8

There's a new problem in 18.04 and later. I just discovered that the way I've always used fsck at the root access in recovery mode no longer works.

It used to be fsck -f /, but now it tells me that the disk is mounted r/w, and it won't run. Sure enough the disk IS mounted r/w. This is new behavior. Trying to remount the disk as ro with mount -o remount,ro / doesn't work either. And, running fsck from the recovery mode menus doesn't work either.

This is my root partition so I can't umount it or fsck it without data loss. I really need to run fsck manually because I get a message that there might be errors (UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY or You are in emergency mode).

How can I fsck my root partition on 18.04 and later?

Daniel T
  • 4,594
heynnema
  • 70,711
  • possible duplicate of https://askubuntu.com/questions/98559/ubuntu-server-live-cd-rescue-mode-cant-run-fsck?rq=1 – s1mmel Jan 23 '19 at 09:11
  • @s1mmel Thanks for your comment, however, the link goes to a question from 2012, and it doesn't address my problem in 18.10, whereas something has changed in 18.xx that causes the disk to be mounted r/w, and thus, you can't run fsck in recovery mode like you could in 17.xx. – heynnema Jan 23 '19 at 15:46
  • SNIP --> I read online that I shouldn't mount the root file system if I want to run fsck, so I chose the option "do not use a root file system". <-- SNIP. Did you see such an option? – s1mmel Jan 23 '19 at 15:57
  • @s1mmel Where are you seeing "do not use root file system"? Is this in 18.xx? In 17.xx recovery mode had the disk mounted r/o, and you could run fsck. In 18.xx this isn't the case, and not only can you not run fsck from the recovery menu, but you can't run it from the root prompt, without an error about / being mounted r/w. – heynnema Jan 23 '19 at 16:06
  • It was written in the question itself. – s1mmel Jan 24 '19 at 11:09
  • @s1mmel ah! In your link. That doesn't apply. That's from 2012, and it's for a 10.xx Server. – heynnema Jan 24 '19 at 14:00

1 Answers1

8

For 18.04 or newer... you MUST do it this way...

  • boot to a Ubuntu Live DVD/USB
  • open a terminal window by pressing Ctrl+Alt+T
  • type sudo fdisk -l
  • identify the /dev/sdXX device name for your "Linux Filesystem"
  • type sudo fsck -f /dev/sdXX, replacing sdXX with the number you found earlier
  • repeat the fsck command if there were errors
  • type reboot
heynnema
  • 70,711
  • 2
    For systems that lack a DVD or USB drive, this is not an acceptable solution. – GregD May 26 '20 at 17:30
  • 1
    @GregD For systems >= 18.04, you must use either DVD or USB. And who doesn't have at least a USB port? – heynnema May 26 '20 at 18:23
  • I have servers that lack such ports for security reasons. There are also machines that cannot boot from USB. In such cases, netboot can be an option, or doing from the initial ramdisk. – GregD May 28 '20 at 03:14
  • 2
    @GregD Please write an answer that describes how to do this from netboot, or from ramdisk... and make it applicable to the average home user... – heynnema May 28 '20 at 03:27
  • How to do it without Ubuntu live DVD/USB. I'm using a company ubuntu version and I don't have permission to insert something into my pc. – Trung Nguyen Nov 22 '21 at 03:46
  • 2
    @TrungNguyen No other way. Call the IT Dept. – heynnema Nov 22 '21 at 04:32
  • For anyone with ubuntu server, if you're booting from live ubuntu, use ubuntu desktop live, NOT server (which doesn't have a terminal)... – Tiago Dec 19 '22 at 13:08
  • @heynnema Can you please write the source of the information? – Porcupine Mar 31 '23 at 09:31