Fix "The file system is read-only" error in Linux

Fix "The file system is read-only" error in Linux

Method 1: Set access rights

The first way to fix the error "The file system is read-only." in Linux it consists of checking the access rights. Sometimes a user accidentally or intentionally sets restrictions that apply to other users. We suggest that you check the attributes first and then make any necessary changes.

  1. Start the console using a method that is comfortable for you. To do this, you can use the corresponding icon in the application menu or the shortcut key Ctrl + Alt + T.
  2. Here, enter a command ls -lto see the complete list of discs with detailed information, among which will be the one we need.
  3. Examine the attributes displayed in the first column next to the problem disk or partition. If there is only one character -rmeans that the system is read-only. Availability w means open to read and write.
  4. If the problem is really related to the specified attributes, you will have to reconfigure the permissions. Enter the command sudo chown -R [user]:[user] /home/[user]substituting user to the name of the desired user, to which all changes will be applied.
  5. This action is performed with the option sudoso it will have to be confirmed by entering the superuser password in the new line.
It may interest you:  Installing Yandex.Browser on Linux

After activating the command, you will be notified that all changes have taken effect. It is recommended to restart the PC and start testing. If the command is used ls has all required attributes for partition or media, you should move on to other solutions for the problem encountered.

Method 2: Bug Fixes Using GParted

GParted is one of the most popular disk management utilities on Linux with a built-in graphical user interface. It has many ancillary functions related to resolving various media errors, among others.

  1. If GParted is not available by default on your distribution, install it using the command sudo apt-get install gparted. Confirm this action by entering the root password and approving the file download.
  2. Afterwards, the easiest thing is to start the utility by clicking on the corresponding icon in the applications menu.
  3. You will also need superuser privileges to open it.
  4. When you log in, it will be immediately clear which partition is the problem, as an exclamation point will light up next to it. Right click on this line.
  5. In the context menu, click "Error checking.".
  6. Start operations by clicking the check mark button on the top panel.
  7. Confirm to run the check.
  8. It only remains to wait for this process to complete.

If any bugs are found and corrected, you will be notified accordingly. After the check is complete, you must restart your PC so that when you start the next session you can check the effectiveness of the actions taken at once. If they don't give any results, move on.

It may interest you:  Open ports in CentOS 7

Method 3: Repair Bad Blocks

Sometimes a read error occurs due to bad sectors of the hard drive. There are special utilities that allow you to allocate the problem space or fix it, if possible. Linux has a built-in command to do this. We suggest its use in case the above recommendations are of no use.

  1. First, we are going to look at the list of disks to see which one needs to be checked. The way to do it is to run the program fdisk -l.
  2. In the list, locate the problem unit by identifying its exact name. You will need it later when you activate the appropriate command to heal the blocks.
  3. Now use the command hdparm -i /dev/sda2 | grep Modelto check the selected media or logical drive. Here replace / Dev / sda2 to the previously defined name.
  4. After that, you need to unmount the disk so that you can run a block check later. This is done with the line umount /dev/sda2.
  5. Run the test by inserting the command badblocks -s /dev/sda2 > /root/badblock.
  6. Detected locks that cannot be set must be checked for the system to stop activating them. To do this, use e2fsck -l /root/badblock /dev/sda2.

All changes will be applied immediately, but as usual it is recommended to create a new OS session to check if the error encountered problem has been resolved "The file system is read-only.".

Method 4: Format the drive

The last method we want to talk about in today's article is the most radical, since it involves a complete formatting of the drive, after which the state of the file system will be restored. This option will be suitable only in the situation where there are no important files on the disk and all the content can be deleted. For more detailed instructions on this topic, please see the separate article on our website using the link provided below.

It may interest you:  Terminal emulators for Linux

Further information: Format a disk in Linux

Today we break down four methods to fix the problem "The file system is read-only.". It remains to find a suitable one only by brute force, carrying out all the instructions given in order. In most cases, at least one of them is effective and allows the error under consideration to be completely eliminated.

We are glad that we were able to help you resolve the issue.

Describe what has not worked for you.
Our specialists will try to respond as quickly as possible.

Has this article helped you?