You are not logged in.
Hey all,
Regular Arch user here, got a new laptop and decided to put Arch on it. Everything went swimmingly (dealt with some Broadcom wireless issues, but replaced that with an Intel card and all problems were gone).
I decided I wanted to dual boot with OpenBSD. Being used to fdisk on Linux, I did not realize that OpenBSD's fdisk lets you freely write to *any* sector on your hard drive. Long story short, I have an OpenBSD partition filling the first 2047 sectors of my hard drive, which clobbered my MBR, rendering my device unbootable. OpenBSD did install to the appropriate partition and indicated success.
Thus, I am using a USB drive with the Arch installer to troubleshoot.
I tried zeroing the MBR:
# dd if=/dev/zero of=/dev/sda bs=1 count=512
After this I opened up fdisk, noted that partition numbers had gone away and were replaced by BSD-style disklabels (c was the whole drive, my valid partitions were various letters. First 2047 cylinders were an OpenBSD partition as expected). I deleted that first partition and then moved on to MBR recovery.
I then recovered the MBR with testdisk (analyse disk and let it rebuilt the MBR). This all worked fine, and I can arch-chroot into my Arch partition, wherein just about everything seems to work. When I try to install GRUB, though, I get an error:
# arch-chroot /dev/sda1 /bin/bash
# grub-install /dev/sda
Installing for i386-pc platform.
grub-install: error hostdisk/dev/sda appears to contain a ufs1 filesystem which isn't known to reserve space for DOS-style boot. Installing GRUB there
could result in FILESYSTEM DESTRUCTION if valuable data is overwritten by grub-setup (--skip-fs-probe disables this check, use at your own risk).
So, I tried running with the indicated flag, getting another error:
# grub-install --skip-fs-probe /dev/sda
Installing for i386-pc platform.
grub-install: warning: Attempting to install GRUB to a disk with multiple partition labels. This is not supported yet..
grub-install: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and
their use is discouraged..
grub-install: errof: will not proceed with blocklists.
I'm now beyond the former edge of my abilities (overwriting and recovering the MBR was new to me) to troubleshoot or solve this on my own. All of my data is present, and I have a prior working install of Arch, and what I can only assume is a working install of OpenBSD, but with no working bootloader to get to either. Based on my success with arch-chroot, I can only assume my Arch installation is still intact with all data present.
I know that the simplest answer would be to wipe the entire drive and start anew, but I'd like to avoid that. It's also now a point of stubbornness to fix my mistake and learn by doing so.
In summary: Overwrote first 2047 cylinders of hard drive with OpenBSD partition while installing OpenBSD. Clobbered MBR. Zeroed MBR. Recovered MBR. grub-install will not write to MBR because it detects ufs1 filesystem. How to force grub to install?
Thanks much.
Last edited by greggyb (2015-09-14 14:11:15)
Offline
If you are still able to fdisk the drive, try shrinking the first partition of 2048 sectors, and then shift it to sector 2048.
If you can do that, you can then wipe everything in there (dd if=/dev/zero...), put the MBR back, and re-try a grub install.
For example, my own disk has a sector size of 512 bytes, so if you have this, you should shrink+move the partition 1MB.
Oh, and, if possible... Do a backup !
Last edited by Webbeh (2015-08-31 01:24:59)
Offline
Webbeh, I will try that momentarily.
I've also just discovered something interesting. Before zeroing the MBR, I would boot to a screen that said GRUB with some gibberish characters that responded to no input whatsoever.
I hadn't tried booting without my USB image of Arch since then.
What I get now is a prompt with a blinking cursor:
1234F:
Almost all input simply results in a new prompt being displayed immediately (no text ever appears on screen, just a new prompt below the old one). When I strike my 3 key, I boot into OpenBSD. OpenBSD is on my /dev/sda3 and the partition is marked as bootable. Strangely, though, my Arch install (on /dev/sda1, also marked bootable) does not boot upon striking 1.
Offline
Apologies, I forgot to loop back around to this thread upon solving.
I was able to recover my MBR and reinstall GRUB by following the following steps (based on advice from Webbeh, thanks).
Overwrote the entire first MB of the hard drive, booting from Arch installation media:
# dd if=/dev/zero of=/dev/sda bs=1M count=1
I then ran testdisk, again from Arch installation media:
# testdisk
I chose to analyse the disk and let testdisk recover the partition structure. After checking its results, I wrote the recovered MBR to /dev/sda.
At this point I was able to reinstall GRUB:
# arch-chroot /dev/sda1 /bin/bash
# grub-install /dev/sda
I'm now running into an issue that I've not had a chance to research, that being os-prober not finding OpenBSD to write an entry to my grub configuration to boot to OBSD. This is obviously a separate problem and my cursory google uncovered a number of hits on a similar issue, so when I get a chance I will probably be able to follow up on my own there. In the meantime I am happily booting to Arch on my laptop.
Thanks for the help.
Offline