[parted-devel] [PATCH] keep kernel interface to extended partition
on Linux
Olaf Hering
olh at suse.de
Fri Jul 21 09:13:52 UTC 2006
This testcase removes the kernel interface to the first 1 or 2 blocks of an
extended partition on an msdos disk label. The Linux kernel allows bootloaders
to be installed there.
Parted just removes the kernel device, bootloaders cant be installed anymore
without a blockdev --rereadpt /dev/sda
+ blockdev --rereadpt /dev/sda
+ parted -s /dev/sda mklabel msdos
+ parted -s /dev/sda mkpart extended 1G 4G
+ blockdev --rereadpt /dev/sda
+ grep sda /proc/partitions
8 0 78150744 sda
8 1 1 sda1
+ parted -s /dev/sda mkpart logical 2G 3G
+ grep sda /proc/partitions
8 0 78150744 sda
8 5 2923798 sda5
+ blockdev --rereadpt /dev/sda
+ grep sda /proc/partitions
8 0 78150744 sda
8 1 1 sda1
8 5 2923798 sda5
This patch may break dvh partition table handling. Both 'msdos' and 'dvh'
use the PED_PARTITION_EXTENDED flag.
---
libparted/arch/linux.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
Index: parted-1.7.1/libparted/arch/linux.c
===================================================================
--- parted-1.7.1.orig/libparted/arch/linux.c
+++ parted-1.7.1/libparted/arch/linux.c
@@ -1806,7 +1806,11 @@ _blkpg_add_partition (PedDisk* disk, Ped
memset (&linux_part, 0, sizeof (linux_part));
linux_part.start = part->geom.start * disk->dev->sector_size;
- linux_part.length = part->geom.length * disk->dev->sector_size;
+ /* see fs/partitions/msdos.c:msdos_partition(): "leave room for LILO" */
+ if (part->type & PED_PARTITION_EXTENDED)
+ linux_part.length = part->geom.length == 1 ? 512 : 1024;
+ else
+ linux_part.length = part->geom.length * disk->dev->sector_size;
linux_part.pno = part->num;
strncpy (linux_part.devname, dev_name, BLKPG_DEVNAMELTH);
if (vol_name)
@@ -1863,13 +1867,6 @@ _disk_sync_part_table (PedDisk* disk)
part = ped_disk_get_partition (disk, i);
if (part) {
- /* extended partitions have no business in the kernel!
- * blkpg doesn't like overlapping partitions. Hmmm,
- * LILO isn't going to like this.
- */
- if (part->type & PED_PARTITION_EXTENDED)
- continue;
-
/* busy... so we won't (can't!) disturb ;) Prolly
* doesn't matter anyway, because users shouldn't be
* changing mounted partitions anyway...
More information about the parted-devel
mailing list