0

Is there any possibility to run fsck if I have one ext3 partition /dev/sda1 only? File system is in the read-only mode, reboot did not help - automatic fsck failed and manual one is required. I have root access to my VPS console. I can't use live CD and similar techniques but command prompt only.

I tried the following (for CentOS 5.6):

telinit S
mount -o remount,ro -t ext3 /dev/sda1 /
fsck -fyC /dev/sda1

It refuses to start fsck on the partition as it's mounted. Now, I understand where I was wrong (SF topic). Still, is there any way to get round this and avoiding use of fsck -n?

Thank you.

Andrew
  • 1,044
  • 6
  • 21
  • 36

2 Answers2

1

You want to boot into your initrd's shell and do the fsck from there, before the root filesystem is mounted. It might involve loading modules in order to get access to your partitions.

This is the reason why having multiple filesystems isn't an unnecessary luxury.

womble
  • 95,029
  • 29
  • 173
  • 228
  • I believe that CentOS's default initrd doesn't have a shell built into it. – anastrophe Aug 23 '11 at 06:16
  • @womble I have tried searching for initrd.img but without success. I know that I can pass /boot/initrd.img to the loader to access initrd shell. But I do not have it. Would you be so kind to share your experience of how to 'tie' this shell to modern distributives? – Andrew Aug 23 '11 at 15:26
0

Don't you want

mount -o remount,rw -t ext3 /dev/sda1

?

fsck will refuse to run except in a non-writing mode, because you're remounting read-only. Yes?

anastrophe
  • 5,388
  • 2
  • 15
  • 16
  • No, it won't. The SF question the OP linked to will explain more. – womble Aug 23 '11 at 05:56
  • If you're in single user, dumped there because fsck on boot couldn't fix automatically, then you remount rw, and run fsck. I've done this, successfully, on CentOS 5.x (I believe 5.4 - it's been a while). If your machine is toastfully unresponsive due to unfixable disk errors, then you've got nothing to lose by forcing fsck in single user mode. The risks are effectively meaningless, since you've already entered the World of Hurt. – anastrophe Aug 23 '11 at 06:11
  • 1
    The risk would still be lower if you fscked a read-only mounted filesystem, and fsck doesn't refuse to write because it's mounted read-only, because it doesn't read/write via the VFS layer. – womble Aug 23 '11 at 06:28
  • @womble Your point is right. There is no a thought to start fsck on the production server mounted in read-write mode. – Andrew Aug 23 '11 at 14:17