0

Explain the disk partition descriptors

The man page about gpart add is:

(https://www.freebsd.org/cgi/man.cgi?gpart(8))

index : "The index in the partition table at which the new partition is to be placed. The index determines the name of the device special file used to represent the partition."

Questions: So by representative does this mean that it is for human identification? what is a special file? What exactly is this for?


label : "The label attached to the partition. This option is only valid when used on partitioning schemes that support partition labels."

Questions: Isn't the index also attached to the partition, as in each partition has an index and a label? How is this different? The next line gives a special case, but again there is no explanation or examples of what this is actually for.

My guess is that a partition label gives the format of the particular partition. Or is that type?


type no explanation given. It doesn't actually give an explanation for what it is in the add subsection nor in the PARTITION subsection. I am able to deduce from past experience formatting disks that type will define the format of my disk partition. format, from my personal experience, determines the compression, access methods, and read/write behavior of that particular partition. When considering a format it is important to consider a number of factors (speed, recoverability, compatibility).

Related SO answers

I found this SO explanation (What is the difference between a partition name and a partition label?) about the difference between label and name, which is quite helpful.

Justification

I think it would be nice to succinctly give an expalanation for each of the available options in gpart add that explain disk labelling and description, as someone with little or no knowledge of disk management will get lost with the man page and the at least the first 3 pages of internet searches.

Criteria for best answer:

give an improved explanation for each partition descriptor (label, name, type, index, and flag). 1. Explaining reason for being (ex: label is used by intramfs at boottime to distinguish mounted devices)
2. Explaining what to consider when choosing (fat16 and fat32 msdosfs file systems are good for compatibility with windows systems, ext4 has some compatibility issues with windows but is good for data integrity (as it has journaling).

1
  • for reference: I am attempting to create a debian livecd with persistence using this tutorial ( unix.stackexchange.com/questions/382817/… ), however the tutorial uses parted and my system is freebsd, which only has gpart. – Andrew Dec 5 '19 at 13:41
2

Questions: So by representative does this mean that it is for human identification? what is a special file? What exactly is this for?

Most Unix-style operating systems expose disks and partitions as "device nodes" under the /dev directory. For example, SATA disk 2 partition 1 on Linux is /dev/sdb1, on FreeBSD /dev/ada0s1.

There are no dedicated "disk access" system calls – instead you always use these files whenever you have to read or write to the disk (e.g. when creating a filesystem or when mounting it).

Questions: Isn't the index also attached to the partition, as in each partition has an index and a label? How is this different? The next line gives a special case, but again there is no explanation or examples of what this is actually for.

The index is implicit. The partition table doesn't literally store each partition's number; a partition just has index 2 because it's the second entry in the table. With most tools, deleting partition 1 will automatically shift partition 2 to become the new 1.

The label is explicit. It is a short textual name stored in the partition table (if using a GPT disk – MBR/DOS disks don't support partition labels at all). The label is set by the user, and never changes until you change it.

The "device nodes" mentioned above are usually named according to the partition's index. However, some operating systems will create "device node" symlinks based on the label, e.g. on Linux you would automatically have /dev/disk/by-partlabel/Windows pointing to /dev/sda2. This allows referencing the same partition even if the disk suddenly gets detected as disk 2 or 3 instead of disk 1.

(Note that many filesystems also support storing a 'label' directly in the filesystem's metadata – that's also a textual name and has the same purpose as GPT labels, but is still a separate thing and outside the scope of gpart.

And just to add to the confusion, there's also a third meaning of 'label' – in some programs, the term 'disk label' it indicates the type of the partition table. For example, MBR partition table is sometimes called a "MBR disklabel" or "DOS disklabel".)

My guess is that a partition label gives the format of the particular partition.

No. It's just a textual name set by the user.

type no explanation given. It doesn't actually give an explanation for what it is in the add subsection nor in the PARTITION subsection. I am able to deduce from past experience formatting disks that type will define the format of my disk partition.

No. It is somewhat related to the filesystem format, but doesn't really define the format as much as it indicates partition's purpose, e.g. there is a single linux-data type for many Linux filesystem formats, and a single ms-basic-data type for Windows filesystem formats.

As another example, if a FAT32-formatted partition is used for regular data storage it could use the ms-basic-data type, but if it is used to hold UEFI bootloaders then it would use the efi type, yet it would contain the same FAT32 filesystem format in both cases.

In general, the partition type can be used by firmwares and operating systems to quickly search for partitions matching a specific purpose, without having to actually examine each partition's contents first.

2
  • "With most tools, deleting partition 1 will automatically shift partition 2 to become the new 1" - parted and GParted didn't do this the last time I tried. Microsoft diskpart will happily shift partitions, possibly preventing Windows from booting if its partition changes its index. – gronostaj Dec 9 '19 at 10:12
  • Well, I once did exactly that expecting everything to Just Work, and it didn't go well ;) – gronostaj Dec 9 '19 at 11:03
1

Do not know Unix, but it goes way back.

I suspect index may be cylinder, head, sector of start of partition if PC type drive, but may be even before that. But that has been replaced with LBA and now with new large drives 4KiB sectors. https://ata.wiki.kernel.org/index.php/ATA_4_KiB_sector_issues

Since with UEFI we now use gpt partitioning we have several labels. The disklabel, sometimes called label is whether drive is MBR(msdos) or gpt, or one of may other partitions (sun, aix, etc). We then have a partition format label and a gpt(GUID) partlabel. And name is format like vfat. While FAT16 was allowed FAT32 normally used and now recommended.

I do not create USB installers, but just use grub2's loopmount to directly boot ISO, then on larger drive I can have multiple ISO as a repair flash drive.

fred@bionic-z97:~$ lsblk -o FSTYPE,NAME,LABEL,PARTLABEL,SIZE,MOUNTPOINT
FSTYPE NAME    LABEL    PARTLABEL   SIZE MOUNTPOINT
sdd                                 3.8G 
└─sdd1  vfat   FOCAL    focal       3.8G /media/fred/FOCAL

Do not know about Debian, but you used to be able to just extract ISO and UEFI boot it as /EFI/Boot folder is what UEFI expects to boot from. With BIOS you have to also add a BIOS boot loader like syslinux.

2.04 Out of memory error loop mount

https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1851311

Links in FAT32 error:

https://bugs.launchpad.net/ubuntu/+source/ubuntu-meta/+bug/1849534

2
  • i've reached my time limit on solving this issue through gpart and bsd (4 hours). it seems to be one of the few options available to do something of this nature in FreeBSD. the man page is also lacking important information regarding how to set up boot flags. It assumes a professional level of knowledge just to use. I'm not there yet, and there is no information online. I am just going to run debian in a VM and say goodbye to FreeBSD for now, it's the 4th unsolvable issue i've encountered since beginning to use it. That makes me and the internet 0/4 on encountered problems in freebsd – Andrew Dec 5 '19 at 14:23
  • I'll read up on what you wrote as soon as I can. Right now I am severely time bound and need to solve this asap. – Andrew Dec 5 '19 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.