Read only file system debian как исправить

Ошибка read only file system может возникнуть при загрузке с LiveCD диска или в режиме восстановления вашего дистрибутива. Она означает, что файловая система в которую вы пытаетесь вести запись примонтирована только для чтения. Этому может быть несколько причин. Есть файловые системы, которые доступны только для чтения это файловая система оптических дисков — ISO, а также файловая система образов SquashFS.

С такими файловыми системами вы сделать ничего не сможете. Для изменения данных в них, надо распаковать образ, изменить данные и запаковать его обратно. Но что касается обычных файловых систем, таких как EXT4, BTRFS, XFS, то их можно монтировать и для чтения и для записи.

В этой небольшой статье мы рассмотрим как исправить read only file system Linux перемонтировав файловую систему для записи. Первым делом надо определиться с точкой монтирования, для которой надо разрешить запись. Попытаемся создать файл в корневом каталоге:

touch /file

Ошибка, файловая система корневого каталога доступна только для чтения. Чтобы посмотреть все точки монтирования доступные в системе выполните в терминале:

mount | grep /dev/sd

В данном случае, корневая файловая система и есть точкой монтирования. Но у вас, например, возникнут проблемы с созданием файла в домашней папке, то надо будет уже перемонтировать /home. Смотрите внимательно. Когда точка монтирования выбрана, осталось её примонтировать с правами на запись:

sudo mount -o remount,rw /

Или для /home:

sudo mount -o remount,rw /home

После этого вы сможете создать файл без каких-либо проблем. После завершения работы, во избежание повреждения данных при перезагрузке, желательно перемонтировать файловую систему обратно в режим только для чтения:

sudo mount -o remount,ro /

Теперь вы знаете что означает эта ошибка и как с ею справится. Если у вас остались вопросы, спрашивайте в комментариях!

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Creative Commons License

Статья распространяется под лицензией Creative Commons ShareAlike 4.0 при копировании материала ссылка на источник обязательна .

Об авторе

Основатель и администратор сайта losst.ru, увлекаюсь открытым программным обеспечением и операционной системой Linux. В качестве основной ОС сейчас использую Ubuntu. Кроме Linux, интересуюсь всем, что связано с информационными технологиями и современной наукой.

В некоторый случаях файловая система в Linux может перейти в состояние read-only, при котором вы можете только читать данные с диска, а при попытке записи любых изменение или создании нового файла появдляется ошибка Read-only file system.

Ошибки файловой системы и опция remount-ro

Проверьте параметры монтирования дисков при загрузке Linux. Настройки монтирования файловых систем при загрузке задаются в файле /etc/fstab.

$ cat /etc/fstab

опции понтирования файловой системы в linux fstab при наличии ошибок

Обратите что в fstab есть строка монтирования корневой директории вида:

UUID=aaaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaa / ext4 errors=remount-ro 0 1

Параметр
errors=remount-ro
означает, что данная директория будет смонтирована в режиме чтения, если на файловой системе устройства обнаружены проблемы. В этом случае нужно выполнить проверку диска с помощью FSCK.

Обычные файловые системы такие как EXT4/BTRFS/XFS можно монтировать как в режиме записи, так и только для чтения (в отличии от файловых систем ISO или SquashFS, которые доступны только для чтения).

В случае обнаружения ошибок на диске вы можете использовать одну из трех опций
errors=[continue|remount-ro|panic]

  • continue – игнорировать ошибки,
  • remount-ro – перемонтировать диск в режиме только для чтения
  • panic – остановить загрузку системы

Вы можете вывести соответствие между UUID диска и именем устройства:

$ sudo blkid

В данном примере вы получили, что вашему UUID соответствует устройство /dev/sda3.

blkid вывести uuid и /dev/sdx имя

Также можно имена устройства и точки монтирования с помощью команды:

$ df –h

точки монтирования и файловые системы в linux

Т.к. в данном примере ошибки обнаружены в корневой директории которая является точкой монтирования, вы сможете выполнить ее проверку только загрузившись с LiveCD. Для исправления ошибок файловой системы используется команда:

$ sudo fsck –y /dev/sda3

Или

$ sudo fsck –y UUID=aaaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaa

Если вы не можете прямо сейчас выполнить проверку диска, и вы хотите немедленно вывести файловую систему из режима read-only, нужно выполниться команду:

$ sudo mount -o remount,rw /

Обязательно запланируйте проверку файловой системы на ближайшее время.

Read-only файловая система в виртуальных машинах

Файловая система раздела Linux на виртуальной машине можете перейти в read-only в случае недоступность системы хранения данных (СХД). Самый простой способ восстановить работу ОС – выполнить сброс виртуальной машины (фактически перезапуск с параметрами по умолчанию).

Может оказаться, что ВМ с Linux вообще не загружается и вам доступна только командная строка initramfs с предупреждениями:

UNEXPECTED INCONSISTENCY: RUN fsck MANUALLY.
Fsck exitrd with code 4.
 The root file system of /dev/sdx requires a manual fsck.

ошибка проверки файловой системы fsck в initramfs

Initramfs это начальная файловая система в оперативной памяти, которая основана на tmpfs, которая содержит утилиты и скрипты, необходимые для работы с дисками, файловыми системами и тд. После запуска initramfs отобразится проблемная ситуация.

Если же ошибок нет – просто вводим exit. Иначе выполняем проверку диска:

$ fsck /dev/sda3 –y

Здесь указан том (в данной случае /dev/sda1), для которого требуется выполнить ручную проверку. С помощью следующей команды можно проверить все подключенные файловые системы:

$ fsck –A –y /dev/sda1

После этого перезагрузите ВМ.

The title might not be as descriptive as I would like it to be but couldn’t come up with a better one.

My server’s file system went into Read-only. And I don’t understand why it does so and how to solve it.

I can SSH into the server and when trying to start apache2 for example I get the following :

username@srv1:~$ sudo service apache2 start
[sudo] password for username:
sudo: unable to open /var/lib/sudo/username/1: Read-only file system
 * Starting web server apache2                                                                                                                                                                                                               (30)Read-only file system: apache2: could not open error log file /var/log/apache2/error.log.
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.

When I try restarting the server I get :

username@srv1:~$ sudo shutdown -r now
[sudo] password for username:
sudo: unable to open /var/lib/sudo/username/1: Read-only file system

Once I restart it manually it just start up without any warning or message saying something is wrong.

I hope somebody could point me into the right direction to resolve this issue.

Pro Backup's user avatar

Pro Backup

3,1503 gold badges24 silver badges33 bronze badges

asked Oct 7, 2012 at 15:41

John's user avatar

6

The filesystem will usually go into read-only while the system is running if there is a filesystem consistency issue. This is specified in fstab as errors=remount-ro and will occur when a FS access fails or an emergency read-only remount is requested via Alt+SysRq+U. You can run:

sudo fsck -Af -M

to force a check of all filesystems. As one of the other answers states, looking at dmesg is also very helpful.

Edit: Don’t forget the -M on the command-line.

NOTE: As mentioned by Bibhas in his answer: If fsck gets stuck after its version banner:

$ sudo fsck -Af -M
fsck from util-linux 2.20.1

you may want to try using the EXT4-specific fsck

$ sudo fsck.ext4 -f /dev/sda1

Provided the partition in question /dev/sda1 was an ext4 filesystem.

answered Oct 7, 2012 at 15:58

nanofarad's user avatar

nanofaradnanofarad

20.6k12 gold badges65 silver badges91 bronze badges

20

The answer by hexafraction didn’t work for me. Every time I tried executing sudo fsck -Af -M it just showed

$ sudo fsck -Af -M
fsck from util-linux 2.20.1

and nothing else. No error or anything. For me, booting into a live disc and executing this worked —

sudo fsck.ext4 -f /dev/sda1

Provided the partition in question /dev/sda1 was an ext4 filesystem.

notpeter's user avatar

notpeter

1,3841 gold badge8 silver badges9 bronze badges

answered Feb 17, 2014 at 15:44

Bibhas's user avatar

BibhasBibhas

9967 silver badges16 bronze badges

5

Here is the command that solved my problem :

mount -o remount /

better than a reboot or sudo fsck -Af

answered Jan 30, 2013 at 16:23

Sulliwane's user avatar

SulliwaneSulliwane

2,0855 gold badges26 silver badges38 bronze badges

8

If you want to force your root filesystem to remount as rw, you can do the following.

mount -o remount,rw /

answered Jun 1, 2015 at 5:07

johnboiles's user avatar

johnboilesjohnboiles

4494 silver badges3 bronze badges

5

Try running dmesg | grep "EXT4-fs error" to see if you have any issues related to the filesystem / journaling system itself. I would recommend you to restart your system, then. Also, sudo fsck -Af answer by ObsessiveSSOℲ won’t hurt.

answered Jun 24, 2013 at 18:17

thiagowfx's user avatar

thiagowfxthiagowfx

7955 silver badges9 bronze badges

Note that sometimes this can be caused by the computer forgetting the system time — disk check fails because the dates in the journal are in THE FUTURE!

Setting the BIOS time (and checking the BIOS battery) fixed this problem for me, without having to do any disk recovery.

answered Feb 23, 2016 at 2:15

Tony Cook's user avatar

Tony CookTony Cook

1211 silver badge3 bronze badges

2

(Deleted previous answer)

Edit: The main problem was on the windows side. After updating my Windows 10, the ‘quick start’ option automatically got enabled. On disabling that option again, and then again re-starting the machine, the problem went away. Windows 10 gave me heavy headache for days :(

The ‘quick start’ option can be found in ‘power options’ in the control panel. Disable that!!! :)

answered Dec 23, 2017 at 8:18

sarthakgupta072's user avatar

3

If you’re dual booting your machine with Ubuntu and Windows together and this issue occurs,it’s because Windows changes the filesystem,in that case this might do the trick.
Try disabling fast startup

Control Panel > Hardware and Sounds > Power Options > (in the left) Choose what closing the lid does > Change settings that are currently unavailable > Untick ‘Turn on fast startup’

Now booting into Ubuntu will solve the issue. Hope this helps!

answered Apr 25, 2018 at 8:03

Maulik Pipaliya Joyy's user avatar

0

If you have the graphical user interface go to the disk application, select the drive with the issue, click on the gears icon and choose the option Repair Filesystem. In less than a second the problem is fixed.

enter image description here

answered Aug 24, 2021 at 9:53

diegosasw's user avatar

diegosaswdiegosasw

1912 silver badges6 bronze badges

1

If you dual boot ubuntu alongside windows 10 it’s probably windows 10’s fast start-up that’s holding onto your filesystem , it doesnt unmount your hard disks properly.
to fix this you need to boot into windows 10

  1. Start > Power Settings
  2. click on Additional power setting on the right
  3. click on choose what thepower buttons do on the left
  4. clock on change settings that are currently unavailable
  5. unmark turn on fast-startup
  6. save changes
    and then reboot into ubuntu everything will work fine!

answered Oct 14, 2020 at 16:22

Alya Gomaa's user avatar

Alya GomaaAlya Gomaa

611 silver badge7 bronze badges

1

Usually linux puts your filesystems in read only when errors occur, especially errors with the disk or the filesystem itself, errors like a wrong journal entry for example.

You better check your dmesg for disk related errors.

Google is full of discussion about this and you can pick the ones that is closer to your configuration, but a look at dmesg is usually enough.

answered Oct 7, 2012 at 15:58

axis's user avatar

axisaxis

2192 silver badges4 bronze badges

2

For me,Rebooting a system solving this issue

sudo reboot

as he mentioned about it.

Remember

as System Administrator rebooting should be the latest Solution

answered Mar 14, 2017 at 18:09

Zaman Oof's user avatar

Zaman OofZaman Oof

2091 silver badge7 bronze badges

2

If you were in situations that can not use live disc, e.g. you are remotely ssh into your system, you can still using the command that @Bibhas had answered:

sudo fsck.ext4 -f /current/filesystem/mount/point

It will prompt for fixing your filesystem error. You also need to reboot your system remotely.

answered Sep 9, 2018 at 5:14

allenyllee's user avatar

1

In my case it was down to RAID 1 stabilizing after the initial installation. I have /boot and / on s/w RAID1. Having left the system overnight and rebooted, everything is working fine.
Richard

answered Dec 8, 2015 at 11:51

Richard Moore's user avatar

1

It looks like some mounted files have got corrupted, and as a result, the kernel has set the file system to RO to prevent further damage. To find which file system is corrupted, we could run:

cat /proc/mounts | grep -i ro

The output would be similar to the below:

proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
/dev/sda1 / ext4 ro,relatime,data=ordered 0 0
tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0

One of the solutions for this issue could be to remount the corrupted file system.

answered Jul 22, 2020 at 18:50

Binita Bharati's user avatar

1

I have had this problem on my computer for over 1 year and tried everything to solve the problem. Suddenly Linux goes into read-only mode. If you are editing something you are unable to save and have to execute fsck command and reset the computer. The computer is also very slow and freezing all the time. I removed the dual boot and left only Ubuntu, upgraded Ubuntu from version 18.04 LTS to version 20.04 LTS, and it didn’t work. What was crucial to solving the problem is the use of the dmesg command. The experience didn’t work out for me, just this command. The function of this command is to monitor the computer.

In my case, the problem was related to the SSD incompatibility with Ubuntu. I used HDD and after I switched to SSD the problem came up. The problem was solved by updating the SSD firmware, which was only possible by partitioned Windowns, because Kingston does not have the program to update firmware through Linux. I also installed the dual boot Windowns and Linux, first installing Windows over the entire SSD, then deallocating space through Windowns and installing Ubuntu, but it is very unlikely that this was the solution to the problem.

answered Nov 9, 2020 at 18:01

Denis da Mata's user avatar

1

Check if you have any faulty hardware.I got this error due to a hardisk loosening. Ran mount -o remount,rw / and it worked fine.

answered Jun 15, 2017 at 14:04

Mwongera808's user avatar

I am using the 18.04 LTS release and what I did was, first I unmounted my damaged drives then I went into “Disks” app by seaching in the dash. From there I selected the drive which was damaged. Make sure it is unmounted else it won’t work. In the options menu (the little gear shape), and clicked on “repair file system”. Boom! Worked like a charm.

answered Jun 2, 2018 at 12:07

Cdadgy71's user avatar

It’s misconfigured boot settings (try mounting / as ext2) not drive or partition physical error.

dmesg | grep "error" gave me:

ext3-fs (sda2): error: couldn't mount because of unsupported optional features (240) 
ext2-fs (sda1): error: couldn't mount because of unsupported optional features (240) 
ext4-fs (sda2): mounted file system with ordered data mode: opts: (null)

It mounted / as read only due to the fstab error=mount-ro directive.

Martin Thornton's user avatar

answered Aug 21, 2016 at 6:22

misiagogo's user avatar


0

1

Здравствуйте. Возможно, мой вопрос и популярен среди новичков, и вы скажете иди гугли.
Суть в том, что система перешла в read-only режим. При запуске не заходит даже в консоль. При запуске режима восстановления в консоль заходит. Однако, я перед тем как писать сюда, я нагуглил, и пытался изменить ситуацию, юзая команду mount. Но то-ли использовал неверно, то ли что, но воз и ныне там. Пожалуйста, напишите, или ткните пальцем в инструкцию для решения подобной проблемы для системы Debian, ибо переустанавливать крайне нежелательно.
Спасибо.

Somehow my Debian went to read only in root file system. I have no idea how this could have happened.
For example when I am in /root folder and type command nano and after that press Tab to list possible file in that folder I get the message:

root@debian:~# nano -bash: cannot create temp file for here-document: Read-only file system

The same for the cd command when I type cd /home and press Tab to list paths I have this:

root@debian:~# cd /home -bash: cannot create temp file for here-document: Read-only file system

I also have problems with software like apt and others. Can’t even apt-get update. I have a lot of errors like this:

Err http ://ftp.de.debian.org wheezy-updates/main Sources
406  Not Acceptable
W: Not using locking for read only lock file /var/lib/apt/lists/lock
W: Failed to fetch http ://ftp.de.debian.org/debian/dists/wheezy/Release  rename failed, Read-only file system (/var/lib/apt/lists/ftp.de.debian.org_debian_dists_wheezy_Release -> /var/lib/apt/lists/ftp.de.debian.org_debian_dists_wheezy_Release).
W: Failed to fetch http ://security.debian.org/dists/wheezy/updates/main/source/Sources  404  Not Found
W: Failed to fetch http ://security.debian.org/dists/wheezy/updates/main/binary-amd64/Packages  404  Not Found
W: Failed to fetch http ://ftp.de.debian.org/debian/dists/wheezy-updates/main/source/Sources  406  Not Acceptable
E: Some index files failed to download. They have been ignored, or old ones used instead.
W: Not using locking for read only lock file /var/lib/dpkg/lock

I have a lot of problems in the system.
Is it possible to fix that? How can I check what happened? What should I look for in the logs?

I know it could be because of the line in /etc/fstab file:

/dev/mapper/debian-root /               ext4    errors=remount-ro 0       1

but what is the problem? I can’t find nothing or maybe I don’t know where to look.

Edit:

I did search messages logs and found only this:

kernel: [    5.709326] EXT4-fs (dm-0): re-mounted. Opts: (null)
kernel: [    5.977131] EXT4-fs (dm-0): re-mounted. Opts: errors=remount-ro
kernel: [    7.174856] EXT4-fs (dm-2): mounted filesystem with ordered data mode. Opts: (null)

I guess it’s correct, because I have the same entries on other debian machines.

I found something in dmesg (I cut that output a bit because was a lot standard ext4 things)

root@gs3-svn:/# dmesg |grep ext4
EXT4-fs error (device dm-0) in ext4_reserve_inode_write:4507: Journal has aborted
EXT4-fs error (device dm-0) in ext4_reserve_inode_write:4507: Journal has aborted
EXT4-fs error (device dm-0) in ext4_dirty_inode:4634: Journal has aborted
EXT4-fs error (device dm-0): ext4_discard_preallocations:3894: comm rsyslogd: Error loading buddy information for 1
EXT4-fs warning (device dm-0): ext4_end_bio:250: I/O error -5 writing to inode 133130 (offset 132726784 size 8192 starting block 159380)
EXT4-fs error (device dm-0): ext4_journal_start_sb:327: Detected aborted journal

5 errors and 1 warning. Any ideas? Is it safe to use mount -o remount,rw / ?

Понравилась статья? Поделить с друзьями:
  • Как найти вероятность разноцветных шаров
  • Как найти пряжу по цвету
  • Как найти человека в сети ватсап
  • Как найти друзей по детдому
  • Как найти значение арифметической дроби