DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD General

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

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 13th May 2008
Bruco Bruco is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Kalamazoo, MI, USA
Posts: 61
Default Booting with external USB drive plugged in?

I swear I've looked around our good friend the Internet for an answer to this, but haven't found it.

I've got an external USB drive plugged into my FreeBSD box. Once a week a script runs that backs up to it with rsync.

This is all well and good, but on very rare occasion I might need to reboot that box remotely (I ssh into it from work, for example). And when you reboot it with the usb drive plugged in, it boots to a mountroot prompt and wants me to specify, well, where to mount root!

I understand this behavior to some extent, but can I tell the OS to ALWAYS default to a specific mount point for root, so I can reboot this thing with the usb drive plugged in and it will just load up normally?
Reply With Quote
  #2   (View Single Post)  
Old 13th May 2008
robbak's Avatar
robbak robbak is offline
Real Name: Robert Backhaus
VPN Cryptographer
 
Join Date: May 2008
Location: North Queensland, Australia
Posts: 366
Default

There are a couple of possibilities. The first is that you are probably booting off the USB drive, and not the internal hard drive! The OS is then, quite understandably, confused over what it should do. The disk's device nodes are probably altered too. The solution would be simple - get into the machine's BIOS and alter the boot order.

Another possibility is that the machine has scsi disks, and the addition of a usb device bumps the /dev/dan nodes along one. I cannot see that happening, though - if a system prioritized usb disks above scsi ones, well......
__________________
The only dumb question is a question not asked.
The only dumb answer is an answer not given.
Reply With Quote
  #3   (View Single Post)  
Old 13th May 2008
roddierod's Avatar
roddierod roddierod is offline
Real Name: Rod Person
VPN Cryptographer
 
Join Date: Apr 2008
Location: Pittsburgh, Pa
Posts: 437
Default

Quote:
Originally Posted by robbak View Post
Another possibility is that the machine has scsi disks, and the addition of a usb device bumps the /dev/dan nodes along one. I cannot see that happening, though - if a system prioritized usb disks above scsi ones, well......
This happens to me. If I leave a usb pen drive plugged in it then maps to /dev/da0 and then boot stops because it can't find the root drive.

This machine also has one SATA drive and when I had FreeBSD install on that as root I didn't have the problem - as I recall.

It never really bothered me all that much to really look into.
__________________
"The basic tool for the manipulation of reality is the manipulation of words. If you can control the meaning of words, you can control the people who must use the words." -Philip K. Dick
Reply With Quote
  #4   (View Single Post)  
Old 13th May 2008
Bruco Bruco is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Kalamazoo, MI, USA
Posts: 61
Default

Thanks for the replies so far.

I don't believe it's booting from the USB drive, because it is loading FreeBSD (where as the USB drive has no OS on it at all) and just stopping part of the way to ask where to mount root from. Plus, this is a little bit older of a motherboard, I don't know if the BIOS will even boot from a USB device (I can check, of course).

I don't have SCSI devices, but I do have a HighPoint 454 RAID5 controller, and that's what FreeBSD loads from. I don't know exactly how it treats the logical drive created by the RAID set - maybe the same as a SCSI device? Would the contents of fstab or another file help me figure that out?

It wouldn't bother me either, but if I reboot the box remotely (or it reboots for any weird reason - not that FreeBSD has done that to me so far!) I lose remote access because it never finishes loading the OS.

Any additional ideas?
Reply With Quote
  #5   (View Single Post)  
Old 13th May 2008
roddierod's Avatar
roddierod roddierod is offline
Real Name: Rod Person
VPN Cryptographer
 
Join Date: Apr 2008
Location: Pittsburgh, Pa
Posts: 437
Default

Do you have dmesg of a failed boot?
__________________
"The basic tool for the manipulation of reality is the manipulation of words. If you can control the meaning of words, you can control the people who must use the words." -Philip K. Dick
Reply With Quote
  #6   (View Single Post)  
Old 13th May 2008
Bruco Bruco is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Kalamazoo, MI, USA
Posts: 61
Default

Well, last night I booted it without the drive plugged in and plugged it in afterwards. I imagine you would want to see a dmesg after I booted it WITH the usb drive plugged in, and I can't get that right now (I'm at work with only ssh access to the box). I can do that tonight though and paste the output of a dmesg afterwards.

I did verify that it sees the RAID5 logical drive as a SCSI. And that's how it designates the external USB drive too. Here's an output of a df command I just ran (the USB drive is connected and mounted at /usbbackup):

# df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/da0s1a 496M 39M 417M 8% /
devfs 1.0K 1.0K 0B 100% /dev
/dev/da0s1e 496M 60K 456M 0% /tmp
/dev/da0s1f 285G 203G 59G 78% /usr
/dev/da0s1d 1.7G 18M 1.5G 1% /var
/dev/da1s1 279G 199G 81G 71% /usbbackup
#


So, here's an idea. Can I add /dev/da1s1 to my fstab with the noauto option as a way to tell it not to mount the USB drive at all on boot (my script mounts and umounts it when it's needed anyway)? Or is fstab not referenced during boot until AFTER the point where it's asking me where to mount root from? Or, is it just a crazy idea altogether?
Reply With Quote
  #7   (View Single Post)  
Old 13th May 2008
roddierod's Avatar
roddierod roddierod is offline
Real Name: Rod Person
VPN Cryptographer
 
Join Date: Apr 2008
Location: Pittsburgh, Pa
Posts: 437
Default

I'll bet when you boot with the USB drive plugged it it gets seen as
/dev/da0s1a so changing fstab will not help.

Like I said, I haven't really researched it since it's not too big a deal with me. But, it does piqued my interest as to why this happens now that someone else actually has the problem also.
__________________
"The basic tool for the manipulation of reality is the manipulation of words. If you can control the meaning of words, you can control the people who must use the words." -Philip K. Dick
Reply With Quote
  #8   (View Single Post)  
Old 13th May 2008
Bruco Bruco is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Kalamazoo, MI, USA
Posts: 61
Default

So basically it's seeing it BEFORE my RAID logical drive, and assigning it /dev/da0, and then it can't find where to mount root and it's asking me?

This is a sticky wicket. So, I wonder... can I tell it to look at my RAID controller BEFORE the USB ports?
Reply With Quote
  #9   (View Single Post)  
Old 13th May 2008
roddierod's Avatar
roddierod roddierod is offline
Real Name: Rod Person
VPN Cryptographer
 
Join Date: Apr 2008
Location: Pittsburgh, Pa
Posts: 437
Default

Yes, that is what I believe. But, I think the "telling" part is a function of the OS. The part I don't get is the machine boot to the point of read fstab to mount the drives, it should "know" that it's on the root drive. This is all just off the top of my head, I need to find some time to sit down and look at it.
__________________
"The basic tool for the manipulation of reality is the manipulation of words. If you can control the meaning of words, you can control the people who must use the words." -Philip K. Dick
Reply With Quote
Old 13th May 2008
Bruco Bruco is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Kalamazoo, MI, USA
Posts: 61
Default

Yeah, I follow what you are saying. If it's reading fstab then it's already MOUNTED the right drive! Or at least, I would think.

I'll see what I can figure out too. And obviously, anyone else with ideas please chime in as well!
Reply With Quote
Old 14th May 2008
Bruco Bruco is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Kalamazoo, MI, USA
Posts: 61
Default

So I was thinking (which is generally dangerous) and while I haven't had a chance to boot that thing with the USB drive plugged in to confirm that it's assigning it /dev/da0, let's go on that assumption. If that's the case, then it's probably assigning my logical RAID 5 drive /dev/da1, yes? So, could I add a rootdev= or a root_disk_unit= line in my loader.conf that points it to that path, instead of /dev/da0? (I'm not sure which of those I would use, I haven't finished reading about them.)

Of course, I imagine if I did that and ever booted WITHOUT the USB drive plugged in, it wouldn't be able to find root and I'd get the mountroot prompt all over again. I really think the fix is some way to either detect the RAID 5 drive BEFORE the USB drive, or somehow force the USB drive to always be /dev/da1.

What a pickle.
Reply With Quote
Old 14th May 2008
roddierod's Avatar
roddierod roddierod is offline
Real Name: Rod Person
VPN Cryptographer
 
Join Date: Apr 2008
Location: Pittsburgh, Pa
Posts: 437
Default

if the assumption we are working on is correct, then you'd have to leave the usb drive plugged it if you set the rootdev to /dev/da1.

I wonder if there is a way to set the usb subsystem to not probe for devices till after the raid controller mounts.
__________________
"The basic tool for the manipulation of reality is the manipulation of words. If you can control the meaning of words, you can control the people who must use the words." -Philip K. Dick
Reply With Quote
Old 14th May 2008
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Default

there is way out.

you can label all your filesystems and specify the label instead of the device file in fstab.

for example to label '/' :

1. boot fbsd into single-user mode
2. tunefs -L root /
3. change the first field in the fstab entry to /dev/ufs/root
4. if you are running fbsd 6.x add: geom_label_load="YES" to /boot/loader.conf

do the same for all the other fiesystems.

Last edited by ephemera; 14th May 2008 at 05:34 PM.
Reply With Quote
Old 14th May 2008
Bruco Bruco is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Kalamazoo, MI, USA
Posts: 61
Default

Hey, that's neat. I will give that a try and post results. Thanks!
Reply With Quote
Old 14th May 2008
Bruco Bruco is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Kalamazoo, MI, USA
Posts: 61
Default

Well, I just tried this with a 6.3 box at work, and it works! So, just need to try it out on the box at home with the USB drive connected. One question - what do I do with the swap partition? It's /dev/da0s1b but it has no mountpoint, so how would I label it? (Or do I need to?)

Thanks again!
Reply With Quote
Old 14th May 2008
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Default

you are right labelling swap is not possible.

but there is a simple solution:
for example if your swap is da0s1b without the usb and da1s1b with usb inserted.
you can have swap entries for both devices in fstab. only one of them will work the other will print an error message and booting will continue.
also, since a b partition is never used for anything other than swap there is no risk.
Reply With Quote
Old 15th May 2008
Bruco Bruco is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Kalamazoo, MI, USA
Posts: 61
Default

Very cool, thank you!

I didn't have a chance to make changes last night (I'm getting married next weekend and my life is nothing but errands for the wedding right now) but I think I'll have a little bit of spare time tonight. I'll try this out!
Reply With Quote
Old 16th May 2008
Bruco Bruco is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Kalamazoo, MI, USA
Posts: 61
Default

Alright, I did as described and everything appears to work! In fact, the only issue I have is that the script I wrote to rsync my data first mounts the USB drive:

# mount -t msdosfs -o large /dev/da1s1 /usbbackup

before running rsync.

But of course, that USB drive might be da0 (if I boot with it plugged in) or it might be da1 (if I plug it in after the box is up). So I need to modify my script. I figure I'll just:

# ls /dev | grep da1s1a

If da1s1a exists I know that da1 is my RAID 5 drive. If it doesn't, that's my USB drive. My script can proceed from there. (That's probably not very sophisticated, but hey, I've been learning scripting even less time than FreeBSD!)

Thanks again!
Reply With Quote
Old 16th May 2008
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Default

maybe:

mount -t msdosfs -o large /dev/msdosfs/some_label /usbbackup
Reply With Quote
Old 16th May 2008
Bruco Bruco is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Kalamazoo, MI, USA
Posts: 61
Default

Can I label it? It's not normally mounted from fstab.
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
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
external drive partition question + fdisk question gosha OpenBSD General 15 15th June 2009 02:00 PM
WD Passport Portable external drive Beastie General Hardware 7 25th April 2009 12:50 PM
Trouble booting if USB drive attached map7 FreeBSD General 1 22nd December 2008 04:51 PM


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


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