コンテンツにスキップ

ディスクをシステム起動時に自動的にマウントさせる

デバイスファイルの UUID を調べる。

1
2
$ sudo blkid
/dev/sda1: UUID="xxxx-xxxx" BLOCK_SIZE="512" TYPE="exfat" PARTLABEL="Basic data partition" PARTUUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

マウント先ディレクトリを用意する。

1
$ sudo mkdir -p /mnt/usb
/etc/fstab
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/nvme0n1p2 during curtin installation
/dev/disk/by-uuid/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx / ext4 defaults 0 1
# /boot/efi was on /dev/nvme0n1p1 during curtin installation
/dev/disk/by-uuid/xxxx-xxxx /boot/efi vfat defaults 0 1
/swap.img       none    swap    sw      0       0
UUID=xxxx-xxxx  /mnt/usb        exfat   auto,rw,uid=1000,gid=1000       0       0

設定項目は左から順に以下のようになっている。

項目 説明
device UUID か/dev/sda1のようなデバイスファイル(UUID の方が宛先が勝手に変わったりしないのでおすすめ)
dir マウント先ディレクトリ
type ファイルシステム(exfatvfatext4など)
options マウントオプション
dump 1 だとシステムがなんかチェックするらしい
fsck 1 だとシステムがなんかチェックするらしい

fstab - ArchWikiに詳しい説明がある。