Tag Archives: how to check file system options

How to remount filesystem in the read-write mode under Linux

Learn how to remount the file system in the read-write mode under Linux. The article also explains how to check if the file system is read-only and how to clean the file system

Re-mount filesystem as read-write

Most of the time on newly created file systems of NFS filesystems we see an error like below :

root@kerneltalks # touch file1
touch: cannot touch ‘file1’: Read-only file system

This is because the file system is mounted as read-only. In such a scenario you have to mount it in read-write mode. Before that, we will see how to check if the file system is mounted in read-only mode and then we will get to how to remount 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 –

# 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 the mounted file system. Here ro denotes file system is mounted read-only.

You can also get these details using mount -v command

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 –

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, the 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.

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 that need to be made on a file system that needs a reboot to make sure there are no processes are accessing the file system.