2

I'm trying to run e2fsck on boot of a persistent live lubuntu to fix 'corrupt filesystem' error of a writable system partition (ext4) and I want to automate this somehow (so ideally I do not want to boot into another live usb to do it)

I want to automate because these errors have a tendency to accumulate with restarts/shutdowns of the system (I do follow instructions and remove the USB stick on which the system is and then press Enter on shutdown/restart). After several months of use (maybe 100 shutdowns) the errors did accumulate so much, that the system became unable to boot.

I did fix the errors by booting another live system and then running:

umount -l /dev/sdc5
e2fsck -y /dev/sdc5

the /dev/sdc5 being the writable partition of the system mounted at /media/lubuntu/writable

In order to automate this for the future I've tried fixing the error from the same storage medium by:

  1. booting into the Recovery mode, yet e2fsck returned 'Target is busy', so the lazy unmount wasn't succesful.
  2. hitting e in the GRUB menu and editing fsck.mode=none to fsck.mode=force and then booting (Ctrl+x/f10) but it did not fix the errors.
  3. forcing fsck on boot by changing the maximum number of mounts by sudo tune2fs -c -1 /dev/sdb5 but it did not fix the errors

I'm not sure if in the last two cases the fsck did run and I don't know how to find out, I've tried to read the contents of several logs in /var/log but did not find a mention about it

my live system was made using mkusb and lubuntu 22.04.3 iso any help welcome

andrej
  • 59

1 Answers1

2

The question was answered by @sudodus in the comments. I will summarize it here:

  • Run a live lubuntu that does not mount the writable partition for logs: in the mkusb made GRUB menu, highlight the live option, press e, replace the inline text quiet splash with nopersistent toram, and boot using f10 or Ctrl+X.
  • When booted, unmount the writable partition (e.g. via the KDE Partition manager GUI), and then in the Terminal run sudo e2fsck -f /dev/sdXN (sdXN being the writable partition, e.g sdc5)

Another possible fix: use a higher quality storage medium for the system, to prevent the errors from accumulating over time (not tested)

andrej
  • 59