[parted-devel] [PATCH] fix handling of disks that can't be partitioned

Joel Granados jgranado at redhat.com
Mon Feb 9 16:48:19 UTC 2009


In any case, parted, still, correctly creates the partition in the LV.  Proof of this is that I can execute the kpartx command, and it will read and create the /dev/mapper/VolGrou00-lvp1 node for the partition.
----- "Joel Granados" <jgranado at redhat.com> wrote:

> A little correction to my post,  I tried the test with parted (master)
> and it seems to error out.  "error informing the kernel"
> 
> Will look into this.
> ----- "Joel Granados" <jgranado at redhat.com> wrote:
> 
> > This is not necessary IMO.  parted (master) correctly creates a
> > partition on a device (its a mapped device, but a device none the
> > less).  additionally you can create a filesystem on top of this
> > partition and mount it and use it as if it were a normal device.
> > 
> > If the issue is related to the partition being available after boot
> > this might be an issue that is solvable with tools like mkinitrd
> where
> > the partitions must be activated with commands like kpartx for them
> to
> > be available as /home or swap or whatever.
> > 
> > Taking this into account, I don't think this patch is of any
> > relevance
> > 
> > regards.
> > ----- "Colin Watson" <cjwatson at ubuntu.com> wrote:
> > 
> > > Don't try to call BLKPG ioctls or tell device-mapper to create
> > > partitions on disks that can't be partitioned. This fixes the
> > > creation
> > > of bogus "/dev/mapper/vg-lvp1"-type devices for LVM logical
> > volumes.
> > > 
> > > Signed-off-by: Colin Watson <cjwatson at ubuntu.com>
> > > 
> > > diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
> > > index 83e24c8..a2af223 100644
> > > --- a/libparted/arch/linux.c
> > > +++ b/libparted/arch/linux.c
> > > @@ -2166,6 +2166,18 @@ linux_partition_is_busy (const
> PedPartition*
> > > part)
> > >  }
> > >  
> > >  static int
> > > +_has_partitions (const PedDisk* disk)
> > > +{
> > > +        PED_ASSERT(disk != NULL, return 0);
> > > +
> > > +        /* Some devices can't be partitioned. */
> > > +        if (!strcmp (disk->type->name, "loop"))
> > > +                return 0;
> > > +
> > > +        return 1;
> > > +}
> > > +
> > > +static int
> > >  _blkpg_part_command (PedDevice* dev, struct blkpg_partition*
> part,
> > > int op)
> > >  {
> > >          LinuxSpecific*          arch_specific = LINUX_SPECIFIC
> > > (dev);
> > > @@ -2190,6 +2202,9 @@ _blkpg_add_partition (PedDisk* disk, const
> > > PedPartition *part)
> > >          PED_ASSERT(disk->dev->sector_size %
> > PED_SECTOR_SIZE_DEFAULT
> > > == 0,
> > >                     return 0);
> > >  
> > > +        if (!_has_partitions (disk))
> > > +                return 0;
> > > +
> > >          if (ped_disk_type_check_feature (disk->type,
> > >                                          
> > > PED_DISK_TYPE_PARTITION_NAME))
> > >                  vol_name = ped_partition_get_name (part);
> > > @@ -2238,6 +2253,9 @@ _blkpg_remove_partition (PedDisk* disk, int
> > n)
> > >  {
> > >          struct blkpg_partition  linux_part;
> > >  
> > > +        if (!_has_partitions (disk))
> > > +                return 0;
> > > +
> > >          memset (&linux_part, 0, sizeof (linux_part));
> > >          linux_part.pno = n;
> > >          return _blkpg_part_command (disk->dev, &linux_part,
> > > @@ -2421,6 +2439,9 @@ _dm_add_partition (PedDisk* disk,
> > PedPartition*
> > > part)
> > >          char*           dev_name = NULL;
> > >          char*           params = NULL;
> > >  
> > > +        if (!_has_partitions(disk))
> > > +                return 0;
> > > +
> > >          dev_name = _device_get_part_path (disk->dev, part->num);
> > >          if (!dev_name)
> > >                  return 0;
> > > 
> > > -- 
> > > Colin Watson                                      
> > > [cjwatson at ubuntu.com]
> > > 
> > > _______________________________________________
> > > parted-devel mailing list
> > > parted-devel at lists.alioth.debian.org
> > > http://lists.alioth.debian.org/mailman/listinfo/parted-devel
> > 
> > -- 
> > Joel Andres Granados
> > Red Hat / Brno Czech Republic
> > 
> > _______________________________________________
> > parted-devel mailing list
> > parted-devel at lists.alioth.debian.org
> > http://lists.alioth.debian.org/mailman/listinfo/parted-devel
> 
> -- 
> Joel Andres Granados
> Red Hat / Brno Czech Republic
> 
> _______________________________________________
> parted-devel mailing list
> parted-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/parted-devel

-- 
Joel Andres Granados
Red Hat / Brno Czech Republic



More information about the parted-devel mailing list