1. 创建错误环境
1.1 操作系统说明
操作系统:CentOS 5.8
硬盘分区情况:
- [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文件:
- [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上创建新的主分区sdb1
- [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.
创建文件系统
- [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目录上
- [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文件
- [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
输入 root 密码,进入运行级别 1试图修改/etc/fstab文件,发现此文件为只读
重新挂载(mount),并修改文件
再次修改/etc/fstab文件,并保存
修复完成,重启系统
系统可以正常启动,问题解决
3. 问题总结
以上问题的出现时由于错误配置了/etc/fstab文件,在系统重启时,无法识别卷标(/ohter),从而导致无法正常启动。如果在修改/etc/fstab文件后,运行mount -a 命令验证一下配置是否正确,则可避免此类问题,另一般不要修改/etc/fstab配置文件