linux重启自动挂载磁盘/etc/fstab

背景

正常linux重启后,不论是断电重启还是直接重启,都会导致磁盘无法自动挂载,此时需要配置磁盘到/etc/fstab文件中来实现自动挂载磁盘

操作

建议使用uuid进行操作

$ blkid
/dev/vda1: UUID="95508740-f44d-4dd4-85a7-d78573982b2e" TYPE="ext4"
/dev/vdb: UUID="97daa5c1-c159-45e5-981d-73c595786000" TYPE="xfs"

$ echo UUID="95508740-f44d-4dd4-85a7-d78573982b2e" /mnt ext4 defaults 0 0 >> /etc/fstab

$ cat fstab

#
# /etc/fstab
# Created by anaconda on Fri Jan  3 11:26:18 2014
#
# 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
#
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/vda1 / ext4 errors=remount-ro,noatime 0 1
/swapfile none swap defaults 0 0
/dev/vdb /data ext4 defaults,noatime,nodiratime 0 0
/dev/vdb /data ext4 defaults,noatime,nodiratime 0 0
/dev/vdb /data ext4 defaults,noatime,nodiratime 0 0
UUID=95508740-f44d-4dd4-85a7-d78573982b2e /mnt ext4 defaults 0 0
UUID=97daa5c1-c159-45e5-981d-73c595786000 /mnt xfs defaults 0 0

参考文档

https://blog.csdn.net/xyajia/article/details/79165655

你可能感兴趣的:(运维)