0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Linuxで追加ディスクの設定をちょっとおしゃれに

Posted at

クラウド時代となりfstabにUUIDで記載することが増えましたね。
そんなマウントポイントの記載方法をちょっとおしゃれにしました。

※追加ディスクをアタッチした状態から。

ディスク確認

fdisk -l

パーティショニング(/dev/sdbとかデバイス名は適宜環境に合わせて)

fdisk /dev/sdb
※p,nで新規作成、wで保存してexit。パーティションを分ける必要がなければ設定はすべてEnterでよい。

ディスク確認

fdisk -l

マウント先ディレクトリ作成

mkdir -p /data

xfsでフォーマット

mkfs -t xfs /dev/sdb1

UUIDとフォーマットを変数にセット

set - $(blkid /dev/sdb1|sed -e "s/\"//g")

fstabで追記(printfでデフォルトのfstabとスペース数を合わせてます)

※nofailにしておくと起動時にボリュームがなくても起動失敗しません。
echo "$2 $(printf "%-24s\n" /data)${3##*=}     nofail          0 0">>/etc/fstab
 
↓こんな感じで入ります。
UUID=3b3c05fc-22a0-46e2-8d6e-bee839fb21c2 /data             xfs     nofail
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?