Learn how to re mount file system in read write mode under Linux. Article also explains how to check if file system is read only and how to clean file system

Most of the time on newly created file systems of NFS filesystems we see error like below :
1 2 3 4 | root@kerneltalks # touch file1 touch: cannot touch ‘file1’: Read-only file system |
This is because file system is mounted as read only. In such scenario you have to mount it in read-write mode. Before that we will see how to check if file system is mounted in read only mode and then we will get to how to re mount it as a read write filesystem.
How to check if file system is read only
To confirm file system is mounted in read only mode use below command –
1 2 3 4 | # cat /proc/mounts | grep datastore /dev/xvdf /datastore ext3 ro,seclabel,relatime,data=ordered 0 0 |
Grep your mount point in cat /proc/mounts
and observer third column which shows all options which are used in mounted file system. Here ro
denotes file system is mounted read-only.
You can also get these details using mount -v
command
1 2 3 4 | root@kerneltalks # mount -v |grep datastore /dev/xvdf on /datastore type ext3 (ro,relatime,seclabel,data=ordered) |
In this output. file system options are listed in braces at last column.
Re-mount file system in read-write mode
To remount file system in read-write mode use below command –
1 2 3 4 5 6 | root@kerneltalks # mount -o remount,rw /datastore root@kerneltalks # mount -v |grep datastore /dev/xvdf on /datastore type ext3 (rw,relatime,seclabel,data=ordered) |
Observe after re-mounting option ro
changed to rw
. Now, file system is mounted as read write and now you can write files in it.
Note : It is recommended to
fsck
file system before re mounting it.
You can check file system by running fsck
on its volume.
1 2 3 4 5 6 7 8 9 10 | root@kerneltalks # df -h /datastore Filesystem Size Used Avail Use% Mounted on /dev/xvda2 10G 881M 9.2G 9% / root@kerneltalks # fsck /dev/xvdf fsck from util-linux 2.23.2 e2fsck 1.42.9 (28-Dec-2013) /dev/xvdf: clean, 12/655360 files, 79696/2621440 blocks |
Sometimes there are some corrections needs to be made on file system which needs reboot to make sure there are no processes are accessing file system.
Share Your Comments & Feedback: