Saturday, August 22, 2015

How to run fsck on root filesystem on virtual servers


How to run root filesystem checks on virtual servers


# server has root filesystem error on reboot
# this requires root filesystem check on reboot

1. Login to vmware and open a console for the server.
2. Click on the CD icon, and connect to ISO image for current version of the OS (In our case Red Hat 64-bit)
3. Use control-D to reboot server at the console session.

Note: It may take about 5-10 minutes to complete.

4. When Linux prompt is displays, click on console and type "linux rescue"  [ At the splash menu ] at the prompt
5. Select "English" for language and "US" for keyboard
6. Select "No" to start network interfaces
7. Click "Continue" for mount filesystems (this is critical to fix the errors)
8. Click "OK" when all filesystems mounted message appears
9. Shows all mounted filesystems

Note: the name of the root filesystem device, whatever is with /mnt/sysimage only

10. Display currently mounted FS.
# mount

/proc on /proc type proc (rw)
/dev on /dev type tmpfs (rw)
/dev/pts on /dev/pts type devpts (rw)
/sys on /sys type sysfs (rw)
none on /tmp type ramfs (rw)
none on /tmp/ramfs type ramfs (rw)
/tmp/loop0 on /mnt/runtime type squashfs (ro)
/selinux on /selinux type selinuxfs (rw)
/dev/sda2 on /mnt/sysimage type ext3 (rw,data=ordered)
/dev/system/TMP on /mnt/sysimage/tmp type ext3 (rw,data=ordered)
/dev/system/PKGS on /mnt/sysimage/pkgs type ext3 (rw,data=ordered)
/dev/system/WWW on /mnt/sysimage/www type ext3 (rw,data=ordered)
/dev/system/WWW-SERVERS on /mnt/sysimage/www/servers type ext3
(rw,data=ordered)
/dev/system/WWW-DOCROOT on /mnt/sysimage/www/docroot type ext3
(rw,data=ordered)
/dev/sda1 on /mnt/sysimage/boot type ext3 (rw,data=ordered)
/tmp/sysfs on /mnt/sysimage/sys type sysfs (rw)
/tmp/proc on /mnt/sysimage/proc type proc (rw)
/dev/DATA1/FMACTS on /mnt/sysimage/fmac/prod/ts/ecvm type ext3
(rw,data=ordered)
/dev/DATA1/FMACDATATS on /mnt/sysimage/fmacdata/prod/ts/ecvm type ext3
(rw,data=ordered)
/dev on /mnt/sysimage/dev type tmpfs (rw)
/dev/pts on /mnt/sysimage/dev/pts type devpts (rw)
/selinux on /mnt/sysimage/selinux type selinuxfs (rw)


11. umount all the non-rescue, real filesystem: anything under /mnt/sysimage
# mount | grep /mnt/sysimage | awk '{print $3}' | sed -n -e '2,$p' | sort -r | awk '{print "umount " $1}'  | sh

a. There may be some stragglers
# mount

/proc on /proc type proc (rw)
/dev on /dev type tmpfs (rw)
/dev/pts on /dev/pts type devpts (rw)
/sys on /sys type sysfs (rw)
none on /tmp type ramfs (rw)
none on /tmp/ramfs type ramfs (rw)
/tmp/loop0 on /mnt/runtime type squashfs (ro)
/selinux on /selinux type selinuxfs (rw)
/dev/sda2 on /mnt/sysimage type ext3 (rw,data=ordered)
/dev/system/WWW on /mnt/sysimage/www type ext3 (rw,data=ordered)

b. Unmount those by hand
# umount /mnt/sysimage/www

12. Unmount the root filesystem last
# umount /mnt/sysimage

13. Run the check on the root filesystem
# e2fsck -y /dev/sda2

14. Disconnect the CD in vmware console

15. reboot the server
# reboot

No comments:

Post a Comment