Monday, June 23, 2008

Use fsck to fix "grub error 21"

-- Last Night when I shutdown down windows XP, it hung, so as usually I pressed the Power off button to turn off it by force.

Oops, today when I powered it on. "Grub Error 21" is threw to me.

Googled that , "Grub Error 21" means can't find the disk.


-- I installed SUSE , Centos and Windows XP on this PC.
-- Grub Loader is the boot loader
-- Partition for XP is FAT32. Another FAT32 partition has my data near 100Gb . (created using Magic Partition)
-- The Disk is about two years old.
-- It is a SATA2 hard disk, but the motherboard only supports SATA-1. So jump is set to run at SATA-1 mode
-- Never have such problem ever with press power off button by force.

Goto BIOS setup, there is no such 320GB SATA hard disk detected by defaul. When Pressed Enter to search it manually. The size detected is 136Gb.

--Uninstalled the HD, and connect to my another PC , which is running 3 other linuxs: SUSE 10.3, CentOS(RHEL) 5.2, and Ubuntu 8.4 .

-- Attach the HD to it, luckily that BIOS can detect it . But when booting failed with all three linuxs. I am disapointed. Why ?!

Warned my girlfriend that all data might lost, including mine. The most important thing to her is she can't IPTV while lying on bed and may lose many digital photoes.

She is sad. :(

Actually, I have more concerns as I have 100Gb data there for ten years. Not all has backup.



Watching TV and thought again, what else I haven't tried.


Finally, I had the clue. The motherboard is new and support SATA2. Why I stilled set the jump to SATA-1 ?


Trying again ...
--Booting Failed with CentOS
--Booting Failed with Suse
--Ubuntu brought to rescue mode .

Do a fdisk -l /dev/sda

All partitions are there. Good!

-- Mount my data partition and move to another 500Gb hard disk without error. (This partition's filesystem looks ok).
-- Now I suspect there is some logical corruption (c:\ filesystem), instead of hardware corruption.
-- fsck come to my mind.
-- unmount my data partition /dev/sda8 and ensure no mounting for /dev/sda1
-- fsck /dev/sda1 . Waw there is many illegale file name there. I just drop or auto-rename them one by one.
-- About 15 mins past, the fsck finished.
-- Now verify with CentOS, which boot successfully.


Set back to SATA-1 and attach to orignal PC.
-- BIOS is able to detect is properly.
-- Continue to boot, no more grub error 21 and I see the XP Flag is flying again.

Cheers! Thanks to Ubuntu fsck.



Lession learned and doubts:

-- Press power off button with caution. This may corrupt the boot sector. (or caused by virus ?)
-- What is enhanced inside Ubuntu fsck? As can't work with suse /rhel linux ?
-- Does fsck support NTFS ? It looks FAT32 still support partition large than 32Gb well. (use magicPartition)

No comments:

Post a Comment