How to use fsck in Ubuntu?
I intend to use fsck for checking my Linux partition of the main disk, because its file system is suspicious of being
not unmounted cleanlyby shutting down the system. I have searched in my environment variables: none of them except of PATH should control the fsck program. But the program apparently needs to be used during a boot:
:~$ fsck -V fsck from util-linux 2.20.1 Checking all file systems. [/sbin/fsck.ext4 (1) -- /] fsck.ext4 /dev/sda6 e2fsck 1.42 (29-Nov-2011) /dev/sda6 is mounted.(There is no /forcefsck file in my root according to How do I find out if there will be a fsck during the next boot? . My etc/fstab file contains
WARNING!!! The filesystem is mounted. If you continue you WILLcause SEVERE filesystem damage. Do you really want to continue? no check aborted.
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # proc /proc proc nodev,noexec,nosuid 0 0 # / was on /dev/sda6 during installation UUID=1ac55d8d-c112-4bc7-9e79-921d196f9f79 / ext4 errors=remount-ro 0 1 # swap was on /dev/sda7 during installation UUID=54f7e314-50e2-419b-a45d-47c3058ecc00 none swap sw 0 0 /dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
).
According to an answer to Slow reboot - understanding fsck and tune2fs I have tried tune2fs hoping that I'll get the present value of the
max_mounts_countparameter to be able to set it to 1 for checking the partition during the next boot. But after
sudo rm /var/lib/update-notifier/fsck-at-rebootand a restart I have only got a response
:~$ tune2fs -l /dev/sda6 tune2fs 1.42 (29-Nov-2011) tune2fs: Permission denied while trying to open /dev/sda6 Couldn't find valid filesystem superblock.Can I use
sudo tune2fs -l /dev/sda6safely? Thanks. 1
3 Answers
To run fsck on your harddrive you need to boot a liveCD and then run the commands with your harddrive partitions as the target.
"There is no /forcefsck file in my root"
-You need to create the file, it is just a blank file so run sudo touch /forcefsck and fsck will check your drive next time your reboot.
I concur with @bodhi.zazen comment here. The best way to go about checking a filesystem is to boot from live media, choose "Try Ubuntu" and then manually fsck the partition in question. For example sudo fsck /dev/ZdXY where ZdXY is the partition in question. sudo fdisk -l will give you a listing of your drives and the partitions on them. This information should be sufficient for you to determine which partition you need to check.
In addition to what other answers said, I would also point out that normally, if the root filesystem wasn't cleanly unmounted, if you just reboot, it will be automatically fsck'ed, when that status is detected during mounting.