All of lore.kernel.org
 help / color / mirror / Atom feed
* Choosing the device name in kpartx.
@ 2016-10-02  5:10 Andre Caldas
  2016-10-03  6:59 ` Bryn M. Reeves
  0 siblings, 1 reply; 4+ messages in thread
From: Andre Caldas @ 2016-10-02  5:10 UTC (permalink / raw)
  To: dm-devel

Dear developers,

I am writing a script using kpartx. It seems to be a very very nice
tool that will make my life a lot easier!

As I understood it, when I call
$ kpartx -a disk.img
kpartx chooses a "device name" X, detects the partitions and their
numbers N, and creates device nodes with naming
XpN.

As I understood it, the correct way to know what name X was chosen, is
to parse the output. I am not comfortable on depending on the format
of something that looks to be intended for humans and not computers.

I think it would be really nice if I could choose the name X myself.
Of course, I would get an error if the name is already in use...

In my script, I know the partition numbers. I can choose the delimiter
with "-p". In my opinion, it would be nice if:
1. I could chose X myself; or
2. If there was an option to get the output of kpartx to be just the
path to the "root" device; or
3. If there was an option to get the output of kpartx to be standard
and intended for parsing; or
4. The documentation stated that the output is not supposed to change
in future versions of kpartx.

Well... maybe I just missed the "correct" way to script with kpartx.
In this case, I would be happy with some guidance... :-)

In my script, I create a file with dd, partition it using sfdisk, then
mount it using kpartx/mount.


Thank you for your time and patience...
André Caldas.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Choosing the device name in kpartx.
  2016-10-02  5:10 Choosing the device name in kpartx Andre Caldas
@ 2016-10-03  6:59 ` Bryn M. Reeves
  2016-10-03 11:35   ` Andre Caldas
  2016-10-03 11:48   ` Bryn M. Reeves
  0 siblings, 2 replies; 4+ messages in thread
From: Bryn M. Reeves @ 2016-10-03  6:59 UTC (permalink / raw)
  To: Andre Caldas; +Cc: dm-devel

On Sun, Oct 02, 2016 at 02:10:50AM -0300, Andre Caldas wrote:
> As I understood it, when I call
> $ kpartx -a disk.img
> kpartx chooses a "device name" X, detects the partitions and their
> numbers N, and creates device nodes with naming
> XpN.

This command performs several steps for you. You can have greater
control by issuing those steps yourself:

1. Create a loop device mapping the image (/dev/loopN)
2. Create a device-mapper device with a linear map of the loop:

   # dmsetup create $DEV_NAME --table="0 $DEV_SIZE linear /dev/loopN"

   This allows you to give any DEV_NAME you like to the device (with
   the default kpartx behaviour, the partitions just map the loop
   device, so have names like 'loop0p1' etc.).

3. Map partitions on the new dm device with kpartx:

   # kpartx -a /dev/mapper/$DEV_NAME

See the kpartx man page for options to fine-tune the partition device
names.

The dmsetup command has lots of options to control the output format
that can be used to get readily parseable data.

Regards,
Bryn.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Choosing the device name in kpartx.
  2016-10-03  6:59 ` Bryn M. Reeves
@ 2016-10-03 11:35   ` Andre Caldas
  2016-10-03 11:48   ` Bryn M. Reeves
  1 sibling, 0 replies; 4+ messages in thread
From: Andre Caldas @ 2016-10-03 11:35 UTC (permalink / raw)
  To: Bryn M. Reeves; +Cc: dm-devel

Dear Bryn,


> The dmsetup command has lots of options to control the output format
> that can be used to get readily parseable data.

Thank you very much for your help!
You have just proven I was not taking the right approach... :-)
I will try dmsetup.


Cheers,
André Caldas.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Choosing the device name in kpartx.
  2016-10-03  6:59 ` Bryn M. Reeves
  2016-10-03 11:35   ` Andre Caldas
@ 2016-10-03 11:48   ` Bryn M. Reeves
  1 sibling, 0 replies; 4+ messages in thread
From: Bryn M. Reeves @ 2016-10-03 11:48 UTC (permalink / raw)
  To: Andre Caldas; +Cc: dm-devel

On Mon, Oct 03, 2016 at 07:59:41AM +0100, Bryn M. Reeves wrote:
> On Sun, Oct 02, 2016 at 02:10:50AM -0300, Andre Caldas wrote:
> > As I understood it, when I call
> > $ kpartx -a disk.img
> > kpartx chooses a "device name" X, detects the partitions and their
> > numbers N, and creates device nodes with naming
> > XpN.
> 
> This command performs several steps for you. You can have greater
> control by issuing those steps yourself:
> 
> 1. Create a loop device mapping the image (/dev/loopN)
> 2. Create a device-mapper device with a linear map of the loop:
> 
>    # dmsetup create $DEV_NAME --table="0 $DEV_SIZE linear /dev/loopN"

Typo: this should be "0 $DEV_SIZE linear /dev/loopN 0" (an extra '0'
at the end) - this is the starting offset for the mapping, which is
always zero for a whole-disk device.

Regards,
Bryn.
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-03 11:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-02  5:10 Choosing the device name in kpartx Andre Caldas
2016-10-03  6:59 ` Bryn M. Reeves
2016-10-03 11:35   ` Andre Caldas
2016-10-03 11:48   ` Bryn M. Reeves

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.