From 太極
Jump to navigation Jump to search
  • man fstab
  • https://help.ubuntu.com/community/Fstab
    • Format: [Device] [Mount Point] [File System Type] [Options] [Dump] [Pass]
    • <dump> Enable or disable backing up of the device/partition (the command dump). This field is usually set to 0, which disables it.
    • <pass> Controls the order in which fsck checks the device/partition for errors at boot time. The root device should be 1. Other partitions should be 2, or 0 to disable checking.
    • man mount
  • What Are UUIDs and Why Are They Useful
  • https://wiki.archlinux.org/title/Fstab
    • Noatime: – Do not update the file access times on the file system. This can help performance on old hardware.
    • Relatime: Update file access times relative to the file modified time.
    • nofail: Devices that are listed and not present will result in an error unless the nofail option is used.
  • External storage configuration from raspberrypi.org.
    UUID=5C24-1453 /mnt/mydisk fstype defaults,auto,users,rw,nofail 0 0
    UUID=5C24-1453 /mnt/mydisk ext4   defaults,noatime,nofail 0 2
$ sudo blkid  #  list devices even not mounted yet

and the result should be compared with

$ sudo fdisk -l
  • Run sudo mount -a to remount /etc/fstab without reboot, except the partitions with noauto option.

The following example shows a problem (as found from the output of df command) with </etc/fstab> where we use /dev/sdXY instead of UUID for specifying hard disks.

$ sudo blkid
/dev/sda1: LABEL="WD640" UUID="d3a0a512-bf96-4199-9674-f410f22f0a92" TYPE="ext4"
/dev/sdb1: UUID="afaa4bde-1172-4c54-8b0a-a324ad855355" TYPE="ext4"
/dev/sdb5: UUID="fb2a4ada-d80a-4e23-b4a2-67376b8b7e72" TYPE="swap"

$ sudo fdisk -l
Disk /dev/sda: 640.1 GB, 640135028736 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048  1250263039   625130496   83  Linux

Disk /dev/sdb: 640.1 GB, 640135028736 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048  1217761279   608879616   83  Linux
/dev/sdb2      1217763326  1250263039    16249857    5  Extended
/dev/sdb5      1217763328  1250263039    16249856   82  Linux swap / Solaris

$ cat /etc/fstab
proc            /proc                                 proc    nodev,noexec,nosuid 0 0
UUID=afaa4bde-1172-4c54-8b0a-a324ad855355 /           ext4    errors=remount-ro   0 1
UUID=fb2a4ada-d80a-4e23-b4a2-67376b8b7e72 none        swap    sw                  0 0
/dev/sdb1       /mnt/WD640                            ext4    rw,nosuid,nodev     0 2
UUID=fb2a4ada-d80a-4e23-b4a2-67376b8b7e70 /mnt/extUSB auto nosuid,nodev,nofail 0 2
UUID=2ab36808-038a-4dfa-ad52-c10944cf61f2 /mnt/hdd  ext4  defaults  0  2

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1       572G  413G  130G  77% /
/dev/sdb1       572G  413G  130G  77% /mnt/WD640

To fix the error here, modify the line starting /dev/sdb1 in /etc/fstab and replace it with the UUID. Then run sudo umount /mnt/WD640 and sudo mount -a. Done!