Partitioning is such sweet sorrow#
Sun, 13 Apr 2008 23:11:39 +0000
A disk read error occurred Press Ctrl+Alt+Del to restart
If you - as I did this afternoon - have a qemu image containing an NTFS filesystem that you want to enlargen considerably (in my case, from 2GB to ~40), please note that XP Pro will not boot the result unless the number of disk heads in the partition table matches that in the NTFS BIOS Parameter Block (more on that here ) and additionally, IME, both are set to 255. gparted and fdisk both seem to default to 64, which doesn't work.
The basic plan is in the page I linked to and involves qemu-img, fdisk, ntfsresize and hexedit in approxaimately that order. Some other notes:
- kpartx is a neato tool which looks at a disk image, mounts it using
the loopback device and creates device-mapper entries for each
partition. Saves much time mucking around with losetup. Thus
:; sudo kpartx /home/dan/xp.raw -av add map loop0p1 (254:1): 0 83875302 linear /dev/loop0 63
and now you have the whole disk on/dev/loop0
and the partitions under/dev/mapper/loop0p1
,/dev/mapper/loop0p2
etc
- changing the number of heads: I used
sfdisk -l -uS /dev/loop0
to read the existing table, thensfdisk -f -uS -H255 /dev/loop0
to recreate it.
- my first attempt (one of the many that failed) was to boot qemu from a gparted live cd image. This was a waste of time: if you are marginally competent with the command line you can do it all from the host using sfdisk and ntfsresize directly - if you're not then obviously please ignore my advice to have anything at all to do with sfdisk as it will eat your babies.