lost and found ( for me ? )

Showing posts with label blkid. Show all posts
Showing posts with label blkid. Show all posts

Fedora 16 : fstab , blkid

After upgrading a kernel from 3.3.4-3.fc16.x86_64 to 3.3.5-2.fc16.x86_64 , an external USB HDD device name has changed to sdf5 from sdb5 and I could not boot Fedora until correcting a device name in /etc/fstab.

When writing a mount point into fstab , it would be better to use UUID not /dev/xxx.

Check UUID

[root@fc16 ~]# blkid
/dev/sda1: LABEL="SYSTEM" UUID="9E2E45302E45032F" TYPE="ntfs"
/dev/sda2: LABEL="HP" UUID="8454D6EB54D6DECC" TYPE="ntfs"
/dev/sda3: UUID="61b367fb-2790-407f-a071-262e8b857fb9" UUID_SUB="5c11bceb-cd4f-4636-be2e-74d0dc199444" TYPE="btrfs"
/dev/sda5: UUID="890e0f93-2c19-479a-92a7-9c2cead5c40b" TYPE="swap"
/dev/sda6: UUID="1c61e7cc-a5ae-4d49-95ba-23361e3e64ea" TYPE="ext4"
/dev/sdb1: LABEL="M-cM-^CM-^\M-cM-^CM-*M-cM-^CM-%M-cM-^CM-<M-cM-^CM- " UUID="D680E4DE80E4C5D9" TYPE="ntfs"
/dev/sdb5: LABEL="fedora" UUID="278b0a16-ba14-429d-a9a2-d79cfa604e76" UUID_SUB="b74f31cc-d0c1-4199-8634-b6b24c416579" TYPE="btrfs"

write a mount point using UUID not /dev/xxx as below.
[root@fc16 ~]# egrep  -v ^# /etc/fstab

UUID=61b367fb-2790-407f-a071-262e8b857fb9 /                       btrfs   defaults        1 1
UUID=890e0f93-2c19-479a-92a7-9c2cead5c40b swap                    swap    defaults        0 0
UUID=278b0a16-ba14-429d-a9a2-d79cfa604e76 /var/USB_HDD/Fedora btrfs defaults 0 0

Linux : small tips : blkid command


blkid command is a tool to display a UUID of block devices.

[ usage examples ]

Here’s /etc/fstab of my Fedora 16 machine.
# egrep -v ^# /etc/fstab | egrep -v ^$
UUID=ba2b7a10-73a2-4986-bcc5-964966fea960 /                       btrfs   defaults        1 1
UUID=0f9153b2-3a0a-472c-8766-d0a37755cbef swap                    swap    defaults        0 0


convert UUID to device name
[root@fc16 ~]# blkid -U ba2b7a10-73a2-4986-bcc5-964966fea960
/dev/sda1
[root@fc16 ~]# blkid -U 0f9153b2-3a0a-472c-8766-d0a37755cbef
/dev/sda2


list UUID , file system type
[root@fc16 ~]# blkid
/dev/sda1: UUID="ba2b7a10-73a2-4986-bcc5-964966fea960" UUID_SUB="d9f471c2-b4f9-400b-a604-aa0cb354b2b6" TYPE="btrfs"
/dev/sda2: UUID="0f9153b2-3a0a-472c-8766-d0a37755cbef" TYPE="swap"
/dev/sda5: UUID="eaf9e7cd-a2b7-4cb0-b589-ca3fb7f8c735" TYPE="swap"
/dev/sda6: UUID="b3a1ec63-246c-4711-b0ba-b14584205b71" TYPE="ext4"
/dev/sda7: UUID="5b301504-1784-418d-9c4f-1a48fdb37b22" TYPE="swap"
/dev/sdb1: UUID="a8ad29b7-93d9-4fbd-8ae0-977d2dc3f2e8" TYPE="ext4"
/dev/sdb2: UUID="7895c59c-8615-45bd-bb8d-164afb63dc26" UUID_SUB="f1271eaa-5dd2-44ab-9817-f72910ad50b0" TYPE="btrfs"


see the detailed info of block device
[root@fc16 ~]# blkid -p /dev/sda1
/dev/sda1: UUID="ba2b7a10-73a2-4986-bcc5-964966fea960" UUID_SUB="d9f471c2-b4f9-400b-a604-aa0cb354b2b6" TYPE="btrfs" USAGE="filesystem" PART_ENTRY_SCHEME="dos" PART_ENTRY_TYPE="0x83" PART_ENTRY_FLAGS="0x80" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="286720000" PART_ENTRY_DISK="8:0"


edit /etc/fstab to mount /dev/sdb2 on a directory ( /var/Fedora16_USB_HDD ) when booting Fedora.

check UUID of /dev/sdb2
[root@fc16 ~]# blkid /dev/sdb2
/dev/sdb2: UUID="7895c59c-8615-45bd-bb8d-164afb63dc26" UUID_SUB="f1271eaa-5dd2-44ab-9817-f72910ad50b0" TYPE="btrfs"


edit /etc/fstab. add a red line.
[root@fc16 ~]# egrep -v ^# /etc/fstab

UUID=ba2b7a10-73a2-4986-bcc5-964966fea960 /                       btrfs   defaults        1 1
UUID=0f9153b2-3a0a-472c-8766-d0a37755cbef swap                    swap    defaults        0 0
UUID=7895c59c-8615-45bd-bb8d-164afb63dc26 /var/Fedora16_USB_HDD   btrfs   defaults 0 0


reboot Fedora16 to confirm /dev/sdb2 is mounted on /var/Fedora16_USB_HDD directory when booting.

after rebooting Fedora.
[root@fc16 ~]# egrep sdb /etc/mtab
/dev/sdb2 /var/Fedora16_USB_HDD btrfs rw,seclabel,relatime,nospace_cache 0 0