有关UUID

前阵子我的系统闹鬼了:明明使用genfstab指定了挂载sdb1到/boot,每次系统挂上去的却是sda2.

genfstab -U / > /etc/fstab

-U 参数代表使用UUID索引设备。 一下内容来自arch wiki:

UUID is a mechanism to give each filesystem a unique identifier. These identifiers are generated by filesystem utilities (e.g. mkfs.*) when the device gets formatted and are designed so that collisions are unlikely. All GNU/Linux filesystems (including swap and LUKS headers of raw encrypted devices) support UUID. FAT, exFAT and NTFS filesystems do not support UUID, but are still listed in /dev/disk/by-uuid/ with a shorter UID (unique identifier):

我列出UUID仔细一看,发现sda2和sdb1两个分区的UUID竟然撞车了,于是乎每次系统启动都是玄学挂载,有时挂这个有时挂那个。。

这两个分区都是做boot的vfat分区,分别位于两块不同的固态硬盘上。

按照wiki的介绍,所有GNU/Linux 文件系统都支持UUID,而 FAT, exFAT 和 NTFS不支持UUID,但这些分区仍然会在 /dev/disk/by-uuid/中列出,使用较短的UID作为标识。(然而奇怪的是,这两个FAT分区并未在我这里列出,但使用blkid命令的确能看到它们的UUID使用了较短的串,而且是重复的).

我的genfstab命令返回如下:

$ genfstab -U /

# /dev/sdb1
UUID=781C-BFE5      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro	0 2

# /dev/sdb2
UUID=31ba13b3-2bc2-47c9-821c-1b54ba1c24d5	none      	swap      	defaults  	0 0

# /dev/sdb3
UUID=e2e8af00-6958-4f98-8273-2b5364dcb41b	/         	ext4      	rw,relatime	0 1

可以看到BOOT分区的挂载的确使用了这个较短的UID。

对于UUID撞车的问题,可以简单地使用设备的PARTUUID代替UUID,在fstab中中只需要写成:

# /dev/sdb1
PARTUUID=XXX-XXX-XXX /boot vfat	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro	0 2

其中 PART-UUID可以使用blkid查看。

BUT WHY?

为什么两个FAT分区会有相同的UUID? 在blkid中这个短UID其实是FAT分区对应的32位序列号(Volume serial number). 一般来说FAT的序列号由分区格式化当时的系统时钟确定. NTFS的序列号更长一些(这儿就不讨论了)

但是为什么他们两个的序列号重复了,我也没想明白。。。按理说FAT分区是不能改UUID的。

这是一个悬而未决的问题,我能肯定的是这两个分区的创建时隔超过了半年,也许是因为我在格式化的时候都没有实现校准系统时钟,有恰好在同一个毫秒上按下了格式化。。。(really??)

edited 13.01.2023
created 12.07.2019
EOF
[+] click to leave a comment [+]
the comment system on this blog works via email. The button
below will generate a mailto: link based on this page's url 
and invoke your email client - please edit the comment there!

[optional] even better, encrypt the email with my public key

- don't modify the subject field
- specify a nickname, otherwise your comment will be shown as   
  anonymous
- your email address will not be disclosed
- you agree that the comment is to be made public.
- to take down a comment, send the request via email.

>> SEND COMMENT <<




mixtape via serocell - media feed April 16, 2024

2024-04-08 via mrshll.com April 8, 2024
The last time I experienced a major solar eclipse Alej, Q and I traveled down to Nashville to experience totality. It really was something. I remember first darkness, then cicadas and bats coming to life, then humans all around us hollering and applaudin…

[log] Painting Practice via Longest Voyage February 10, 2024
Trying to keep on the reading, writing, and painting focus for the year. I have a hard time right now doing extra hobbies during the week. I have been mentally drained from work to do much of anything afterwards. But I’ve gotten a tiny bit of painting don…

Generated by openring from webring