[FreeBSD] USB Install - BSD

Users browsing this thread: 4 Guest(s)
yrmt
Grey Hair Nixers
USB Install or expert install.

After reading this thread you should know how to install FreeBSD to USB.

I run these commands on FreeBSD.

What you need :

- USB

- FreeBSD cd | FreeBSD iso | FreeBSD archives (ftp://ftp.freebsd.org/pub/FreeBSD/releases/)

\_ You need at least kernel.txz and base.txz.

\_ How to find the packages in FreeBSD iso/cd ?
It's in $CD/usr/freebsd-dist/

- Plug in you USB key, a quick look at /var/log/messages should show something like this: (you can use `tail -f /var/log/messages)

PHP Code:
Jun  8 20:33:30 home kernelugen4.2: <USBat usbus4
Jun  8 20
:33:30 home kernelumass0: <USB Flash Disk, class 0/0rev 2.00/11.00addr 2on usbus4
Jun  8 20
:33:30 home kernelumass0:  SCSI over Bulk-Onlyquirks 0x4000
Jun  8 20
:33:30 home kernelumass0:4:0:-1Attached to scbus4
Jun  8 20
:33:30 home kernelda0 at umass-sim0 bus 0 scbus4 target 0 lun 0
Jun  8 20
:33:30 home kernelda0: <USB Flash Disk 1100Removable Direct Access SCSI-0 device 
Jun  8 20
:33:30 home kernelda040.000MB/s transfers
Jun  8 20
:33:30 home kernelda07648MB (15663104 512 byte sectors255H 63S/T 974C

- Erase the disk with dd, this should take a few minutes.
\_ dd if=/dev/zero of=/dev/da0 count=560 bs=2m

- Create the geom and partitions:
\_gpart create -s gpt da0 # Create the geom.
\_gpart add -s 64K -t freebsd-boot da0 # add the bot partition, 64K should be enough.
\_gpart add -s 100M -t freebsd-swap -l swap0 da0 # add the swap partition. I recommend 5-10% of the disk size.
\_gpart add -t freebsd-ufs -l disk0 da0 # add the root ufs partition. it will use all the space left.
\_newfs -UJt -L freebsdusb /dev/da0p3 # enabling soft-updates and journaling. You can use -t if you want trim (ssd).

- Verify everything is correct
\_gpart show da0
PHP Code:
=>      34  15663037  da0  GPT  (7.5G)
        
34       128    1  freebsd-boot  (64k)
       
162    204800    2  freebsd-swap  (100M)
    
204962  15458109    3  freebsd-ufs  (7.4G

- Mount the root partition
\_mount /dev/da0p3 /mnt/usb

- Extract at least kernel.txz and base.txz in / on your usb, ilke this:
\_ cd /mnt/usb/
\_ tar -xf $packagespath/kernel.txz; tar -xf $packagespath/base.txz


- Add the bootcode to your usb installation:
\_gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 da0

- Edit the fstab in /mnt/usb/etc/fstab, add:
\_
PHP Code:
/dev/da0p3       /                       ufs              rw,async            1            1
     
/dev/da0p2       none                     swap              sw                  0            0 

- You can now boot with the USB key to try !

- If you get errors like "permission denied" when running as root, run this:
\_sysctl kern.geom.debugflags=16
FreeBSD
Long time nixers
Thank you was wondering about this sort of thing!
I do Byte
yrmt
Grey Hair Nixers
very relevant for ArchBSD.
zygotb
Long time nixers
Is this a persistent installation to USB?
Someone doesn't appreciate my php generated image!
yrmt
Grey Hair Nixers
yep, but you can use that to install yo anything
zygotb
Long time nixers
(30-12-2012, 05:10 AM)Beastie Wrote: yep, but you can use that to install yo anything

I just tried it, minus the extracting files from CD (I have none,) and it setup my USB drive perfectly!
The only caveat was that I had no /mnt/usb directory, as I've named my USB mount dir a different name. Not really an issue though.

Then, to add insult to injury, I didn't have a FreeBSD ISO that I wanted to write to the USB device, so I tried writing a slax memstick image to the USB, but the slax memstick image isn't like most normal .iso files I'm used to...
slax-English-US-7.0.2-i486.zip is more geared towards Windoze & *buntu users, and wouldn't write to my USB drive, probably because of the partition layout created above.

My advice; if you want to try slax on a USB flash drive, use the CD .iso instead of the memstick .iso.
It's not that hard to dd an .iso to the proper location, but the slax bootinst.sh script assumes that one is a moron who uses mainstream operating systems, and so turns the process into more work than it should be.

Thanks again for the guide Beastie!



Well, my slax endeavor failed, for some reason, but in the meantime, I've found some interesting information about Flash dirves and NAND FLASH storage.
Since it's an involved subject, here's a link.
(it's not the first time I've dealt with bootable USB drives and writing .iso/.img files to said removable media.)

I downloaded slax from here, but don't see any signature, or hash, to verify the integrity of the downloaded file.
I tried both versions of the English-US file for my arch (i486) and neither download included any md5sum, etc.
The failure to provide any means of verification of the downloaded files causes me to lose faith in the rest of the system.

I'll be sticking with FreeBSD from here on out. :)



I found some more good info on USB flash drives & FreeBSD here.
Someone doesn't appreciate my php generated image!