How to schedule a disk check for the next reboot. As root or using sudo do the following:
Method 1: Use the forecfsck file method
touch /forcefsck
shutdown -r now
Note: This command seems to check all partitions when run
Method 2: Up the mount count above the fsck check limit
Use this to identify what mounted partition you want to check
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 88G 81G 2.5G 98% /
On a LVM system the path to the device can be quite long
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/apf--ma--ln03-root
36G 913M 34G 3% /
/dev/sda5 236M 19M 206M 9% /boot
Check the current "Maximum mount count" and "Mount Count" values
tune2fs -l /dev/sda2 | grep -E '(Max|Mount)'
Mount count: 11
Maximum mount count: 36
Then set the actual "Mount count" to something higher
tune2fs -C 100 /dev/sda2
Check it out
tune2fs -l /dev/sda2 | grep Mount
Mount count: 100
Then reboot and wait for the disk check to finish, remember the bigger the volume the longer it takes. Make a cup of $BEVERAGE.
Ever wondered how to identify what partition is mentioned in /etc/fstab with
UUID=a0584727-1c8b-48df-867b-9e3b5a453ff7 / ext3 defaults,errors=remount-ro 0 1
Use tune2fs and you will find the answer
tune2fs -l /dev/sda2 | grep UUID
Filesystem UUID: a0584727-1c8b-48df-867b-9e3b5a453ff7
Now how would you apply a new UUID to a partition
tune2fs -U `uuidgen` /dev/sda3
tune2fs -l /dev/sda3 | grep UU
Filesystem UUID: 293512d5-fbb9-4a0a-9d50-ce347a3e0091
So it's easy then to reference that in /etc/fstab
UUID=293512d5-fbb9-4a0a-9d50-ce347a3e0091 /media/sda3 ...
What is a UUID? It's a Universally Unique Identifier. Theoretically, the way it's generated means that you wont get a duplicate anywhere. You see them used a lot where uniqueness is needed (check the Windows Registry).
It is a better system then using labels to identify partitions because a label can be easily duplicated.
If you are old school Redhat then you can use e2label and apply a label to the partition:
e2label /dev/sda3 MYDISK
Then in /etc/fstab you can refer to the volume thusly
LABEL=MYDISK /media/sda3 ext3 defaults 0 2
Note: I had to reboot for the above LABEL= change to take affect. The MYDISK label needs to appear in /dev/disk/by-label/MYDISK for a mount operation to work.
It's probably better to make the label to be the same as the mount point. For example
e2label /dev/sdb12 /u2
Then add that to /etc/fstab
LABEL=/u2 /u2 ext3 defaults ....
would be mounted at /u2 so you know exactly where the partiton is going.
I tried to set the mount count in a number bigger than the maximum count number in order for the disks to be checked on the next reboot, but it doesn't seem to work. The mount count number is raised and set to the right value and is incremented every time I reboot but checking on my disk isn't forced.
Do u have any clue on what is wrong?
I had some confusion between "Mount count" and "Maximum mount count" it's "Mount Count" you need to set but I don't think that's your issue.
sudo tune2fs /dev/sda3 -l | grep -i mount
Last mounted on:
Default mount options: (none)
Last mount time: Sat Sep 13 07:20:24 2008
Mount count: 3
Maximum mount count: 39
Have a look in /etc/fstab you should see something like:
UUID=48c9bea8-3b6f-4636-a83a-22c803ed1f03 /boot ext3 relatime 0 2
The last value, in this case a 2, is the order in which the partition is checked on a disk / is usually 1 and the other file partitions go up from there. If it's set to zero then the filesystem won't be checked. I think people set this to 0 to stop being interrupted by a disk check.
Also check man fstab for information
Method 1 was the silver bullet for my unbootable sick ubuntu machine!
Thanks for the tip!