how to fsck?

okay, major newbie alert here. i just started with linode, so here goes:

How do I run fsck? I've searched online, but am kinda lost. It seems to me that I need to boot into single-user mode, but there's where I'm stuck…

I've noticed the radio box in the Configs section, but checking single user mode and rebooting my linode does what? And then how do I get into my Linode (what user), and what do I do to run fsck.

I got into the Lish console, and tried to run 'fsck /dev/ubda' but no go, and I'm lost now…

thanks,

aj

8 Replies

@yo-yo:

I got into the Lish console, and tried to run 'fsck /dev/ubda' but no go, and I'm lost now…
Make sure you attached to your console, and NOT at the Lish prompt. It should have worked. To reiterate:

Set your config profile to "Single User Mode", reboot. Connect to the console (it should attach to the console automatically), then run:

fsck.ext3 /dev/ubda

Just "fsck" should also work – it's pretty smart about determining the type of filesystem you want to check..

The other option is to deploy a small distro (like Debian), and add the disk image you want to fsck to the config profile (say, as /dev/ubdc), boot the small distro (not in single user mode), connect via ssh, do NOT mount /dev/ubdc, and run fsck /dev/ubdc.

-Chris

You can only run fsck against "quiescent" filesystems; basically those that are unmounted. So if you have a data disk that can be unmounted then you can run fsck against it while the machine is live. However the root partition can't be umounted and so that can only be fsck'd in single user mode (or very early on in the boot sequence).

To fsck a disk you need to know the device name for it. This can be found (normally) by looking in /etc/fstab. eg on my linode:

cat /etc/fstab

/dev/ubda / ext3 defaults 1 1

none /dev/pts devpts gid=5,mode=620 0 0

none /proc proc defaults 0 0

none /dev/shm tmpfs defaults 0 0

/dev/ubdb swap swap defaults 0 0

/dev/ubdc /datadisk ext3 defaults 1 1

/dev/ubdd /altroot ext3 ro 1 1

For me that means I could (in multi-user mode) do the following:

umount /altroot

fsck /dev/ubdd

fsck 1.34 (25-Jul-2003)

e2fsck 1.34 (25-Jul-2003)

/dev/ubdd: clean, 37991/82080 files, 112009/163840 blocks

mount /altroot

If I wanted to check the root disk…

fsck /dev/ubda

fsck 1.34 (25-Jul-2003)

e2fsck 1.34 (25-Jul-2003)

/dev/ubda is mounted.

WARNING!!! Running e2fsck on a mounted filesystem may cause

SEVERE filesystem damage.

Do you really want to continue (y/n)? no

check aborted.

I'd have to boot single user to do this properly :-)

Hope this helps!

Okay, so I guess my main problem still is I'm not sure how to log into my console? I can't get into my Linode with the normal 'ssh root@000'. So this is why I've tried to login via Lish, which works all swell and stuff.

So I'm in a session of my Linode via Lish, and I'm trying to run 'fsck.ext3 /dev/ubda' Here's what I get:

sh-2.05b# fsck.ext3 /dev/ubda
e2fsck 1.34 (25-Jul-2003)
modprobe: Can't open dependencies file /lib/modules/2.4.26-linode28-1um/modules.dep (No such file or directory)
modprobe: Can't open dependencies file /lib/modules/2.4.26-linode28-1um/modules.dep (No such file or directory)
modprobe: Can't open dependencies file /lib/modules/2.4.26-linode28-1um/modules.dep (No such file or directory)
modprobe: Can't open dependencies file /lib/modules/2.4.26-linode28-1um/modules.dep (No such file or directory)
fsck.ext3: No such file or directory while trying to open /dev/ubda

The superblock could not be read or does not describe a correct ext2filesystem.  If the device is valid and it really contains an ext2 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock:    
e2fsck -b 8193 

So is my disk f'ed? I'm just confused.

@yo-yo:

sh-2.05b# fsck.ext3 /dev/ubda

[ snip ]

fsck.ext3: No such file or directory while trying to open /dev/ubda

Can you do an "ls -l /dev/ubda" ?

It should look something like:

brw-rw–-- 1 root disk 98, 0 Nov 22 19:29 /dev/ubda

If this entry doesn't exist then that could explain your problems. In this case I would do as Chris suggested and deploy a second small distro. This will allow you to fsck the disk and if /dev is broken on your existing image then you can rebuild it

okay, thanks! using debian worked. so /dev is missing and broken on my system, how do I go about fixing it?

@yo-yo:

okay, thanks! using debian worked. so /dev is missing and broken on my system, how do I go about fixing it?
After you've fsck'd the partition in your debian instance, mount it somewhere temporary

eg

mkdir /a

mount /dev/udbc /a

Now look in /a/dev - if this is totally bad you could try

mv /a/dev /a/dev.broken

#

( cd / && tar cf - dev ) | ( cd /a && tar xfp - )

This will copy the debian /dev tree over to your broken area.

You can check this with "ls /a/dev"

Unfortunately, if /dev is broken then there might be other damage to the filesystem (other missing files, programs, configurations). You might be better off rescuing the data and setups and rebuilding the image from scratch, just to be safe.

The entire /dev is missing? I hope this wasn't a Gentoo system with devfs, since /dev/ubda is really /dev/ubd/0.

-Chris

oops.

guess maybe I should have stated that from the beginning. Yep, I've been using Gentoo for all of four days, so pretty darn new at it.

Oh, and when I said my /dev was missing, that was a typo. I meant /dev/ubda was missing, which caker has explained away.

all seems well now. sorry for the trouble!

:oops:

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct