Search My Blog

Monday, July 12, 2010

Checking the Root Filesystem without Rebooting

Checking the Root Filesystem without Rebooting
Topic:Backup/Recovery   Date: 2003-01-06
Printer Friendly: Print

spacerspacer
<<  <   >  >>

Subject
I'm not making any guarantees about this or even recommending it, but this is a procedure you can use to fsck a Linux root filesystem in a situation where a reboot is impossible but you suspect filesystem corruption.
Example: Remote web server suspected of having filesystem corruption. Can be taken out of service for maintenance but not rebooted at this time.

Here's what happens when you try to fsck a mounted filesystem:
[root@czarina usr-3]# /sbin/e2fsck /dev/sda1 fsck 1.27 (8-Mar-2002) e2fsck 1.27 (8-Mar-2002) /dev/sda1 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.       

OK. First unmount all unnecessary filesystems (eg. home, opt). Force the complete filesystem check even if filesystem is marked clean by setting the maximum mount count and mount count to the same number. You can confirm by running tune2fs -l.
[root@czarina usr-3]# /sbin/tune2fs -c 5 -C 5 /dev/sda1       

Remount / read-only and confirm.
Note: running mount will still show the filesystem as being rw.
[root@czarina usr-3]# mount -o ro,remount /dev/sda1 [root@czarina usr-3]# touch /test touch: creating `/test': Read-only file system [root@czarina usr-3]# mount /dev/sda1 on / type ext3 (rw)       

Now check the file system:
[root@czarina usr-3]# /sbin/e2fsck /dev/sda1 fsck 1.27 (8-Mar-2002) e2fsck 1.27 (8-Mar-2002) / has been mounted 5 times without being checked, check forced. Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /: 22290/66264 files (0.2% non-contiguous), 88016/265041 blocks       

Remount rw and confirm, remount any other filesystems you've unmounted,
[root@czarina usr-3]# mount -o remount /dev/sda1 [root@czarina usr-3]# touch /test [root@czarina usr-3]# mount -a       

This is not the preferred method of checking the root filesystem, but if you can't reboot the system it's better than running with suspected file system corruption. Use at your own risk!

Go there Read More Articles...
http://www.netadmintools.com/art179.html

Categories:
·GNU/Linux
·Homebrew designs
·Perl
·Ruby
·Administration
·Backup/Recovery
·Bugs/Fixes
·Certification
·Database
·Email
·File/Print
·Hardware
·Information Grab Bag
·Interoperability
·GNU/Linux ABCs
·Monitoring
·Name Resolution
·Network Services
·Networking
·Remote Control
·Security
·Desktop
·Web
·BSD
·Solaris
·GIAGD
·ERP
·REALbasic
·All Categories


Don

No comments: