# messed up my boot drive; won't boot now



## dvl@ (Mar 10, 2013)

This isn't a production system.  It's just my testing HDD.  I think I did some nasty gpart stuff on it while I was booted from it.  I'm not sure what happened.

My first attempt at salvage made some headway I think.  I got past the previous message which was no boot disk found (unsure of the exact message).  In attempting to get past that, I issue this command: [cmd=]gpart bootcode -b /boot/mbr /dev/ada0[/cmd]. Here's what it looks like: http://bit.ly/10rWQUx (screen shot image)

When booting, it says "Missing Operating System".

I think I need to add another [cmd=]gpart bootcode -b /boot/boot[/cmd] but not sure how or if that's correct.


----------



## wblock@ (Mar 10, 2013)

There's no freebsd-boot partition, although there is space for one, the 64K free spot before the first partition.  So:
`# gpart add -t freebsd-boot -b34 -s64k ada0`


This part is different, so back up first.  On my test disk, that new partition shows up as partition 2, even though it is before partition 1.  Writing the bootcode to it:
`# gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 2 ada0`

Incidentally, those partitions are misaligned.


----------



## jb_fvwm2 (Mar 10, 2013)

[The post above me bested this one by a few seconds..]

The Nov. 2012 freebsd-questions list may be of help; but I found that any attempt to restore the full boot stuff on a disk that did not start from scratch, made unavailable the data on it.  So ...using several threads from here and the wonkity guide, they were too dissimilar to do anything than just following the latter. YMMV...


----------



## dvl@ (Mar 11, 2013)

Thank you.  I got this solved earlier tonight.

Here's what I did:


```
# gpart bootcode -b /boot/pmbr ada0
# gpart add -b 34 -s 94 -t freebsd-boot ada0
# gpart bootcode -p /boot/gptboot -i 1 ada0
```

I also had to modify /etc/fstab (but that is outside the scope of the problem; the device renumbered because of changes in HDD within the box).


----------



## dvl@ (Mar 11, 2013)

Screen shots etc here: http://dan.langille.org/2013/03/10/oops-i-deleted-my-boot-partition/


----------

