2

I have problems with the main OS partition, but seems that i can't run fsck on mounted partitions?

Is there a way to diagnose mounted partition (i'm having problems lately) and if there isn't what is the best way to check it when not mounted?

user240891
  • 739
  • 4
  • 10
  • 26

2 Answers2

3

You can perform a fsck on your root partition during the next reboot by creating a file named forcefsck in your root directory:

sudo touch /forcefsck
reboot
Byte Commander
  • 107,489
  • Will this work when I have encrypted hdd, home and swap? – user240891 May 17 '17 at 07:09
  • It should work, I think, but I can't test it here. In the worst case, if that file prevented your installation from booting and failed to trigger a fsck, you could mount the partition from a live system and remove it from there. But as you'd have to do the fsck from a live system anyway if it doesn't work this way, I don't see a real problem with just trying this method. – Byte Commander May 17 '17 at 08:25
  • will the file go away after running fsck or do I have to remove it manually afterwards? – wotter Feb 20 '19 at 17:47
  • 1
    @wotter It will get removed automatically during the file system check. – Byte Commander Feb 20 '19 at 18:07
1

I suggest running it in "Initramfs".

dracut is a low-level tool for generating an "initramfs" images with a lot of capabilities.

Let's install it:

sudo apt install dracut

After installation is finished a new "initramfs" will be generated and GRUB will be updated automatically; It also removes initramfs-tools.

Now reboot the system, hold the Shift to make the GRUB appear (if it won't by itself), press e to edit the default menu. There is a line which starts with linux at the end of that line add rd.break=pre-mount then press Ctrl+x to continue boot process.

it means that drop me into initramfs before mounting the filesystem, Now we are in a sh shell and we can simply run fsck:

$ fsch /dev/sda1
/dev/sda1: clean,  xxx/xxx files,  yyy/yyy blocks

dracut
dracut.cmdline

Ravexina
  • 55,668
  • 25
  • 164
  • 183