Skip to contentSkip to conversation

What is the deal with the partition separator?

DISCUSSION Phillip Susi 5 participants 14 messages Feb 16, 2011 – Feb 20, 2011 8 messages not in the archive Device mapper

lore
Share & tools
lore
#0 lore raw

It used to be that partitions device names just had a digit added on to the base disk device name. It seems that this became problematic at some point with device mapper and oddly named disks, and there have been several responses to it:

1) dmraid and (lib)parted now always add a 'p' between the base name and the partition number

2) kpartx from multipath-tools adds the 'p' only if the base name ends in a digit

3) Debian and Ubuntu's udev and init scripts tell kpartx to use 'part' instead of just 'p'.

4) gparted now explicitly tells dmraid to not use any character so that it behaves like older versions and is therefore compatible with the kpartx method that gparted has adopted, at least when the base name does not end with a digit.

Each of these components needs to agree on what the correct name is or chaos ensues. I would like to discuss the merits of each and try to decide on a standard.

Having thought about it for a moment, it seems to me that deciding on always adding the 'p' is the way to go, since the 'art' just makes things longer for no good reason, and if you only sometimes add the 'p' then you can't tell if a device name that ends in a digit that does not follow a 'p' is a whole disk, or a partition.

#1 lore raw
Quoted 23 lines · Phillip Susi

It used to be that partitions device names just had a digit added on to the base disk device name. It seems that this became problematic at some point with device mapper and oddly named disks, and there have been several responses to it:

1) dmraid and (lib)parted now always add a 'p' between the base name and the partition number

2) kpartx from multipath-tools adds the 'p' only if the base name ends in a digit

3) Debian and Ubuntu's udev and init scripts tell kpartx to use 'part' instead of just 'p'.

4) gparted now explicitly tells dmraid to not use any character so that it behaves like older versions and is therefore compatible with the kpartx method that gparted has adopted, at least when the base name does not end with a digit.

Each of these components needs to agree on what the correct name is or chaos ensues. I would like to discuss the merits of each and try to decide on a standard.

Quoted 6 lines

Having thought about it for a moment, it seems to me that deciding on always adding the 'p' is the way to go, since the 'art' just makes things longer for no good reason, and if you only sometimes add the 'p' then you can't tell if a device name that ends in a digit that does not follow a 'p' is a whole disk, or a partition.

No.

The linux scheme since the dawn of time is to
a) Add the partition number to the device node name
b) If last letter of the device node name is a number, insert a 'p' between device node name and partition number

with the advent of persistent device names (via udev) the partition separator (for persistent links only!) is '-part'.

So you have

/dev/sda
/dev/sda1
/dev/disk/by-id/scsi-0WhatAStupidName
/dev/disk/by-id/scsi-0WhatAStupidName-part1

persistent device names are longish anyway, so we can as well use something readable for partitions.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 8 lines · Hannes Reinecke
Quoted 7 lines · Phillip Susi

It used to be that partitions device names just had a digit added on to the base disk device name. It seems that this became problematic at some point with device mapper and oddly named disks, and there have been several responses to it:

1) dmraid and (lib)parted now always add a 'p' between the base name and the partition number

Only newer versions of (lib)parted which link with the dmraid library work this way with dmraid devices. In this situation it is the dmraid library that is coming up with the device names. For all other devices, (lib)parted uses the "linux scheme since the dawn of time" mentioned below. Older versions of (lib)parted follow the "linux scheme since the dawn of time".

Quoted 2 lines
Quoted 2 lines

2) kpartx from multipath-tools adds the 'p' only if the base name ends in a digit

kpartx follows the "linux scheme since the dawn of time" mentioned below.

Quoted 5 lines
Quoted 5 lines

4) gparted now explicitly tells dmraid to not use any character so that it behaves like older versions and is therefore compatible with the kpartx method that gparted has adopted, at least when the base name does not end with a digit.

GParted uses (lib)parted to come up with device names, except in the case of dmraid devices. Because dmraid does not follow the "linux scheme since the dawn of time", gparted calls dmraid directly to create names following the old dmraid standard (only append partition number to device name). If kpartx is available, then GParted will call kpartx to ensure that dmraid device names follow the "linux scheme since the dawn of time". This behaviour enables GParted to work with all versions of dmraid, and maintain compatibility with (lib)parted versions 1.7.1 and higher.

Quoted 22 lines
Quoted 10 lines

Each of these components needs to agree on what the correct name is or chaos ensues. I would like to discuss the merits of each and try to decide on a standard.

Having thought about it for a moment, it seems to me that deciding on always adding the 'p' is the way to go, since the 'art' just makes things longer for no good reason, and if you only sometimes add the 'p' then you can't tell if a device name that ends in a digit that does not follow a 'p' is a whole disk, or a partition.

No.

The linux scheme since the dawn of time is to
a) Add the partition number to the device node name
b) If last letter of the device node name is a number, insert a 'p' between device node name and partition number

with the advent of persistent device names (via udev) the partition separator (for persistent links only!) is '-part'.

So you have

Quoted 9 lines

/dev/sda
/dev/sda1
/dev/disk/by-id/scsi-0WhatAStupidName
/dev/disk/by-id/scsi-0WhatAStupidName-part1

persistent device names are longish anyway, so we can as well use something readable for partitions.

My thoughts are that if possible, tools should try to create partition names using the "linux scheme since the dawn of time", unless there are good reasons to not do this.

Regards,
Curtis Gedak
(Maintainer of GParted)

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 6 lines · Curtis Gedak

Only newer versions of (lib)parted which link with the dmraid library work this way with dmraid devices. In this situation it is the dmraid library that is coming up with the device names. For all other devices, (lib)parted uses the "linux scheme since the dawn of time" mentioned below. Older versions of (lib)parted follow the "linux scheme since the dawn of time".

(lib)parted does not link to dmraid; it contains its own code to generate the name by always adding the 'p' in libparted/arch/linux.c.

Quoted 9 lines

GParted uses (lib)parted to come up with device names, except in the case of dmraid devices. Because dmraid does not follow the "linux scheme since the dawn of time", gparted calls dmraid directly to create names following the old dmraid standard (only append partition number to device name). If kpartx is available, then GParted will call kpartx to ensure that dmraid device names follow the "linux scheme since the dawn of time". This behaviour enables GParted to work with all versions of dmraid, and maintain compatibility with (lib)parted versions 1.7.1 and higher.

It shouldn't be using both dmraid and kpartx to create the partition devices. If dmraid does it, then calling kpartx at best does nothing, and at worst creates duplicate devices.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 9 lines · Phillip Susi
Quoted 6 lines · Curtis Gedak

Only newer versions of (lib)parted which link with the dmraid library work this way with dmraid devices. In this situation it is the dmraid library that is coming up with the device names. For all other devices, (lib)parted uses the "linux scheme since the dawn of time" mentioned below. Older versions of (lib)parted follow the "linux scheme since the dawn of time".

(lib)parted does not link to dmraid; it contains its own code to generate the name by always adding the 'p' in libparted/arch/linux.c.

My bad. (lib)parted does not link with dmraid. It has been a while since I looked deeply into the libparted code.

I do know that the current version of parted in git has a "--enable-device-mapper" option for configure that is enabled by default.
http://git.debian.org/?p=parted/parted.git;a=blob;f=configure.ac;h=25960a74abe909f7b11580aa053c0689a966820d;hb=HEAD#l81

The function _device_get_part_path in libparted/arc/linux.c, does appear to always insert a 'p' for devices such as PED_DEVICE_DM and PED_DEVICE_ATARAID.
http://git.debian.org/?p=parted/parted.git;a=blob;f=libparted/arch/linux.c;h=0288a150769298b92f06d96f8515f96bc27066ea;hb=HEAD#l2198

Regarding the GParted code, it has been written to will work with dmraid devices regardless of whether the "--enable-device-mapper" configure option is enabled or disabled.

Quoted 9 lines
Quoted 9 lines

GParted uses (lib)parted to come up with device names, except in the case of dmraid devices. Because dmraid does not follow the "linux scheme since the dawn of time", gparted calls dmraid directly to create names following the old dmraid standard (only append partition number to device name). If kpartx is available, then GParted will call kpartx to ensure that dmraid device names follow the "linux scheme since the dawn of time". This behaviour enables GParted to work with all versions of dmraid, and maintain compatibility with (lib)parted versions 1.7.1 and higher.

Quoted 3 lines

It shouldn't be using both dmraid and kpartx to create the partition devices. If dmraid does it, then calling kpartx at best does nothing, and at worst creates duplicate devices.

It would be easy in GParted to not call kpartx at all. This is in the code to try to follow the normal partition naming standards for GNU/Linux.

#8 lore raw
In reply to a message not in the archive
Quoted 4 lines · Hannes Reinecke

The linux scheme since the dawn of time is to
a) Add the partition number to the device node name
b) If last letter of the device node name is a number, insert a 'p' between device node name and partition number

Since the dawn of time? Before device mapper it wasn't possible to have a disk device name ending in a digit.

Quoted 5 lines

with the advent of persistent device names (via udev) the partition separator (for persistent links only!) is '-part'.

So you have

Quoted 7 lines

/dev/sda
/dev/sda1
/dev/disk/by-id/scsi-0WhatAStupidName
/dev/disk/by-id/scsi-0WhatAStupidName-part1

persistent device names are longish anyway, so we can as well use something readable for partitions.

That's fine for the symlinks in by-id, but what about the names in /dev/mapper and /dev/VG?

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw
Quoted 9 lines · Phillip Susi
Quoted 4 lines · Hannes Reinecke

The linux scheme since the dawn of time is to
a) Add the partition number to the device node name
b) If last letter of the device node name is a number, insert a 'p' between device node name and partition number

Since the dawn of time? Before device mapper it wasn't possible to have a disk device name ending in a digit.

Unless you happen to have a raid HBA, which has names like

cciss/c0d0

or

rd/c0d0

and, of course, you can have partitions on md devices, too, which will also give you names like
md0p1

Quoted 10 lines
Quoted 10 lines

with the advent of persistent device names (via udev) the partition separator (for persistent links only!) is '-part'.

So you have

/dev/sda
/dev/sda1
/dev/disk/by-id/scsi-0WhatAStupidName
/dev/disk/by-id/scsi-0WhatAStupidName-part1

Quoted 6 lines
Quoted 2 lines

persistent device names are longish anyway, so we can as well use something readable for partitions.

That's fine for the symlinks in by-id, but what about the names in /dev/mapper and /dev/VG?

/dev/mapper contains the names of the device-mapper devices themselves; for those I don't have any preference. kpartx as called from udev is using the '-part' suffix here, too.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 3 lines · Hannes Reinecke

/dev/mapper contains the names of the device-mapper devices themselves; for those I don't have any preference. kpartx as called from udev is using the '-part' suffix here, too.

Right; it needs to not do that. Everyone needs to use the same naming scheme. When you change naming schemes, you get duplicate devices. If dmraid creates them with 'p' and then udev runs kpartx and tells it to use '-part', then you get two partition devices, which will cause all kinds of hell.

Is there any harm done by adding the 'p' even when the base name does not end in a digit? Is there any good reason to?

A message that is not in the archive (sent off-list or not yet received): [email protected]

#14 lore raw
Quoted 11 lines · Phillip Susi
Quoted 3 lines · Hannes Reinecke

/dev/mapper contains the names of the device-mapper devices themselves; for those I don't have any preference. kpartx as called from udev is using the '-part' suffix here, too.

Right; it needs to not do that. Everyone needs to use the same naming scheme. When you change naming schemes, you get duplicate devices. If dmraid creates them with 'p' and then udev runs kpartx and tells it to use '-part', then you get two partition devices, which will cause all kinds of hell.

Which is why you should call 'dmraid' with '-p' to avoid having it creating partitions.
We'll be getting another event via udev, which then trigger kpartx to create the partitons there.

Quoted 2 lines

Is there any harm done by adding the 'p' even when the base name does not end in a digit? Is there any good reason to?

The main problem here is that each and everyone has their own preferred way of naming.
Most tend to stick to the linux model (occasionally inserting a 'p'), some tend to use persistent device names, some tend to use device-mapper / LVM and do away with all partitions etc.

So whichever way you proceed, you should avoid using a naming scheme which resembles the linux one.
Otherwise inevitably someone doesn't get it and starts complaining, one way of the other.

Which was the reason why I chose the '-part' naming scheme; this way it's pretty obvious that a new naming scheme is used. So any objections for it not being compliant to the linux naming scheme are immediately voided.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)

A message that is not in the archive (sent off-list or not yet received): [email protected]

#16 lore raw
Quoted 4 lines · Hannes Reinecke

Which is why you should call 'dmraid' with '-p' to avoid having it creating partitions.
We'll be getting another event via udev, which then trigger kpartx to create the partitons there.

Except that won't work if you don't have kpartx installed, and also users tend to run dmraid directly and don't use -p to change its behavior. The same goes with kpartx. Everyone needs to get on the same page here and do away with -p switches to deviate from the standard behavior, or you run into possibly data corrupting problems.

Quoted 4 lines

Which was the reason why I chose the '-part' naming scheme; this way it's pretty obvious that a new naming scheme is used. So any objections for it not being compliant to the linux naming scheme are immediately voided.

Being VERY non compliant does not void objections that you aren't compliant.

#17 lore raw

Partitions should be created only once, in one place.

If a second instance of anything tries to create them too, it should, by default, detect that they are already there and not proceed.

You should not be able to run kpartx twice on the same underlying disk with different delimiters without some sort of 'force' option.

(Check by querying /sys/.../holders ?)

Alasdair

#18 lore raw
Quoted 1 line · Alasdair G Kergon

(Check by querying /sys/.../holders ?)

Actually, would it be sufficient for kpartx to attempt an exclusive open?

Alasdair

A message that is not in the archive (sent off-list or not yet received): 20110217165332.GE28729-FDJ95KluN3Z0klwcnFlA1dvLeJWuRmrY@public.gmane.org

#20 lore raw

Oops, didn't see this until today because this darn mailing list mangles the reply-to header. *shakes fist*

Currently all of the tools check by trying to open the expected device name. If they have different ideas of what that is, the check fails to find the existing instance. It is looking to me like the way to fix this is to patch dmraid and libparted so that they conform with the kpartx and "linux since the dawn of time" method of only adding the 'p' if the previous character is a digit.

Quoted 9 lines · Alasdair G Kergon

Partitions should be created only once, in one place.

If a second instance of anything tries to create them too, it should, by default, detect that they are already there and not proceed.

You should not be able to run kpartx twice on the same underlying disk with different delimiters without some sort of 'force' option.

(Check by querying /sys/.../holders ?)

#21 lore raw
In reply to a message not in the archive
Quoted 2 lines · Hannes Reinecke

So whichever way you proceed, you should avoid using a naming scheme which resembles the linux one.

From my perspective as a maintainer of partitioning software it would be nice if given the device name and partition number I could easily determine the partition name.

Unfortunately this is not easily done when there are deviations from the linux model ("insert a 'p' between the device name and the partition number when the device name ends in a number").

Each deviation from the linux partition naming model results in more code to handle the deviation, and a corresponding increased number of test cases to avoid errors.

Regards,
Curtis Gedak
(Maintainer of GParted)