1. 建立錯誤環境node
1.1 操做系統說明ide
操做系統:CentOS 5.8oop
硬盤分區狀況:this
- [root@hooper ~]# fdisk /dev/sda
- The number of cylinders for this disk is set to 1305.
- There is nothing wrong with that, but this is larger than 1024,
- and could in certain setups cause problems with:
- 1) software that runs at boot time (e.g., old versions of LILO)
- 2) booting and partitioning software from other OSs
- (e.g., DOS FDISK, OS/2 FDISK)
- Command (m for help): p #顯示分區表
- Disk /dev/sda: 10.7 GB, 10737418240 bytes
- 255 heads, 63 sectors/track, 1305 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Device Boot Start End Blocks Id System
- /dev/sda1 * 1 19 152586 83 Linux
- /dev/sda2 20 52 265072+ 82 Linux swap / Solaris
- /dev/sda3 53 1305 10064722+ 83 Linux
- Command (m for help): v
- 6757 unallocated sectors
fstab文件:spa
- [root@hooper ~]# cat /etc/fstab
- LABEL=/ / ext3 defaults 1 1
- LABEL=/boot /boot ext3 defaults 1 2
- 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
- LABEL=SWAP-sda2 swap swap defaults 0 0
1.2 建立一個錯誤的分區操作系統
添加新硬盤,建立新的分區,並配置fstab文件
添加一塊新的硬盤,並建立分區:在/dev/sdb上建立新的主分區sdb1orm
- [root@hooper ~]# fdisk /dev/sdb
- Command (m for help): p
- Disk /dev/sdb: 536 MB, 536870912 bytes
- 64 heads, 32 sectors/track, 512 cylinders
- Units = cylinders of 2048 * 512 = 1048576 bytes
- Device Boot Start End Blocks Id System
- Command (m for help): n #建立分區
- Command action
- e extended
- p primary partition (1-4)
- p
- Partition number (1-4): 1
- First cylinder (1-512, default 1):
- Using default value 1
- Last cylinder or +size or +sizeM or +sizeK (1-512, default 512):
- Using default value 512
- Command (m for help): p
- Disk /dev/sdb: 536 MB, 536870912 bytes
- 64 heads, 32 sectors/track, 512 cylinders
- Units = cylinders of 2048 * 512 = 1048576 bytes
- Device Boot Start End Blocks Id System
- /dev/sdb1 1 512 524272 83 Linux
- Command (m for help): w
- The partition table has been altered!
- Calling ioctl() to re-read partition table.
- Syncing disks.
建立文件系統xml
- [root@hooper ~]# mke2fs -j -L other /dev/sdb1
- mke2fs 1.39 (29-May-2006)
- Filesystem label=other
- OS type: Linux
- Block size=1024 (log=0)
- Fragment size=1024 (log=0)
- 131072 inodes, 524272 blocks
- 26213 blocks (5.00%) reserved for the super user
- First data block=1
- Maximum filesystem blocks=67633152
- 64 block groups
- 8192 blocks per group, 8192 fragments per group
- 2048 inodes per group
- Superblock backups stored on blocks:
- 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
- Writing inode tables: done
- Creating journal (8192 blocks): done
- Writing superblocks and filesystem accounting information: done
- This filesystem will be automatically checked every 23 mounts or
- 180 days, whichever comes first. Use tune2fs -c or -i to override.
將sdb1掛載到others目錄上blog
- [root@hooper ~]# mkdir /others
- [root@hooper ~]# mount /dev/sdb1 /others
- [root@hooper ~]# mount
- /dev/sda3 on / type ext3 (rw)
- proc on /proc type proc (rw)
- sysfs on /sys type sysfs (rw)
- devpts on /dev/pts type devpts (rw,gid=5,mode=620)
- /dev/sda1 on /boot type ext3 (rw)
- tmpfs on /dev/shm type tmpfs (rw)
- none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
- sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
- nfsd on /proc/fs/nfsd type nfsd (rw)
- /dev/sdb1 on /others type ext3 (rw)
- [root@hooper ~]# cd /others
- [root@hooper others]# ll
- total 12
- drwx------ 2 root root 12288 Dec 7 15:38 lost+found
修改fstab文件ip
- [root@hooper others]# vi /etc/fstab
- LABEL=/ / ext3 defaults 1 1
- LABEL=/boot /boot ext3 defaults 1 2
- 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
- LABEL=SWAP-sda2 swap swap defaults 0 0
- LABEL=/other /others ext3 defaults 1 2
這裏用到的是LABE而不是設備名(/dev/sdb1),可是這個把卷標寫錯,應該是other,前面沒有 /,而且沒有運行mount -a 命令來驗證配置是否正確
重啓系統
- [root@hooper others]# init 6
2. 修復fstab文件
重啓後遇到問題,以下圖:
系統發現fstab中的LABEL=/other卷標不存在
2.1 故障解決過程
2.1.1 進入運行級別1
試圖修改/etc/fstab文件,發現此文件爲只讀
從新掛載(mount),並修改文件
再次修改/etc/fstab文件,並保存
修復完成,重啓系統
系統能夠正常啓動,問題解決
3. 問題總結
以上問題的出現時因爲錯誤配置了/etc/fstab文件,在系統重啓時,沒法識別卷標(/ohter),從而致使沒法正常啓動。若是在修改/etc/fstab文件後,運行mount -a 命令驗證一下配置是否正確,則可避免此類問題,另外一般不要修改/etc/fstab配置文件