cptaffe / plan9front

Automatically exported from code.google.com/p/plan9front
0 stars 0 forks source link

disk/fdisk breaks existing partitions #68

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
disk/fdisk might break existing partitions because
it aligns all lba offsets to cylinder boundries.

Original issue reported on code.google.com by cinap_le...@felloff.net on 13 Jul 2011 at 3:37

GoogleCodeExporter commented 9 years ago
I remember fdisk also fucking things up when there are extended partitions. 
Somebody in #cat-v seems to have run into this (or something else) which 
corrupted two of his existing partitions.

Given that fdisk has not been reliable for years, I think we should simply make 
it impossible to edit existing partition tables, fdisk should only allow 
creation of new partition tables from scratch, which should be the common case 
anyway, and which should ensure we don't fuck over anyone. (Maybe we can have a 
flag to disable this 'safe' behavior in case somebody wants to play with fire).

Original comment by ur...@berlinblue.org on 17 Jul 2011 at 2:48

GoogleCodeExporter commented 9 years ago
I am the one from #cat-v.

My partition layout as reported by fdisk -l:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63     3068414     1534176    7  HPFS/NTFS/exFAT
/dev/sda2         3068415   167766794    82349190    7  HPFS/NTFS/exFAT
/dev/sda3       167782860   281860424    57038782+   f  W95 Ext'd (LBA)
/dev/sda5       167782923   202194089    17205583+  83  Linux
/dev/sda6       202194153   203238314      522081   82  Linux swap / Solaris
/dev/sda7       203238378   281860424    39311023+   7  HPFS/NTFS/exFAT

sda1 is windows recovery partition. The windows boot loader is installed there.
sda2 is an NTFS data partition.
sda3 is and extended partition.
sda5 is linux / (root) - logical
sda6 is linux swap - logical
sda7 is NTFS windows server 2008 R2 - also logical

This is after deleting the new plan9 fat partition.

In the install process, boot loader step, I chose the option "plan9" and asked 
the installer to skip writing a new MBR since I already use GRUB2 for dual 
booting windows and linux.

sda1 and sda2 got corrupt. gnu parted says their filesystem type is unknown. 
fdisk knows the type as you can see above. Now windows can't boot although its 
partition (sda7) hasn't been damaged because sda1 contains its boot loader.
The files on the data partition (sda2) are not accessible. mount is impossible 
because "ntfs signature is missing".

Original comment by J.La...@gmail.com on 17 Jul 2011 at 3:29

GoogleCodeExporter commented 9 years ago
"Only create" sounds problematical. Deleting partitions is also needed for new 
non-vm installs if nothing else, but that's not the big problem.

What it's doing is converting existing partitions, which is Sick And Evil™, 
but if we want it to avoid "touching" other partitions it needs to calculate 
the maximum possible extent of the preceding partition (on-disk, not in table 
order) and the minimum possible start of the following partition. Either that 
or at least waste 1 cylinder either side, since it works in cylinders.

Original comment by tereniao...@gmail.com on 17 Jul 2011 at 3:30

GoogleCodeExporter commented 9 years ago
Also possibly refuse to delete partitions with type: extended.

Original comment by tereniao...@gmail.com on 17 Jul 2011 at 4:15

GoogleCodeExporter commented 9 years ago
eekee, you are missing what I meant, and how fdisk works, fdisk always creates 
its own fucked up view of what is in the existing table, and then writes it 
from scratch.

What I'm suggesting is that we make it explicit that we do not support (perhaps 
unless an special flag is passed) loading existing tables at all, we can 
overwrite an existing table, but not pretend we can 'edit' it by loading and 
then writing it back in.

Original comment by ur...@berlinblue.org on 17 Jul 2011 at 4:17

GoogleCodeExporter commented 9 years ago
Nope, I gotcha, uriel. I was just trying to point out "not touching other 
partitions" is not overly simple, and try to point out a way in which partition 
editing might still be possible. Probably useless, come to think of it.

Original comment by tereniao...@gmail.com on 17 Jul 2011 at 4:27

GoogleCodeExporter commented 9 years ago
Not touching other partitions is very simple: On startup give the user two 
options: 1) Quit fdisk. 2) Wipe out your existing partition table and override 
it with a blank one.

Original comment by ur...@berlinblue.org on 17 Jul 2011 at 8:19

GoogleCodeExporter commented 9 years ago
problem addressed:

http://code.google.com/p/plan9front/source/detail?r=47505fef802a58675ca54effeb84
0b852a5a6a13

Original comment by cinap_le...@felloff.net on 17 Jul 2011 at 8:32

GoogleCodeExporter commented 9 years ago
Why did you call the fix "fdisk: attempt fixing extended partition handling"? 
From my experience the extended partition was not damaged after the install. 
Only the other primary ones got corrupt.
What am I missing?

Original comment by J.La...@gmail.com on 17 Jul 2011 at 11:48

GoogleCodeExporter commented 9 years ago
there where 2 problems. the probelm you reported was
fixed here:

http://code.google.com/p/plan9front/source/detail?r=a7b226cbc2e71c2e76f58c2ca874
25bb6f041013

Original comment by cinap_le...@felloff.net on 18 Jul 2011 at 12:09