How to run fsck manualy?

Hi everyone. I’ve experienced some strange crashes of kde 4.2 in suse 11.1 recently and would like to make sure my disks are ok, so from kde I switched to konsole with Alt+Ctr+F1, switched to root user, switched to runlevel 3 and tried to run fsck command, but it warned me that some partitions are still mounted, and that I can damage them if continuing with disk check, so I aborted the check. Now I don’t know how to run the disk check safely, since I can not unmount the partition on which kernel runs. Any help is much appreciated. Thanks.

The most straightforward is to run the Repair System from the install media which will do a thorough check, including a fsck.

If you can handle the CLI, you can boot to the Rescue Console from the install media, and issue the fsck commands yourself.

If you are experienced you could boot single user and remount / ro, then do the fsck.

Thanks ken_yap for pointing me the right way. I did select repair system from the installation dvd and nothing strange was reported, so I guess my disks are still healthy. However I did not like the repair system option very much, since I don’t know what is that autorepairing do and how. Probably it does everything as it should and I don’t need to worry about that, but still I and probably also someone else would like to know how to manually do disk check. My problem is solved, but despite that a good explanation for others having similar problem would be very helpful.

So first I decided for the second option that ken_yap suggested, that is to boot from installation dvd and select Rescue option, which put me into comand line interface (CLI) and from there I tried to issue fsck command, but the result was that it printed out the version of fsck (V 1.41.11 or something) and did nothing, I saw no processing of my disks. I think this is very strange or it may be, that if the disks are ok, it doesn’t say anything else but print the version number. But that didn’t convince me, so I decided to try the third method. I rebooted pc and on the grub menu entered “1” (without quotes) and pressed enter, this put me in single user mode on run level 3, after root login I tried to remount all partitions with commands like

mount -o ro,remount /dev/sda1

which worked on all partitions except on the one running the kernel, saying the partition was busy, and I was back at beginning of the story. Afterwards I decided to use autorepair option.

I would be thankful if someone would briefly describe the correct way of doing fsck, or tell me which mistakes I made during my attempts. I’m not much experienced penguin yet, but am willing to learn :slight_smile: Thanks for help again.

Additionally fsck should never be issued on a mounted partition. fsck should always be issued when the disk is offline (not mounted).

By the way you don’t issue fsck but fsck.<whatever filesystem you need to check>(x) :wink:

So for example fsck.ext3

@arcull

You need to specify the partition to check as the argument, e.g. fsck /dev/sda1

@BBR

fsck will call fsck.filesystem after it has autodetected the type of filesystem on it. Generally works for Linux filesystem types.

Hi arcull,
have you checked /var/log/messages
for any smartd errors?

You should find some info there if your hard drive is dying,

:slight_smile:

except for XFS where one must call xfs_repair as fsck.xfs does nothing :slight_smile:

But if you forget that, fsck.xfs will remind you what to do. So one less thing to remember.

fsck.xfs does nothing and always returns 0 (success) even if the FS needs repair

fsck.xfs is called by the generic Linux fsck(8) program at startup to check and repair an XFS filesys-
tem. XFS is a journaling filesystem and performs recovery at mount(8) time if necessary, so fsck.xfs
simply exits with a zero exit status.

   If  you wish to check the consistency of an XFS filesystem, or repair a damaged or corrupt XFS filesys-
   tem, see xfs_check(8) and xfs_repair(8).

Read the shell script that /sbin/fsck.xfs is.

ah, didn’t even know it was a shell script. good to know. I always use xfs_repair directly

thank you all for you suggestions, but I guess you did not understand me well enough :slight_smile: I know that you can issue command fsck for specific partition, but I wanted to check all partition that are in /etc/fstab, that’s why I didn’t specify any. I also know that you can not safely check partition which is mounted, and that is my main problem. So I guess the right way to do it would be to load kernel somehow in RAM, which happens I think when booting from installation dvd and selecting rescue option (correct me if I’m wrong ;)). This way no physical partition would mount automatically. However when taking this approach, when trying to issue fsck command, all it does, is print out the version of fsck command, and no check seems to be performed. All my partitions are ext3, so I don’t know if fsck.xfs would be the right way, but I can give it try. I also did check /var/log/messages but didn’t notice anything about disk errors (or don’t know what kind of errors should I look for :frowning: in there, so your suggestion would be helpful. Thanks again.

fsck knows nothing about /etc/fstab if nothing is mounted. So to check all the partitions in /etc/fstab you have to note the pathnames of the partitions and then issue the command

fsck <pathname of partition>

one by one. If you boot to the repair system, nothing will be mounted, so you have to note down the partitions you want to check on a piece of paper (yes, those still have uses) before booting.

Ignore the discussion about XFS. You would have had to have chosen XFS as the filesystem type to get it. Normally data partitions are ext3 in the default installation.

fsck knows nothing about /etc/fstab if nothing is mounted
, yap that was my mistake. I booted one more time in rescue mode and tried fsck partition by partition and it checked ok and reported no problems. Thanks again for help.

PS: Where in Slovenija are you? I was there in 2007. Enjoyed my time in Koper/Capodistria and other coastal towns. Ljubjana was cool too. I had to smile when a fellow tourist pronounced it l-jub-ja-na.


cat /var/log/messages | grep smartd

and look for warnings / errors like these:


smartd[2950]: Device: /dev/sdb [SAT], 1 Offline uncorrectable sectors

smartd[4254]: Device: /dev/sda [SAT], SMART Prefailure Attribute: 1 Raw_Read_Error_Rate changed from 253 to 100

smartd[3810]: Device: /dev/sda [SAT], 2 Offline uncorrectable sectors

I’ve got quite a lot of these in var/log/messages :(, should I worry about them?

smartd[4254]: Device: /dev/sda [SAT], SMART Prefailure Attribute: 1 Raw_Read_Error_Rate changed from 253 to 100
fortunately if found no line like this.

PS: Where in Slovenija are you? I was there in 2007. Enjoyed my time in Koper/Capodistria and other coastal towns. Ljubjana was cool too. I had to smile when a fellow tourist pronounced it l-jub-ja-na.
I live near city Nova Gorica which is situated somewhere midway between Koper and Ljubljana, but is much less crowded with tourists than Koper :slight_smile:

Ah ok, that town that has an Italian side and a Slovenian side. I didn’t get to that part of Slovenija. After Koper I went on to Trieste. That part of Europe has seen so much history.

Glad to hear that you have no prefailure warning,
:slight_smile:

Offline uncorrectable sector can cause unwanted resets,
Pls read this article, to fix the problem:
Bad block HOWTO for smartmontools

HTH

Don’t trust the disk anymore. Backup a.s.a.p., w.s.p Replace disk a.s.a.p.

Badblocks are misteriously related. You think you’ve allocated them in the table, all back to normal. The allocation of bad blocks is for rescueing data, not for keeping a defect disk going.