Non-destructively running fsck
I have an ext3 partition that became corrupted after an unclean shutdown (the power cut). My machine no longer boots and using Knoppix, when I try to mount the root partition, it gives me the following message:
mount: wrong fs type, bad option, bad superblock on /dev/sdb1,
or too many mounted file systems
Is there any way to run fsck so that it writes changes to the filesystem into a temporary file and doesn't actually change the real filesystem so that I know what fsck will do to the partition (I've had experience with fsck where it hosed the filesystem) and know is the fsck operation will leave my data intact? I know I can do this by dd'ing the partition, but sometimes, it's not practical to dd a 50+ GB partition. Thank you for your help.
How about using the -N switch, and >> to a file? (of course make sure the file is on another drive or whatever)
So like fsck /dev/hda6 -v -N >> tempfile.txt
v = verbose, and N = Don't actually do it, just show what would be done.
NOTE: read 'man fsck' to be sure for yourself that this exactly is what you want.
Thanks GrapefruiTgirl. Do you know if this would then allow me to mount the filesystem afterwards to see if any damage had been done? I get a feeling that -N would just show you what would be done but wouldn't allow you to mount the filesystem afterwards. Any ideas?
Well.. I'm no expert by any means, but... If it's the root filesystem, it will automatically run fsck during boot, to fix it.
Mounting it and having a look around, you might not really be able to see any damage yourself. It might 'look' fine, but still have errors somewhere.
If you want to mount it, boot a live CD or load another OS on your machine, then mount this messed up partition 'Read-Only' and then CHROOT into it.
Again, as far as mounting it in the circumstances that it is the root partition of a system which you are actually booting, it's going to want to run fsck. There *might* be a flag you can set on either fsck or on reboot that will skip fsck, but I can't recall if/what it is.
Success stories vary, but personally I haven't had anything go terribly wrong with fsck; I haven't lost any data or files, with the exception of stuff like the open status of my browser for crash recovery, or files I have had open in 'kwrite' when I rebooted, that sort of thing. But, I use Ext2 and e2fsck. Don't know what difference it makes, but, that's just my own experience.
Why not just TRY what you want: run fsck -N and then remount it RO or RW, and see what happens?
|All times are GMT -5. The time now is 07:06 PM.|