# Installing FreeBSD to USB



## calgarychris (Sep 21, 2011)

Hi,

I'm completely new to FreeBSD, Unix and everything non-Windows/Mac, so please be gentle and forgive my ignorance.

I've been reading the Handbook and New User guides and playing around trying to install FreeBSD but I'm not sure if I am misreading the Handbook.  I realise that you can put the installation file onto a memory stick by using dd or the Image Writer program and then installing FreeBSD from that, but I wanted to confirm - can you run FreeBSD off of a USB stick?  I currently am running Freenas off a USB stick and would like to do the same with FreeBSD as I'm starting to think Freenas won't do all the things I want it to do (questions to follow on that later!).

What I've tried so far:

I have tried writing the img file using dd - this was unsuccessful, as I kept getting an error message with the command

[cmd=]# sysctl kern.geom.debugflags=16[/cmd]

and therefore tried dd'ing without first doing that.  I then tried to use a CD to install onto the USB, which failed a number of times when I got to the "Creating Partitions using Disklabel" stage (inadequate space).  I then manually set partition sizes (1GB for /, 512M each for swap and /var and ~2G for /usr) which worked beautifully, but then the system wouldn't boot after the installation completed.  I rebooted (after changing boot priority to USB) and it simply had a "-" showing on a black screen.

I've now used Image Writer to write the img file to the USB, but how can you *fdisk* the disk the installation is running from (which it didn't - error message again)...

I apologise for asking such a stupid basic question, but I've tried google and I've tried the Handbook and I'm still stumped.  I'd really appreciate your help.

Thanks very much
Chris


----------



## wblock@ (Sep 21, 2011)

calgarychris said:
			
		

> can you run FreeBSD off of a USB stick?



Sure.  Of course it has to be a different drive than the installer.



> I then tried to use a CD to install onto the USB, which failed a number of times when I got to the "Creating Partitions using Disklabel" stage (inadequate space).



How big is the target drive?  On smallish drives, 8G or less, it works better to create a single filesystem.  Just / and swap.  FreeBSD 9's bsdinstall does that by default.



> it simply had a "-" showing on a black screen



Could be a boot loader incompatibility with that system, but try installing again with the single filesystem.


----------



## davidgurvich (Sep 21, 2011)

You can use qemu to create an appropriately sized image, install FreeBSD from iso to that image, and then use dd.  Remember to use labels for fstab to make things easier. OpenBSD liveusb is where I got the idea and that did work. 

I've had issues with the usb image that are solved by first clearing the usb drive.
`dd if=/dev/zero of=/dev/usb_drive bs=512 count=2`


----------



## calgarychris (Sep 22, 2011)

davidgurvich said:
			
		

> You can use qemu to create an appropriately sized image, install FreeBSD from iso to that image, and then use dd.  Remember to use labels for fstab to make things easier. OpenBSD liveusb is where I got the idea and that did work.
> 
> I've had issues with the usb image that are solved by first clearing the usb drive.
> `dd if=/dev/zero of=/dev/usb_drive bs=512 count=2`



Thanks - I've picked up a larger USB (16Gb) but it appears to have the same problem...It just hangs at bootup after installing from iso to the USB - at least with this installation it was okay to auto-select the disklabels.  Anyway, I will try dd'ing it one more time and re-installing, then I guess I'm going to give up for now - thanks for the suggestion above, but I'm afraid that's a bit too complicated for this guy.  I've got no idea what qemu is, why I would create an image or how to create labels for fstab.


----------



## calgarychris (Sep 22, 2011)

Oh dear.  I think I found the problem.  I won't know just yet, but I think it's an ID-10T error   Also known as a RTFM.  When I read the part about Boot Manager, I thought it was for booting multiple OSes, so I kept choosing "None".  I blame it on the fact that I've been reading about Debian, Ubuntu, Freenas and now FreeBSD so I've started skimming...

Thanks for your help all - we'll see how we go.


----------



## wblock@ (Sep 22, 2011)

calgarychris said:
			
		

> Oh dear.  I think I found the problem.  I won't know just yet, but I think it's an ID-10T error   Also known as a RTFM.  When I read the part about Boot Manager, I thought it was for booting multiple OSes



That's correct, it is.



> so I kept choosing "None".



That's the problem.  There has to be some kind of boot code in the MBR.  New, blank disks are, well, blank.  /boot/mbr is the boot manager, and /boot/mbr is the plain old MBR boot code.  boot0cfg(8) talks about it more, and there's an example using fdisk(8) to write the plain MBR boot code.


----------



## calgarychris (Sep 23, 2011)

wblock@ said:
			
		

> That's correct, it is.
> 
> 
> 
> That's the problem.  There has to be some kind of boot code in the MBR.  New, blank disks are, well, blank.  /boot/mbr is the boot manager, and /boot/mbr is the plain old MBR boot code.  boot0cfg(8) talks about it more, and there's an example using fdisk(8) to write the plain MBR boot code.



Thought I had it but it still gets stuck on "-" on bootup...I've specified an active slice, set up the boot mgr (STD), used the disk label part of sysinstall...any idea what I'm missing?


----------



## wblock@ (Sep 23, 2011)

First, a correction.  I meant to say above


> /boot/boot0 is the boot manager, and /boot/mbr is the plain old MBR boot code.



For why it's stopping on the boot loader... I don't know.  A browse through the BIOS is worthwhile.  "Legacy USB emulation" is sometimes a problem.  Some machines will take minutes at startup (waiting for a timeout?).  Identify your computer, and maybe someone will know of a specific cure for it.


----------



## zandro (Sep 23, 2011)

FreeBSD 8.2. Help. Does not recognize USB. To do.


----------



## calgarychris (Sep 23, 2011)

wblock@ said:
			
		

> First, a correction.  I meant to say above
> 
> 
> For why it's stopping on the boot loader... I don't know.  A browse through the BIOS is worthwhile.  "Legacy USB emulation" is sometimes a problem.  Some machines will take minutes at startup (waiting for a timeout?).  Identify your computer, and maybe someone will know of a specific cure for it.



I'm using the Asus E350M1-I Deluxe motherboard.  It's got to be something I'm doing incorrectly, because it boots Freenas from USB and it boots the USB that has the FreeBSD installation img.  Question - when I choose A during fdisk, it always creates three slices - the first to sector (segment, cylinder, not sure as I'm not in front of it atm) 63, the next with the lion's share and then a third segment that is "unused" that I can't delete.  Is this normal?  Also, at this point, do I set the big slice to active, or the little slice from 0-63?

Thanks
Chris


----------



## wblock@ (Sep 23, 2011)

There should only be one slice (and it should be active), but you might have unused space before or after.  Disk Setup On FreeBSD shows the underlying commands that sysinstall(8) is actually trying to do in the background.  You can do those before the install and assign mountpoints to the existing partitions.

However... have you tried the FreeBSD-9.0 install?  It uses gpart(8) internally.


----------



## calgarychris (Sep 24, 2011)

wblock@ said:
			
		

> There should only be one slice (and it should be active), but you might have unused space before or after.  Disk Setup On FreeBSD shows the underlying commands that sysinstall(8) is actually trying to do in the background.  You can do those before the install and assign mountpoints to the existing partitions.
> 
> However... have you tried the FreeBSD-9.0 install?  It uses gpart(8) internally.



I haven't tried FreeBSD-9.0 - I read the "disclaimer" saying it was for advanced users and that just scared me right off!

Happily I've managed to at least get the system to boot off of the USB - I went back into the installation and for some reason, the partition wasn't set to "active".  I know I did that, as that was one of the things I had changed but it wasn't active so I must have stuffed something up along the way.  Anyway, I'm now confronted with a daunting "$" after logging in.  Off to read some Handbook so I can figure out what I can do with this system!

Thanks for your help so far guys - I really appreciate the patience.  One of the reasons I chose FreeBSD over Debian was the way that the community was replying to complete noobs such as myself.

I won't lie, I'm sure I'll have more questions, but for the moment it's off to read!
Chris


----------

