Reinstalling GPT boot loader

My hard disk had some bad sectors, and later became not-bootable, so I repaired the sectors with this utility, it has recovered 2920 sectors and my hard disk is 500[]GB.

Now, I get this message every time I try to boot up my system:
Code:
Not ufs
gptboot: No /boot/loader on 0:ad(0p2)
Not ufs
gptboot: No /boot/kernel/kernel on 0:ad(0p2)

FreeBSD/x86 boot
Default: 0:ad(0p2)/boot/kernel/kernel
boot:

I tried to dump my slices in another disk in order to reformat my disk but I'm stuck at this error message:
Code:
mount: /dev/ad4p4 : Invalid argument
It looks like I am unable to mount my UFS partitions.
My slices are still there because typing gpart show outputs this:
Code:
=> 34                976773101        ad4     GPT     (466G)
   34                      128          1     freebsd-boot      (64k)
   **                *********          1     freebsd-ufs      (2.0G)
   **                *********          1     freebsd-ufs      (40G)
   **                *********          1     freebsd-ufs      (3.0G)
   **                *********          1     freebsd-ufs      (15G)
   **                *********          1     freebsd-ufs      (100G)
   **                *********          1     freebsd-ufs      (303G)
   **                *********          1     freebsd-ufs      (2.8G)
 
The bootloader seems to be there. It looks like it cannot find some things in /boot/, including your kernel (/boot/kernel/kernel) :O

Now this is a really dirty hack but you could boot from a 9.1-RELEASE image, mount the 'old' filesystem and simply extract /usr/freebsd-dist/kernel.txz to it. That should at least give you a kernel to boot from. Depending on what else might be missing it may just be simpler to re-install over the existing filesystem.
 
It's not clear what magic technology that program uses, but it most likely just forced bad block remaps. Please install sysutils/smartmontools and run smartctl -a on that drive. If it shows more than a few sectors in Reallocated_Sector_Ct, plan on replacing the drive.
 
SirDice said:
The bootloader seems to be there. It looks like it cannot find some things in /boot/, including your kernel (/boot/kernel/kernel) :O

Now this is a really dirty hack but you could boot from a 9.1-RELEASE image, mount the 'old' filesystem and simply extract /usr/freebsd-dist/kernel.txz to it. That should at least give you a kernel to boot from. Depending on what else might be missing it may just be simpler to re-install over the existing filesystem.
Unfortunately mounting the old file system give this message:
Code:
mount: /dev/ad4p4 : Invalid argument
wblock@ said:
It's not clear what magic technology that program uses, but it most likely just forced bad block remaps. Please install sysutils/smartmontools and run smartctl -a(8) on that drive. If it shows more than a few sectors in Reallocated_Sector_Ct, plan on replacing the drive.
I don't have access to the system yet, still stuck on how to boot it.
 
I don't think it will be needed but restoring the bootcode is done like this:
# gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ad4
 
I tried that before but it returns an error message:
Code:
gpart: /boot/pmbr: No such file or directory
 
SIFE said:
I tried that before but it returns an error message:
Code:
gpart: /boot/pmbr: No such file or directory

Boot from a 9.1 install and use the "Shell" or "Live" option. Then the files should exist in the same location. The command assumes the needed files are in /boot/. Your system is pretty hosed so they may not be there anymore.
 
As @wblock says, your disk must be failing and probably is no use any more. Just for the future: bad sectors mean the disk must be replaced ASAP. There is NO utility to really fix bad sectors, make no mistake.

What you've reported in this thread:
Code:
mount: /dev/ad4p4 : Invalid argument
means most likely that such partition doesn't exist any more or is corrupted and can't be recognized.

gpart show seems to be showing the partition information such as is stored in where it is on a GPT disk. Which doesn't guarantee the partition itself still exists on the disk.
 
Last edited by a moderator:
Is there a way to recover my data even partially, I tried ufs2tool but I managed to copy user directory.
Code:
C:\ufs2tools>ufs2tool 2/1/0  usr
Jun 27,2013  13:55:10      <DIR> .
Jun 27,2013  13:55:09      <DIR> ..
Nov 21,2009  06:56:49      <DIR> bin
Jun 27,2013  13:55:08      <DIR> compat
Jun 27,2013  13:55:10      <DIR> games
Nov 21,2009  06:56:25      <DIR> include
Nov 21,2009  08:00:12      <DIR> lib
Nov 21,2009  06:53:58      <DIR> libdata
Nov 21,2009  06:56:52      <DIR> libexec
Nov 21,2009  06:53:58      <DIR> local
Jun 27,2013  13:55:10      <DIR> obj
Nov 21,2009  06:53:58      <DIR> ports
Nov 21,2009  06:56:57      <DIR> sbin
Jun 27,2013  13:55:10      <DIR> share
Nov 21,2009  06:53:58      <DIR> src
 
That is, /usr directory , right? Which must have been on a different partition, than /home, right?

The way I read this is that you're doing the right thing (given the result you've got so far), but the HDD is really in a bad condition.

Well, just recently I had series of those HDD failures within a rather short period of time. They were Windows and Linux formatted disks, but that makes no difference.

So, per my experience, there are no rules in such cases but to try everything you can find before the disk fails entirely. Then some disks would fail to get detected, then later on they may get detected again -- but this, of course, is not what you want from a HDD.

BTW: there is a good rescue CD at www.systesccd.org, which has a number of disk handling utilities like smartmontools. That one's useful in HDD problems diagnostics, so you can see the condition of your drive using S.M.A.R.T capabilities. There is also support for the most widely used file systems (UFS included), at least read access.
 
Parts of the disk have already failed. The first thing to do is to make a complete copy of it with dd(1), either to a large file or another disk. Use at least a bs=64k or it will take forever.

Then stop using the failing disk. The more it runs, the more damage may occur. If the data is very valuable (hundreds or thousands of dollars), there are data recovery companies like http://www.myharddrivedied.com/.

Otherwise, you can run any data recovery software on the copy without risking further damage to the original.
 
Back
Top