首先用blkid来查看一下硬盘的UUID
blkid
/dev/sda1: UUID="be32db7c-f4a1-4143-816d-351fec7681f4" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="a5874101-01"
/dev/sda2: UUID="4c73f462-4ae1-466a-9976-686b122bd72e" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="a5874101-02"
/dev/sda3: UUID="27b5b97e-4e28-4b59-9094-93eb8baafc17" TYPE="swap" PARTUUID="a5874101-03"
/dev/sda5: UUID="2f0446a8-2e2b-4a29-8c8e-a8f24f9a6943" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="a5874101-05"
/dev/sdb1: UUID="5cce7d74-6386-4e6a-b61c-352f224263c4" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="74f5b0c6-3cef-b547-98e0-6a091d737799"
我们要自动挂载sdb1
vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Dec 20 19:43:57 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=4c73f462-4ae1-466a-9976-686b122bd72e / xfs defaults 0 0
UUID=be32db7c-f4a1-4143-816d-351fec7681f4 /boot ext4 defaults 1 2
UUID=2f0446a8-2e2b-4a29-8c8e-a8f24f9a6943 /home xfs defaults 0 0
UUID=27b5b97e-4e28-4b59-9094-93eb8baafc17 swap swap defaults 0 0
输入i开始编辑 箭头可移动光标位置
在下一行添加以下代码即可 /smb是挂载目录(目录必须已经存在)
(谨慎使用自动挂载,一旦设置错误则无法正常开机)
UUID=5cce7d74-6386-4e6a-b61c-352f224263c4 /smb ext4 defaults 0 0
按一下esc 输入:wq (保存退出) 就OK了
评论区