Bug 234535 - The label that was set on partition in single mode disappears on mutli-user mode.
Summary: The label that was set on partition in single mode disappears on mutli-user m...
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 12.0-RELEASE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2019-01-01 02:51 UTC by yuchensdgt
Modified: 2019-01-05 17:08 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yuchensdgt 2019-01-01 02:51:23 UTC
I used FreeBSD 12.0-RELEASE, I set label for partition refer to "Example 18.1. Labeling Partitions on the Boot Disk" in chapter 18.7. Labeling Disk Devices.
In single mode, it work okay, I can see labels in /dev/label, but booted in multi-user mode, the directory /dev/label disappeared, I try "glabel status", it did not show any labels that I have set in single mode.
Comment 1 Andrey V. Elsukov freebsd_committer 2019-01-01 09:57:24 UTC
When partition, that has label mounted/opened for writing/etc and this is done using another name (not a label), the label's geom object becomes spoiled.
Read about SPOILING in the geom(4) manual page.
Comment 2 yuchensdgt 2019-01-02 01:43:43 UTC
What is the correct operations or step for setting a persistent label on partition?
Comment 3 Benjamin Kaduk freebsd_committer 2019-01-04 21:39:36 UTC
(In reply to yuchensdgt from comment #2)

I am a bit confused today, but is `gpart add -l <label> ...` what you are looking for?
Comment 4 yuchensdgt 2019-01-05 05:26:04 UTC
I just want create a label that can be used in /etc/fstab, if I add a new hard disk, the device number maybe be changed, for example, from ada7s11 to ada8s11; if I use /dev/ada7s11 in /etc/fstab, freebsd system will be suspended, failed to statrt.
Comment 5 Conrad Meyer freebsd_committer 2019-01-05 05:39:37 UTC
Can you tell what is accessing the disk via the non /dev/label interface?  Some geoms can hardcode the label name to avoid tasting the other name.

Either way, I think our current interface of randomly killing device names that lost the first-open race is definitely *a* bug.  I don't know if we're tracking it in some other PR or not.
Comment 6 yuchensdgt 2019-01-05 08:04:37 UTC
(In reply to Conrad Meyer from comment #5)
my /etc/fstab is below:

# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/ada7p12    /               ufs     rw      1       1
/dev/ada7p13    none            swap    sw      0       0
/dev/ada7p14    /var            ufs     rw      2       2
/dev/ada7p15    /tmp            ufs     rw      2       2
/dev/ada7p16    /usr            ufs     rw      2       2
Comment 7 Conrad Meyer freebsd_committer 2019-01-05 17:08:03 UTC
(In reply to yuchensdgt from comment #6)
Oh, yeah.  That would be why the filesystem mounts (in multiuser) are obtaining non-label names and spoiling the label names.

Note that later in the same example, 18.1, it presents the following fstab:

# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/label/swap         none            swap    sw              0       0
/dev/label/rootfs       /               ufs     rw              1       1
/dev/label/tmp          /tmp            ufs     rw              2       2
/dev/label/usr          /usr            ufs     rw              2       2
/dev/label/var          /var            ufs     rw              2       2

I recommend using the label name in fstab, as that example shows.  Then the /dev/ada names will disappear, which still sucks, but at least the labels will persist.

In my personal configuration I use GPT labels rather than GEOM labels, but a similar idea.

# device mount fstype options dump pass
/dev/gpt/freebsd-root / ufs rw,noatime 1 1
/dev/gpt/freebsd-swap none swap sw 0 0

That should resolve the immediate issue, although I would still like to see the "spoiling" of alternative labels get fixed.