(這篇文章是英文版,若您需要台灣中文版,請至此閱覽)
As mentioned before, the MBR of system disk on kmd.twbbs.org was lost, by somehow weird reasons. So, I tried to find utilities for FreeBSD which may diagnose the missing disklabel automatically.
After googling, scan_ffs (8)
is the very answer.
The usage of scan_ffs (8)
scan_ffs [-lsv] [-b begin] [-e end] device
The options are as follows:
-l generate bsdlabel/disklabel style output, for further progressing
-s smartly skip partitions (may not suitable if there are UFS & other file system format)
-v verbose
-b and -e Indicate the begin and end of search range, respectively
device the node device you want to analyze
Steps of Recovery
(NOTE: The following actions were operated in the “FIXIT” mode with livefs. Some data was stored in the temporary file system; thus, reboot in any step will abort or fail the recovery.)
0. First of all, boot the machine from FreeBSD livefs, then go into Fixit mode.
Install the pre-compiled scan_ffs as a package, by
pkg_add -r scan_ffs
1. Then, type the following command in the shell
scan_ffs -l > /tmp/disklabel
The disk layout was found and stored in /tmp/disklabel:
X: 20971520 4194367 4.2BSD 2048 16384 0
X: 287410816 25165887 4.2BSD 2048 16384 0
2. Edit the file, and make sure the result is correct.
After some pencil-and-paper calculate, we got two partition sized 20 G and 13x G, respectively.
In my case, I remember there should be three disk labels, swap, “/”, and “/home”; therefore, the result generated by scan_ffs was obviously wrong.
So, I add a new description for the swap partition, from sector 0 to 4194367.
The modified result was listed:
b: 4194367 0 swap
a: 20971520 4194367 4.2BSD 2048 16384 0 # /
d: 287410816 25165887 4.2BSD 2048 16384 0 # /home
(The label c: was reserved by FreeBSD)
3. Try to commit the change, but do nothing.
bsdlabel -R -n -m i386 ad0 /tmp/disklabel
4. If no error message was shown, write the disklabels to the disk.
bsdlabel -R -m i386 ad0 /tmp/disklabel
5. Now, we can mount the partitions according to the node devices in /dev.
mkdir /mnt/slash
mount /dev/ad0a /mnt/slash
6. Last step!! Install the original boot strap from the mounted file system, then DONE!!
bsdlabel -B -b /mnt/slash/boot/boot -m i386 ad0a
在〈Disklabel Recovery under FreeBSD: Using scan_ffs〉中有 1 則留言