Re: [PATCH] kpartx: Add -P option for partition scanning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 22, 2022 at 06:59:10PM +0000, Ritika Srivastava wrote:
> On 2/22/22, 10:28 AM, "Benjamin Marzinski" wrote:
> 
>     On Fri, Feb 11, 2022 at 12:41:48PM -0800, Ritika Srivastava wrote:
>     >> Add -P, partition scanning option to kpartx which would set
>     >> LO_FLAGS_PARTSCAN flag during loop device creation.
>     >> This option is same as losetup -P option.
> 
>     >I'm confused here. What's the benefit of doing this? Doesn't this create
>     >partition devices, just like kpartx would?
> 
> This enables partition scanning for loop devices created via kpartx.
> When enabled, LO_FLAGS_PARTSCAN flag will be set during loop creation via kpartx -a.
> On detach (kpartx -d), any partitions (/dev/loopXpY) would also be removed.
> It has similar use cases as losetup -P option.
> 
> Currently, kpartx does not create partition loop devices (/dev/loopXpY)  via kpartx -a

And I'm trying to figure out why you want to create /dev/loop0p1 if you
already have /dev/mapper/loop0p1?  The ability of kpartx to create
partitioned loop devices predates the existance "kpartx -P". So perhaps
the better question is, why do you want to run

# kpartx -av test.img

instead of just running

# loasetup -fP test.img

They both get you partition devices, and you don't need both of them.
Or do you, for some reason I don't understand?

-Ben

> Example:
> 1. Current behavior: kpartx -a does not create /dev/loop0p1
> 
> # kpartx -av test.img
> add map loop0p1 (252:0): 0 99937 linear /dev/loop0 64
> 
> (Notice below: /dev/loop0p1 NOT created)
> # ls -l /dev/loop0*
> brw-rw----. 1 root disk  7,   0 Jan 14 20:46 /dev/loop0 
> 
> 2. IF -P IS USED to create loop device, /dev/loop0p1 IS created.
> 
> # kpartx -av -P test.img
> add map loop0p1 (252:0): 0 99937 linear /dev/loop0 64
> 
> (Notice below: /dev/loop0p1 IS created)
> # ls -l /dev/loop0*
> brw-rw----. 1 root disk   7,   0 Jan 14 20:50 /dev/loop0
> brw-rw----. 1 root disk 259,   0 Jan 14 20:50 /dev/loop0p1
> 
> 
> Similar behavior can also be observed during detach
> 1. Current Behavior:  kpartx -d does NOT delete partitions
> 
> # kpartx -a -v test.img
> # parted -a none -s /dev/loop0 mkpart primary 64s 100000s
> 
> # ls -l /dev/loop0*
> brw-rw----. 1 root disk   7,   0 Jan 14 20:54 /dev/loop0
> brw-rw----. 1 root disk 259,   0 Jan 14 20:54 /dev/loop0p1
> 
> # kpartx -d test.img
> loop deleted : /dev/loop0
> 
> (Notice: /dev/loop0p1 NOT deleted)
> # ls -l /dev/loop0*
> brw-rw----. 1 root disk   7,   0 Jan 14 20:54 /dev/loop0
> brw-rw----. 1 root disk 259,   0 Jan 14 20:54 /dev/loop0p1
> 
> 2. IF -P IS added while creating loop, kpartx -d DOES delete loop0p1
> 
> # kpartx -a -v -P test.img
> # parted -a none -s /dev/loop0 mkpart primary 64s 100000s
> 
> # ls -l /dev/loop0*
> brw-rw----. 1 root disk   7,   0 Jan 14 20:46 /dev/loop0
> brw-rw----. 1 root disk 259,   0 Jan 14 20:46 /dev/loop0p1
> 
> # kpartx -d test.img
> loop deleted : /dev/loop0
> 
> (Notice: /dev/loop0p1 IS deleted)
> # ls -l /dev/loop0*
> brw-rw----. 1 root disk  7,   0 Jan 14 20:46 /dev/loop0
> 
> Thanks,
> Ritika
> 
> 
> 

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux