Device file in /dev/mapper/ present even after removing partition with parted

6,263

It has been possible to fix this issue by updating parted to 2.1-21. We have a system based on CentOS in which certain components are source compiled and parted happens to be one. I have not yet tried to explore if there was any bug in the previous parted release.

Share:
6,263

Related videos on Youtube

pdp
Author by

pdp

Updated on September 18, 2022

Comments

  • pdp
    pdp almost 2 years

    These observations are from CentOS 6.3, 6.4 and 6.5. I have a multipath device with a single partition:

    # ls -l /dev/mapper/
    total 0
    crw-rw---- 1 admin root 10, 57 Dec 22 12:52 control
    lrwxrwxrwx 1 admin root      7 Dec 24 12:22 mpatha -> ../dm-0
    lrwxrwxrwx 1 admin root      7 Dec 24 12:22 mpathap1 -> ../dm-1
    
    # kpartx -l /dev/mapper/mpatha
    mpatha1 : 0 5368719293 /dev/mapper/mpatha 34
    

    Then, parted is used to remove the partition:

    # parted /dev/mapper/mpatha
    GNU Parted 1.7.1
    Using /dev/dm-0
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    
    (parted) unit GB                                                          
    (parted) p                                                                
    
    Disk /dev/dm-0: 2749GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    
    Number  Start   End     Size    File system  Name     Flags
     1      0.00GB  2749GB  2749GB  ext3         primary       
    
    (parted) rm 1                                                             
    (parted) q                                                                
    Information: Don't forget to update /etc/fstab, if necessary.
    

    However, the device special file /dev/mapper/mpathap1 does not get automatically removed. Running ls -l /dev/mapper/ produces exactly the same output as shown above, while kpartx -l /dev/mapper/mpatha, exits normally ($? = 0) without printing anything.

    My question is related to this one. However, there the issue was with no device special file being created in /dev/ while mine is about removal and that too on multipath devices. I am doing certain operations in a script and have already instrumented checks on whether expected device files actually get created or removed and if not then I call kpartx -a -p p <device> (took that hint from /lib/udev/rules.d/40-multipath.rules) or kpartx -d <device> as the case may be. But I have not yet had a satisfying understanding.

    When in general, creating partitions on an extra local disk or a portable hard disk using parted works perfectly fine why should anything more be required to be done on disks coming from a SAN? Any information will be appreciated. Thanks!

    • c4f4t0r
      c4f4t0r about 9 years
      why you created a partion on luns? LUNS = LOGICAL UNIT
    • pdp
      pdp about 9 years
      It is normal to create partitions on a block device. Are there any risks of doing so with LUNs?
  • pdp
    pdp about 9 years
    Done. I have now mentioned CentOS 6.5 in the question.