Fix a not clean, unmountable disk on FreeBSD

“fsck is our good friends” – By an accident poweroff, the mounted hard disk was not unmounted yet, and the power supply just been cut off … from the next boot, FreeBSD booted into single user mode because the system couldn’t mount my harddisk properly, let’s talk about how to fix it.

In single user mode, I just comment the line to mount the partition on my hard disk in /etc/fstab and then reboot, let my system boot normally first (the system was installed on another disk, if you have only one disk, it’s another situation), and try to mount the partition manually :

$ sudo mount /dev/ada1p1  /mnt/hdd

mount: /dev/ada1p1: R/W mount of /mnt/hdd denied. Filesystem is not clean – run fsck.: Operation not permitted

Still not work, so I use fsck_ufs to check the partition (it’s a UFS filesystem), and see if we can repair it:

$ sudo fsck_ufs /dev/adap1

** /dev/ada1p1
** Last mounted on /mnt/hdd
** Phase 1 – Check Blocks and Sizes
** Phase 2 – Check Pathnames
** Phase 3 – Check Connectivity
** Phase 4 – Check Reference Counts
** Phase 5 – Check Cyl groups
2005994 files, 8009350 used, 143322246 free (29606 frags, 17911580 blocks, 0.0% fragmentation)

***** FILE SYSTEM MARKED CLEAN ****

Looks great, it took me about only 3 minutes and didn’t report any bad news, for different situation, you may got different result, like additional message: ** Phase 1b – Rescan for more Dups, it depends.

Now we can try to mount it again:

$ sudo mount /dev/ada1p1  /mnt/hdd

No error message, awesome, let’s make sure it’s mounted:

$ df | grep ada1p1
/dev/ada1p1    ufs    577G    33G    498G    6%    /mnt/hdd

The end.

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。