|
|
022f11 |
From a78d6b7a5e4524f67e9cfea93e3aee153e80f540 Mon Sep 17 00:00:00 2001
|
|
|
022f11 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
022f11 |
Date: Thu, 29 Aug 2013 11:24:00 +0100
|
|
|
022f11 |
Subject: [PATCH] format: Set MBR partition type byte appropriately
|
|
|
022f11 |
(RHBZ#1000428).
|
|
|
022f11 |
|
|
|
022f11 |
Windows won't see a filesystem unless the MBR partition type
|
|
|
022f11 |
byte is set correctly.
|
|
|
022f11 |
|
|
|
022f11 |
$ ./run ./format/virt-format -a /tmp/test.img
|
|
|
022f11 |
$ ./run ./cat/virt-filesystems -a /tmp/test.img --all --long -h
|
|
|
022f11 |
Name Type VFS Label MBR Size Parent
|
|
|
022f11 |
/dev/sda1 filesystem unknown - - 1.0G -
|
|
|
022f11 |
/dev/sda1 partition - - 83 1.0G /dev/sda
|
|
|
022f11 |
/dev/sda device - - - 1.0G -
|
|
|
022f11 |
|
|
|
022f11 |
$ ./run ./format/virt-format -a /tmp/test.img --filesystem=ntfs
|
|
|
022f11 |
$ ./run ./cat/virt-filesystems -a /tmp/test.img --all --long -h
|
|
|
022f11 |
Name Type VFS Label MBR Size Parent
|
|
|
022f11 |
/dev/sda1 filesystem ntfs - - 1.0G -
|
|
|
022f11 |
/dev/sda1 partition - - 07 1.0G /dev/sda
|
|
|
022f11 |
/dev/sda device - - - 1.0G -
|
|
|
022f11 |
|
|
|
022f11 |
$ ./run ./format/virt-format -a /tmp/test.img --filesystem=vfat
|
|
|
022f11 |
$ ./run ./cat/virt-filesystems -a /tmp/test.img --all --long -h
|
|
|
022f11 |
Name Type VFS Label MBR Size Parent
|
|
|
022f11 |
/dev/sda1 filesystem vfat - - 1.0G -
|
|
|
022f11 |
/dev/sda1 partition - - 0b 1.0G /dev/sda
|
|
|
022f11 |
/dev/sda device - - - 1.0G -
|
|
|
022f11 |
|
|
|
022f11 |
$ ./run ./format/virt-format -a /tmp/test.img --lvm --filesystem=vfat
|
|
|
022f11 |
$ ./run ./cat/virt-filesystems -a /tmp/test.img --all --long -h
|
|
|
022f11 |
Name Type VFS Label MBR Size Parent
|
|
|
022f11 |
/dev/VG/LV filesystem vfat - - 1020M -
|
|
|
022f11 |
/dev/VG/LV lv - - - 1020M /dev/VG
|
|
|
022f11 |
/dev/VG vg - - - 1020M /dev/sda1
|
|
|
022f11 |
/dev/sda1 pv - - - 1020M -
|
|
|
022f11 |
/dev/sda1 partition - - 8e 1.0G /dev/sda
|
|
|
022f11 |
/dev/sda device - - - 1.0G -
|
|
|
022f11 |
|
|
|
022f11 |
Thanks: Gerd Hoffmann (kraxel)
|
|
|
022f11 |
(cherry picked from commit d432ab2b5a965110bab542bfd397785eee9753dd)
|
|
|
022f11 |
---
|
|
|
022f11 |
format/format.c | 25 +++++++++++++++++++++++++
|
|
|
022f11 |
1 file changed, 25 insertions(+)
|
|
|
022f11 |
|
|
|
022f11 |
diff --git a/format/format.c b/format/format.c
|
|
|
022f11 |
index 3418d2c..718fb2b 100644
|
|
|
022f11 |
--- a/format/format.c
|
|
|
022f11 |
+++ b/format/format.c
|
|
|
022f11 |
@@ -364,6 +364,31 @@ do_format (void)
|
|
|
022f11 |
exit (EXIT_FAILURE);
|
|
|
022f11 |
}
|
|
|
022f11 |
free_dev = 1;
|
|
|
022f11 |
+
|
|
|
022f11 |
+ /* Set the partition type byte appropriately, otherwise Windows
|
|
|
022f11 |
+ * won't see the filesystem (RHBZ#1000428).
|
|
|
022f11 |
+ */
|
|
|
022f11 |
+ if (STREQ (ptype, "mbr") || STREQ (ptype, "msdos")) {
|
|
|
022f11 |
+ int mbr_id = 0;
|
|
|
022f11 |
+
|
|
|
022f11 |
+ if (vg && lv)
|
|
|
022f11 |
+ mbr_id = 0x8e;
|
|
|
022f11 |
+ else if (filesystem) {
|
|
|
022f11 |
+ if (STREQ (filesystem, "msdos"))
|
|
|
022f11 |
+ mbr_id = 0x01;
|
|
|
022f11 |
+ else if (STREQ (filesystem, "fat") || STREQ (filesystem, "vfat"))
|
|
|
022f11 |
+ mbr_id = 0x0b;
|
|
|
022f11 |
+ else if (STREQ (filesystem, "ntfs"))
|
|
|
022f11 |
+ mbr_id = 0x07;
|
|
|
022f11 |
+ else if (STRPREFIX (filesystem, "ext"))
|
|
|
022f11 |
+ mbr_id = 0x83;
|
|
|
022f11 |
+ else if (STREQ (filesystem, "minix"))
|
|
|
022f11 |
+ mbr_id = 0x81;
|
|
|
022f11 |
+ }
|
|
|
022f11 |
+
|
|
|
022f11 |
+ if (mbr_id > 0)
|
|
|
022f11 |
+ guestfs_part_set_mbr_id (g, devices[i], 1, mbr_id);
|
|
|
022f11 |
+ }
|
|
|
022f11 |
}
|
|
|
022f11 |
|
|
|
022f11 |
if (vg && lv) {
|
|
|
022f11 |
--
|
|
|
022f11 |
1.8.3.1
|
|
|
022f11 |
|