[Parted-maintainers] Bug#619330: libparted0debian1: false detection partition busy state through device mapper

Vaclav Ovsik vaclav.ovsik at gmail.com
Tue Mar 22 22:47:58 UTC 2011


Package: libparted0debian1
Version: 2.3-5
Severity: normal

Hi,
the code snippets in the source file libparted/arch/linux.c

...
static dev_t
_partition_get_part_dev (const PedPartition* part)
{
        struct stat dev_stat;
        int dev_major, dev_minor;

        if (stat (part->disk->dev->path, &dev_stat))
                return (dev_t)0;
        dev_major = major (dev_stat.st_rdev);
        dev_minor = minor (dev_stat.st_rdev);
        return (dev_t)makedev (dev_major, dev_minor + part->num);
}
...

...
static int
_partition_is_mounted (const PedPartition *part)
{
        dev_t dev;
        if (!ped_partition_is_active (part))
                return 0;
        dev = _partition_get_part_dev (part);
        if (!dev)
                return 0;
        return _partition_is_mounted_by_dev (dev);
}
...

The above code assumes the partition major & minor numbers can be constructed
as the major number the same as the main device and the minor number as the
main device minor number plus the partition number. This is not true at least
for a LVM HDD image with mapped partitions (probably the same for a HDD image
in a file...)

I discovered this problem while trying to repartition the virtual
machine HDD image on LV using gparted, parted or cfdisk.

I have an image /dev/mapper/vg-helpd and partitions mapped by parted:

bobek:~# ls -la /dev/mapper/vg-helpd*
lrwxrwxrwx 1 root root       8 Mar 22 19:33 /dev/mapper/vg-helpd -> ../dm-26
brw-rw---- 1 root disk 254, 31 Mar 22 22:04 /dev/mapper/vg-helpdp1
brw-rw---- 1 root disk 254, 32 Mar 22 22:04 /dev/mapper/vg-helpdp2
brw-rw---- 1 root disk 254, 33 Mar 22 22:04 /dev/mapper/vg-helpdp5
brw-rw---- 1 root disk 254, 34 Mar 22 22:04 /dev/mapper/vg-helpdp6
brw-rw---- 1 root disk 254, 35 Mar 22 22:04 /dev/mapper/vg-helpdp7
brw-rw---- 1 root disk 254, 36 Mar 22 22:04 /dev/mapper/vg-helpdp8

So the partition number 1 has minor number 31 and not 27. Minor number
27 has my root file system (of course mounted :)

bobek:~# dmsetup ls|grep 27
root	(254, 27)

So I end up with:

bobek:~# parted /dev/mapper/vg-helpd check 1
WARNING: you are attempting to use parted to operate on (check) a file system.
parted's file system manipulation code is not as robust as what you'll find in
dedicated, file-system-specific packages like e2fsprogs.  We recommend
you use parted only to manipulate partition tables, whenever possible.
Support for performing most operations on most types of file systems
will be removed in an upcoming release.
Error: Partition /dev/mapper/vg-helpdp1 is being used. You must unmount it before you modify it with Parted.

So this is the problem
Best Regards
-- 
Zito


-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (x86_64)

Kernel: Linux 2.6.38-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=cs_CZ.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libparted0debian1 depends on:
ii  libblkid1                    2.17.2-9.1  block device id library
ii  libc6                        2.11.2-11   Embedded GNU C Library: Shared lib
ii  libdevmapper1.02.1           2:1.02.63-2 The Linux Kernel Device Mapper use
ii  libuuid1                     2.17.2-9.1  Universally Unique ID library

libparted0debian1 recommends no packages.

Versions of packages libparted0debian1 suggests:
pn  libparted0-dev                <none>     (no description available)
pn  libparted0-i18n               <none>     (no description available)
ii  parted                        2.3-5      The GNU Parted disk partition resi

-- no debconf information





More information about the Parted-maintainers mailing list