DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 25th July 2013
moosejaw moosejaw is offline
Port Guard
 
Join Date: Oct 2009
Location: Milwaukee
Posts: 12
Thanked 0 Times in 0 Posts
Default [Solved]: External HD seen as drive 0 by OpenBSD MBR

I recently configured an external USB HD to use as a backup drive: used OpenBSD fdisk to devote the entire disk to OpenBSD, then used disklabel to configure two partitions, one for /altroot (a) and another to backup my primary user's home directory (d). Everything works great.

The only problem is that, if I leave the drive plugged in via USB and reboot, the MBR sees the USB drive as drive 0 and gets stuck, since the PBR, kernel, etc, are all on another disk (the internal hard disk). That is, upon booting, I get the following message:
"Using drive 0, partition 3.
No O/S"

If I understand FAQ sec 14.7 correctly, this means that my machine's BIOS is correctly finding the MBR code on the internal hard drive, but then that MBR code is seeing the external USB drive as "drive 0", rather than the internal hard drive (which the MBR code itself lives on!).

If I simply shut off the machine, unplug the external HD, and turn it back on, everything boots fine.

Questions: does this description of the problem sound accurate? And if so, does anyone know of a way to get the MBR to see the internal HD as "drive 0" while the external USB HD is plugged in? This is my office machine, so it's not a huge deal for me to just unplug the external HD whenever I reboot (though it means I can't reboot remotely with the external HD plugged in).

For reference, the kernel sees the internal HD as wd0 and the external USB HD as sd4. This is OpenBSD 5.3-stable, amd64.

Last edited by moosejaw; 25th July 2013 at 04:17 PM. Reason: problem solved
Reply With Quote
  #2   (View Single Post)  
Old 25th July 2013
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 3,891
Thanked 214 Times in 189 Posts
Default

I don't think you're seeing a problem with the minimal MBR code from your internal drive. Rather, I expect your BIOS is executing the MBR code it found on your external drive.

If you power up the computer with both drives plugged in, can you edit your boot device search order in your BIOS so that the internal drive is selected ahead of your external device by your BIOS? Perhaps you can remove the external drive from boot search entirely?
Reply With Quote
  #3   (View Single Post)  
Old 25th July 2013
moosejaw moosejaw is offline
Port Guard
 
Join Date: Oct 2009
Location: Milwaukee
Posts: 12
Thanked 0 Times in 0 Posts
Default

Bingo; thanks!

I didn't realize that the external HD would have MBR code on it, but I guess it was put there by fdisk? Perhaps I should zero out the drive and then just put a new disklabel on it without using fdisk first (if I understand FAQ sec 14.4 correctly, only i386 requires the use of fdisk first). Would that prevent the external HD from having any MBR code on it? Then I could go back to the old BIOS boot order (convenient for occasional booting from thumbdrives).
Reply With Quote
  #4   (View Single Post)  
Old 25th July 2013
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 3,891
Thanked 214 Times in 189 Posts
Default

I don't know why your platform seems to have an "external drive boots first" policy, nor why you cannot control this via BIOS settings. If you are able to control it, that, to me, would be your easiest solution.

There is no reason why you should not maintain an MBR sector at the front of your drive -- an MBR should be considered a risk mitigation. If you have an MBR, you may prevent another OS from inadvertently scribbling on the drive, should you accidentally connect the drive to one of those OSes.

Every fdisk-like program will write MBR bootcode into Sector 0 whenever an MBR is written for the first time, or reinitialized. All the fdisk-like programs I know of, including the one that came with MS-DOS, can update the bootcode in an existing MBR upon request.

If you really want to eliminate the MBR from your external drive, you could do so. However, if your BIOS insists on attempting to boot from the drive, if it does not find a valid MBR the BIOS may provide its own "No O/S" message and stop. In that case, all you will have done is waste your time backing up filesystems, zeroing out Sector 0, recreating a disklabel, reformatting filesystems, and restoring data.

Last edited by jggimi; 25th July 2013 at 04:50 PM. Reason: typo, clarity
Reply With Quote
  #5   (View Single Post)  
Old 25th July 2013
moosejaw moosejaw is offline
Port Guard
 
Join Date: Oct 2009
Location: Milwaukee
Posts: 12
Thanked 0 Times in 0 Posts
Default

The "external drive boots first" isn't a platform policy, it's just been my preferred BIOS setting, since I occasionally boot from a thumbdrive (to test other OSes, etc) and this lets me do that without hitting F12 and manually selecting the boot device. (i.e., I've set things up this way primarily out of laziness)

I did succeed in zeroing the external drive's first sector with dd, writing a new disklabel onto the disk, switching the BIOS boot order back to "USB drive before internal HD", and booting successfully from the internal HD.

I appreciate your thoughts on maintaining an MBR on the disk as a precaution. Perhaps I will fdisk/disklabel the external drive once more and set the BIOS to boot preferentially from the internal drive. I suppose I can manage to hit F12 for the occasional boot from USB, especially if this might keep me from accidentally damaging the external drive's contents if I plug it in somewhere else.

Thanks; this has been very helpful for learning more about fdisk and disklabel.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
backing up to external drive unixjingleman OpenBSD General 5 28th February 2011 12:05 AM
errors re-mounting external drive amorphousone OpenBSD General 3 12th March 2010 05:34 PM
looking for external drive buy suggestions gosha General Hardware 20 5th September 2009 05:32 AM
Problem Installing From External DVD Drive jimnms OpenBSD Installation and Upgrading 8 16th July 2009 07:12 PM
Booting with external USB drive plugged in? Bruco FreeBSD General 29 17th May 2008 05:39 PM


All times are GMT. The time now is 08:34 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick