Add snapshot to P2V VM and it no longer boots + solution
Posted: 6. Aug 2010, 13:55
I recently battled a problem where a P2V VM guest would boot OK while booting directly from the base VDI file (when NO snapshots were in place), but as soon as a snapshot was created, would give the :
I think I found a bug with snapshots, but there was a fairly easy workaround, which I am documenting here.
The bug:
VirtualBox apparently uses one set of rules for setting the virtual disk logical geometry of a base disk (HDD in HardDisks folder), and another set for setting the disk logical geometry for snapshots. When these rules produce different logical geometries, an operating system (Windows only?) that boots OK on the base disk geometry will then fail to boot when the logical geometry changes for the snapshot.
I'm not sure if the exact rules for a base hard disk, but usually the logical geometry is set to LCHS = n/255/63 (n cylinders, 255 heads/cylinder, 63 sectors/track).
VBox.log contains entries like so:... and as long as the Windows Volume Boot Record also specifies 255 heads, the VM boots OK.
The logical geometry of a snapshot is set based on the partition in the Master Boot Record.
VirtualBox apparently examines (as of 3.2.x? or as of before?) the heads/cylinder value of the partitions present, and assumes the logical geometry based on that.
For example, with a partition map like so:... VirtualBox assumes that there are 5 logical heads/cylinder. When Windows boots, it still uses 255 (as in the VBR), but the VirtualBox virtual BIOS returns an error because it thinks there should only be 5 heads/cylinder.
VBox.log contains entries like so:
The workaround is to resize the partitions so that they start and end on whole cylinder boundaries, so that VirtualBox will see 255 heads in the partition and use 255.
GParted (included on the Parted Magic live CD) can move and resize the partitions:
- Delete any snapshots on the VM.
- Launch GParted in the VM ('Partition Editor' icon in Parted Magic) - attach a Live CD if needed.
- Select any partitions following the main boot partition, click 'Resize/Move', set 'Free Space Preceeding' to 1MiB, ensure that 'Round to cylinders' is CHECKED ON, and click Resize/Move.
(NOTE: Check that GParted does NOT say: 'and shrink /dev/hd...' at any point, because it is safer to keep the partition size the same or Grow it. If it does say 'shrink', then click 'Undo' and try again but increase the 'New Size' field.)
A new 'unallocated' section should appear in front of that partition in the map. If it does not, click 'Undo' and repeat the steps above and set the 'Free Space' to 2MiB and so on until an 'unallocated' gap does appear.
- Select the boot partition, click 'Resize/Move', set the 'New Size' field as high as it will go, click 'Resize/Move'.
The 'unallocated' gap should now disappear.
Click 'Apply' to start the partition resizing.
- Afterwards, a tool such as CloneVDI can confirm that the partition heads are now correct (open the base VDI and click the 'Partition Info...' button and confirm that the 'Last sector' column heads now reads n/255/63).
- When the VM is next booted, the OS may notice the changed partitions and do a repair. If it does not do so, you may want to manually 'chkdsk /f' all of the moved partitions to ensure they are OK.
READ the '-2- What happens with NTFSD file system' section of this link : http://gparted.sourceforge.net/larry/re ... sizing.htm.
If the partition contains an installation of Windows, performing a disk check is critical! Do not skip a disk check between each operation under any circumstance!
... error when trying to boot it with the snapshot present.A disk read error occurred.
Insert a system diskette and restart the system
I think I found a bug with snapshots, but there was a fairly easy workaround, which I am documenting here.
The bug:
VirtualBox apparently uses one set of rules for setting the virtual disk logical geometry of a base disk (HDD in HardDisks folder), and another set for setting the disk logical geometry for snapshots. When these rules produce different logical geometries, an operating system (Windows only?) that boots OK on the base disk geometry will then fail to boot when the logical geometry changes for the snapshot.
I'm not sure if the exact rules for a base hard disk, but usually the logical geometry is set to LCHS = n/255/63 (n cylinders, 255 heads/cylinder, 63 sectors/track).
VBox.log contains entries like so:
Code: Select all
00:00:00.484 PIIX3 ATA: LUN#0: disk, PCHS=16383/16/63, total number of sectors 83886080
00:00:00.815 DevPcBios: ATA LUN#0 LCHS=1024/255/63
00:00:00.884 Guest Log: BIOS: ata0-0: PCHS=16383/16/63 LCHS=1024/255/63The logical geometry of a snapshot is set based on the partition in the Master Boot Record.
VirtualBox apparently examines (as of 3.2.x? or as of before?) the heads/cylinder value of the partitions present, and assumes the logical geometry based on that.
For example, with a partition map like so:
Code: Select all
1 (C:) First Sector c=0,h=1,s=1 Last Sector c=261,h=4,s=63
1 (D:) First Sector c=261,h=5,s=1 Last Sector c=498,h=113,s=63VBox.log contains entries like so:
Code: Select all
00:00:00.620 PIIX3 ATA: LUN#0: disk, PCHS=16383/16/63, total number of sectors 83886080
00:00:00.966 DevPcBios: ATA LUN#0 LCHS=1024/5/63
00:00:01.036 Guest Log: BIOS: ata0-0: PCHS=16383/16/63 LCHS=1024/5/63
00:00:03.816 Guest Log: BIOS: Booting from Hard Disk...
00:00:03.818 Guest Log: BIOS: int13_harddisk: function 02, parameters out of range 000a/0047/0028!GParted (included on the Parted Magic live CD) can move and resize the partitions:
- Delete any snapshots on the VM.
- Launch GParted in the VM ('Partition Editor' icon in Parted Magic) - attach a Live CD if needed.
- Select any partitions following the main boot partition, click 'Resize/Move', set 'Free Space Preceeding' to 1MiB, ensure that 'Round to cylinders' is CHECKED ON, and click Resize/Move.
(NOTE: Check that GParted does NOT say: 'and shrink /dev/hd...' at any point, because it is safer to keep the partition size the same or Grow it. If it does say 'shrink', then click 'Undo' and try again but increase the 'New Size' field.)
A new 'unallocated' section should appear in front of that partition in the map. If it does not, click 'Undo' and repeat the steps above and set the 'Free Space' to 2MiB and so on until an 'unallocated' gap does appear.
- Select the boot partition, click 'Resize/Move', set the 'New Size' field as high as it will go, click 'Resize/Move'.
The 'unallocated' gap should now disappear.
Click 'Apply' to start the partition resizing.
- Afterwards, a tool such as CloneVDI can confirm that the partition heads are now correct (open the base VDI and click the 'Partition Info...' button and confirm that the 'Last sector' column heads now reads n/255/63).
- When the VM is next booted, the OS may notice the changed partitions and do a repair. If it does not do so, you may want to manually 'chkdsk /f' all of the moved partitions to ensure they are OK.
READ the '-2- What happens with NTFSD file system' section of this link : http://gparted.sourceforge.net/larry/re ... sizing.htm.
If the partition contains an installation of Windows, performing a disk check is critical! Do not skip a disk check between each operation under any circumstance!