Some systems, particularly CentOS, require the root password to run fsck or similar utilities when the system cannot boot completely. In such cases, you can perform a disk check either by booting the system into single-user mode or by booting from another disk.
Boot from any LiveCD, for example, Parted Magic.
For convenience, configure the network:
# ifconfig eth0 inet 77.120.106.** netmask 255.255.255.0
# route add default gw 77.120.106.1 eth0
Check which disks and partitions are available:
# fdisk -l
Disk /dev/sda: 171.8 GB, 171798691840 bytes
255 heads, 63 sectors/track, 20886 cylinders, total 335544320 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000723b3
Device Boot Start End Blocks Id System
/dev/sda1 2048 1953791 975872 82 Linux swap
/dev/sda2 * 1953792 335542271 166794240 83 Linux
We are not interested in the /dev/sda1 partition; we need the main system partition — /dev/sda2.
Check the file system type:
# file -s /dev/sda2
/dev/sda2: Linux rev 1.0 ext3 filesystem data, UUID=09a28f89-96eb-4368-92ad-3d0dbf475dd4 (errors) (large files)
You can see what actions can be performed:
# fsck -N /dev/sda2
fsck 1.42.5 (29-Jul-2012)
[/sbin/fsck.ext3 (1) -- /media/sda2] fsck.ext3 /dev/sda2
Run the file system integrity check with the option to fix errors:
# fsck.ext3 -y /dev/sda2
fsck 1.42.5 (29-Jul-2012)
e2fsck 1.42.5 (29-Jul-2012)
/dev/sda2 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Inodes that were part of a corrupted orphan linked list found. Fix? yes
Inode 1007620 was part of the orphaned inode list. FIXED.
…
Pass 2: Checking directory structure
…
/dev/sda2: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sda2: 1901835/10428416 files (0.1% non-contiguous), 19568125/41698560 blocks
Now you can reboot the machine.
