今天碰到的一个小问题,涉及centos7下的光驱挂载,记录如下:
1. 起因:久未使用的一个CENTOS7虚机,今天计划起来做个实验,启动过程中自动进入RESCUE模式,
输入root密码进入修复模式,查看/var/log/boot.log发现如下内容:
[FAILED] Failed to mount /media/cdrom.
See 'systemctl status media-cdrom.mount' for details.
[DEPEND] Dependency failed for Local File Systems.
[DEPEND] Dependency failed for Mark the need to relabel after reboot.
[DEPEND] Dependency failed for Relabel all filesystems, if necessary.
[DEPEND] Dependency failed for Migrate local... structure to the new structure.
Starting Preprocess NFS configuration...
提示和光驱挂载有关,检查/etc/fstab文件内容,光驱这行内容如下,
/dev/sr0 /mnt iso9660 defaults 0 0
检查virtualbox设置,显示光驱没有盘片(没有挂载iso),很奇怪,一直这样写,需要挂载光驱修改virtualbox设置挂载上光驱,即可在系统里面使用。
进一步排错,
1)修改VM设置,插入光盘,再次启动,系统启动正常,OK。
2)不插入光盘,修改/etc/fstab文件,注释掉光驱这行,再次启动,系统启动正常,OK。
确定问题就在这行,总共6列,1设备名,2挂载点显然不应该有问题,3文件类型,4选项,以及后面的DUMP和FSCK,显然只能在这4个选项上面了,进一步排查,
#man fstab
发现如下内容,
The fourth field (fs_mntops).
This field describes the mount options associated with the filesystem.
It is formatted as a comma separated list of options. It contains at least the type of mount plus any
additional options appropriate to the filesystem type. For documentation on the available mount options,
see mount(8). For documentation on the available swap options, see swapon(8).
Basic file system independent options are:
defaults
use default options: rw, suid, dev, exec, auto, nouser, and async.
noauto do not mount when "mount -a" is given (e.g., at boot time)
进一步排除3,5,6,重点怀疑4,进一步排查,
#man mount
auto Can be mounted with the -a option.
noauto Can only be mounted explicitly (i.e., the -a option will not cause the filesystem to be mounted).
defaults
Use default options: rw, suid, dev, exec, auto, nouser, and async.
Note that the real set of the all default mount options depends on kernel and filesystem type. See the
begin of this section for more details.
看着有点感觉了,删除defaults, 改为noauto,不插入光盘,重启正常,OK。
问题解决,但是这个问题出的有点蹊跷,之前一直在rhel6,centos6上面为什么从来没有碰到过这个情况?
随手找了一台RHEL6虚机,重复上面的实验,确实不同(暂时手头没有centos6机器),centos7上似乎启动的时候与rhel6默认行为不同,进一步排查,
#man fstab 5
没有什么特别信息
#man mount
defaults
Use default options: rw, suid, dev, exec, auto, nouser, async, and relatime.
Note that the real set of the all default mount options depends on kernel and filesystem type.
See the begin of this section for more details.
auto Can be mounted with the -a option.
noauto Can only be mounted explicitly (i.e., the -a option will not cause the filesystem to be
mounted).
除了man page内容排版上略有区别外,似乎没有其它什么差别了,那么只能初步定位这个是CENTOS7采用SYSTEMD技术和原来的SYSVINIT技术在初始化文件系统时候的一个区别了,SYSTEMD方式下为了加快启动速度,采用了并行启动,而SYSVINIT下面是顺序方式,于是系统优化时,对可以忽略的硬件乃至文件系统的初始化都忽略掉了,但是这个只是个人的猜测,目前还无法从更多文档上面得到证实。