阅读量:359
在Linux系统中,/etc/fstab文件是一个关键配置文件,它包含了静态文件系统信息,定义了存储设备和分区如何整合到整个系统中。通过将文件系统挂载点、对应的挂载卷(或硬盘)以及挂载附加信息写入/etc/fstab,可以实现卷(或硬盘)的开机自动挂载。以下是一个示例:
/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).
#
# \u003cfile system\u003e \u003cmount point\u003e \u003ctype\u003e \u003coptions\u003e \u003cdump\u003e \u003cpass\u003e
#
# / was on /dev/sda1 during installation
UUID=23890ab8-1234-5678-9abc-def012345678 / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda2 during installation
UUID=12345678-abcd-ef01-2345-6789abcdef01 /boot ext4 defaults 0 2
# /home was on /dev/sda5 during installation
UUID=56789abc-def0-1234-5678-9abcdef01234 /home ext4 defaults 0 2
# /var was on /dev/sda6 during installation
UUID=6789abcdef01-2345-6789-abcdef012345 /var ext4 defaults 0 2
在某些情况下,可能需要取消/etc/fstab文件的自动加载,例如:
- 云服务器制作自定义镜像时。
- 云服务器文件系统挂载点和对应挂载卷(或硬盘)的对应关系发生变化时。
取消自动加载的操作步骤如下:
1. 打开/etc/fstab文件。
shell
sudo vim /etc/fstab
安装vim编辑器的命令是:
shell
sudo yum install vim
2. 进入编辑模式,并删除对应的自动挂载项。
shell
i
3. 按“Esc”退出编辑模式,保存并关闭文件。
shell
wq
通过这些步骤,就可以从/etc/fstab文件中取消特定的自动挂载项,从而避免在不需要的时候自动挂载特定的卷(或硬盘)。