18

I intend to use fsck for checking my Linux partition of the main disk, because its file system is suspicious of being

not unmounted cleanly
by 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.
WARNING!!! The filesystem is mounted. If you continue you WILL cause SEVERE filesystem damage. Do you really want to continue? no check aborted.
(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

 
# /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_count
parameter 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-reboot
and 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/sda6
safely? Thanks.

1
  • You need to run all those commands from a live USB with the target partition(s) unmounted. If fsck can not automatically fix the problems(s) your hard drive may be failing and you should back up your data.
    – Panther
    Oct 4, 2013 at 17:51

3 Answers 3

8

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.

6
  • Can I set (using the Main Menu) the fsck option to -V to get full information about the checking? Oct 4, 2013 at 17:58
  • IMO it is best to run various repair commands from a live CD. fsck works "OK" on auto pilot when booting, but if you have problems you are going to want to manually recover. If the problem is severe enough your system may fail to boot. I highly advise you review the man page and/or information about data recovery as those commands can result in data loss if not used with care.
    – Panther
    Oct 4, 2013 at 18:04
  • It works, thanks, I have accepted the answer. But running fsck, suggested by ghost 8, has not helped for making the partition image. I am asking a new question about it. Oct 4, 2013 at 18:24
  • I see the new question is not necessary, it is probably solved by manpages.ubuntu.com/manpages/hardy/man8/dump.8.html and manpages.ubuntu.com/manpages/hardy/man8/restore.8.html. Oct 4, 2013 at 18:55
  • I have tried sudo touch /forcefsck because Clonzilla gets interrupted during image creation due to problem with superblock. Now, as I said I have tried forcefsck but I have noticed no difference at startup. Is there a log somewhere to show the result of forcefsck?
    – Andras
    Dec 29, 2020 at 19:55
2

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.

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .