Check that filesystem and partition table are in a good state?

If you have a MBR partition table, you can use fdisk:

sudo fdisk -l

This command will print out the partition table and will also automatically perform some consistency checks. If instead you have a GPT partition table, you can use gdisk (thanks Rod Smith for pointing that out):

sudo gdisk /dev/something

where /dev/something is the path to your disk device file (e.g. /dev/sda). From the gdisk interface you will be able to press v to run consistency checks.


About the filesystem, there are many ways to perform the check, the one I prefer is this:

sudo touch /forcefsck

This way, once you reboot the computer, the filesystem is checked for errors. This is a nice way of doing it because you don't need to worry about the dangers of running fsck.

It's worth noting that the file /forcefsck will be automatically deleted as soon as the check has completed.


You can use the fsck command. Make sure to execute the fsck on an unmounted file systems to avoid any data corruption issues.

Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

fsck /dev/sdaX

Make sure to replace the X with you device number.

The following are the possible exit codes for fsck command.

0 – No errors
1 – Filesystem errors corrected
2 – System should be rebooted
4 – Filesystem errors left uncorrected
8 – Operational error
16 – Usage or syntax error
32 – Fsck canceled by user request
128 – Shared-library error

You may also take a look at 10 Linux Fsck Command Examples to Check and Repair Filesystem

Source:fsck Man Page