If you are looking for software to use, go to Huajun Software Park! software release

What should I do if I get the message "cannot create directory 'test'" when using Mkdir on Linux?

Author: GiuliaQ Date: 2017-05-23

If you encounter the problem of "cannot create directory 'test'" when using Mkdir in Linux, please use this solution provided by the editor to solve it. I believe this method will be helpful to you.

What should I do if I get the message "cannot create directory 'test'" when using Mkdir on Linux?

Symptom of the problem: According to feedback from the monitoring team, when creating a directory on a certain host opt, it is prompted as Read-only file system, and writing or deletion is not allowed. According to past experience, there are three possibilities for this problem:

1. The w permission was not granted when mounting;

2. There is a problem with the partition and fsck is required to repair it;

3. If the hard disk fails, you need to use the server's original tools to verify whether there is a problem with the hard disk and replace the hard disk to avoid data loss.

Note: Some people may also think of using chattr to set permissions to prevent writing and configure through disk quotas, but the error content of these two settings is different from this error.

Solution:

1. View the current parameters through mount:

# mount

/dev/sda2 on/type ext3 (rw, acl, user_xattr)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

debugfs on /sys/kernel/debug type debugfs (rw)

udev on /dev type tmpfs (rw)

devpts on /dev/pts type devpts (rw, mode=0620, gid=5)

/dev/sda5 on /boot type ext3 (rw, acl, user_xattr)

/dev/sda9 on /home type ext3 (rw, acl, user_xattr)

/dev/sda10 on /opt type ext3 (rw, acl, user_xattr)

/dev/sda8 on /tmp type ext3 (rw, acl, user_xattr)

/dev/sda6 on /usr type ext3 (rw, acl, user_xattr)

/dev/sda7 on /var type ext3 (rw, acl, user_xattr)

By checking, you can find that the current mounting permission is rw permission.

2. fsck repair

[root@361way.com ~]# umount /opt/

umount: /opt: device is busy

umount: /opt: device is busy

[root@361way.com ~]# fuser -m /dev/sda10

/dev/sda10: 11334

[root@361way.com ~]# ps auxww|grep 11334

apache 11334 0.0 0.3 14288 6404? S 09:47 0:00 /usr/sbin/httpd -k start -DSSL

root 12184 0.0 0.0 4128 684 pts/0 R+ 09:50 0:00 grep 11334

[root@361way.com ~]# service httpd stop

Stopping httpd: [OK]

[root@361way.com ~]# umount /opt/

[root@361way.com ~]# fsck -V -a /dev/sda10

fsck 1.39 (29-May-2006)

[/sbin/fsck.ext3 (1) -- /opt] fsck.ext3 -a /dev/sda10

/opt: recovery journal

/opt: clean, 1890281/20971520 files, 6941812/20970849 blocks

3. Hard drive detection

This can be determined based on the tools provided by OEM manufacturers for related systems. Commonly used tools include HP's hpacucli, DELL's delldset, ATAE's disk_info_test, etc.

  

Related articles