mkdir: cannot create directory `test’: Read-only file system
问题现象:接监控组人员反馈,在某主机opt上当创建目录时,提示为只读Read-only file system,不允许写入或删除,根据以往经验这种问题有三种可能:
1、挂载时未给予w权限;
2、分区出现问题,需要fsck进行修复处理;
3、硬盘故障,需通过服务器原厂工具核实是否硬盘是否出现问题,更换硬盘以免丢失数据 。
注:有些人可能还会想到使用chattr 设置权限造成不能写和通过磁盘配额进行配置,不过这两种设置报错内容和这个报错不同。
解决思路:
1、通过mount查看当前参数:
1# mount
2/dev/sda2 on / type ext3 (rw,acl,user_xattr)
3proc on /proc type proc (rw)
4sysfs on /sys type sysfs (rw)
5debugfs on /sys/kernel/debug type debugfs (rw)
6udev on /dev type tmpfs (rw)
7devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
8/dev/sda5 on /boot type ext3 (rw,acl,user_xattr)
9/dev/sda9 on /home type ext3 (rw,acl,user_xattr)
10/dev/sda10 on /opt type ext3 (rw,acl,user_xattr)
11/dev/sda8 on /tmp type ext3 (rw,acl,user_xattr)
12/dev/sda6 on /usr type ext3 (rw,acl,user_xattr)
13/dev/sda7 on /var type ext3 (rw,acl,user_xattr)
通过查看可以发现,当前挂载的权限是rw权限。
2、fsck修复
1[[email protected] ~]# umount /opt/
2umount: /opt: device is busy
3umount: /opt: device is busy
4[[email protected] ~]# fuser -m /dev/sda10
5/dev/sda10: 11334
6[[email protected] ~]# ps auxww|grep 11334
7apache 11334 0.0 0.3 14288 6404 ? S 09:47 0:00 /usr/sbin/httpd -k start -DSSL
8root 12184 0.0 0.0 4128 684 pts/0 R+ 09:50 0:00 grep 11334
9[[email protected] ~]# service httpd stop
10Stopping httpd: [ OK ]
11[[email protected] ~]# umount /opt/
12[[email protected] ~]# fsck -V -a /dev/sda10
13fsck 1.39 (29-May-2006)
14[/sbin/fsck.ext3 (1) -- /opt] fsck.ext3 -a /dev/sda10
15/opt: recovering journal
16/opt: clean, 1890281/20971520 files, 6941812/20970849 blocks
3、硬盘检测
这个可以根据OEM厂商提供的针对相关系统的工具而定,常用的如HP的hpacucli 、DELL的delldset、ATAE的disk_info_test等。
捐赠本站(Donate)
如您感觉文章有用,可扫码捐赠本站!(If the article useful, you can scan the QR code to donate))
- Author: shisekong
- Link: https://blog.361way.com/cannot-create-directory/4302.html
- License: This work is under a 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. Kindly fulfill the requirements of the aforementioned License when adapting or creating a derivative of this work.