天天看點

centos7下的光驅挂載



今天碰到的一個小問題,涉及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設定,插入CD光牒,再次啟動,系統啟動正常,OK。

2)不插入CD光牒,修改/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,不插入CD光牒,重新開機正常,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下面是順序方式,于是系統優化時,對可以忽略的硬體乃至檔案系統的初始化都忽略掉了,但是這個隻是個人的猜測,目前還無法從更多文檔上面得到證明。

繼續閱讀