mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
format: Set MBR partition type byte appropriately (RHBZ#1000428).
Windows won't see a filesystem unless the MBR partition type byte is set correctly. $ ./run ./format/virt-format -a /tmp/test.img $ ./run ./cat/virt-filesystems -a /tmp/test.img --all --long -h Name Type VFS Label MBR Size Parent /dev/sda1 filesystem unknown - - 1.0G - /dev/sda1 partition - - 83 1.0G /dev/sda /dev/sda device - - - 1.0G - $ ./run ./format/virt-format -a /tmp/test.img --filesystem=ntfs $ ./run ./cat/virt-filesystems -a /tmp/test.img --all --long -h Name Type VFS Label MBR Size Parent /dev/sda1 filesystem ntfs - - 1.0G - /dev/sda1 partition - - 07 1.0G /dev/sda /dev/sda device - - - 1.0G - $ ./run ./format/virt-format -a /tmp/test.img --filesystem=vfat $ ./run ./cat/virt-filesystems -a /tmp/test.img --all --long -h Name Type VFS Label MBR Size Parent /dev/sda1 filesystem vfat - - 1.0G - /dev/sda1 partition - - 0b 1.0G /dev/sda /dev/sda device - - - 1.0G - $ ./run ./format/virt-format -a /tmp/test.img --lvm --filesystem=vfat $ ./run ./cat/virt-filesystems -a /tmp/test.img --all --long -h Name Type VFS Label MBR Size Parent /dev/VG/LV filesystem vfat - - 1020M - /dev/VG/LV lv - - - 1020M /dev/VG /dev/VG vg - - - 1020M /dev/sda1 /dev/sda1 pv - - - 1020M - /dev/sda1 partition - - 8e 1.0G /dev/sda /dev/sda device - - - 1.0G - Thanks: Gerd Hoffmann (kraxel)
This commit is contained in:
@@ -364,6 +364,31 @@ do_format (void)
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
free_dev = 1;
|
||||
|
||||
/* Set the partition type byte appropriately, otherwise Windows
|
||||
* won't see the filesystem (RHBZ#1000428).
|
||||
*/
|
||||
if (STREQ (ptype, "mbr") || STREQ (ptype, "msdos")) {
|
||||
int mbr_id = 0;
|
||||
|
||||
if (vg && lv)
|
||||
mbr_id = 0x8e;
|
||||
else if (filesystem) {
|
||||
if (STREQ (filesystem, "msdos"))
|
||||
mbr_id = 0x01;
|
||||
else if (STREQ (filesystem, "fat") || STREQ (filesystem, "vfat"))
|
||||
mbr_id = 0x0b;
|
||||
else if (STREQ (filesystem, "ntfs"))
|
||||
mbr_id = 0x07;
|
||||
else if (STRPREFIX (filesystem, "ext"))
|
||||
mbr_id = 0x83;
|
||||
else if (STREQ (filesystem, "minix"))
|
||||
mbr_id = 0x81;
|
||||
}
|
||||
|
||||
if (mbr_id > 0)
|
||||
guestfs_part_set_mbr_id (g, devices[i], 1, mbr_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (vg && lv) {
|
||||
|
||||
Reference in New Issue
Block a user