bootable FreeBSD on USB-Flash-Drive [SOLUTION]

Grossmann Martin grossmann at connectit.at
Fri Mar 31 18:44:11 UTC 2006


a little success story with freebsd and a tiny usb stick:
[tried with FreeBSD 6.1-BETA4 install-cd and a kingston 256MB
usb-flash-drive]

prepare yourself to work on the command-line ;-)
- attach the usb-stick to the server
- boot the freebsd installation cd-rom
- go to the "fixit" shell
- CHECK YOUR DMESG WHAT DEVICE YOUR USB STICK ACTUALLY IS!!! (here /dev/da0)

create the future "/"-filesystem on your usb-drive:

wipe everything on the usb-drive:
# dd if=/dev/zero of=/dev/da0 bs=1m
create a new partition table on it with a default slice 1 and make it
bootable
# fdisk -BI /dev/da0
label it for booting freebsd:
# bsdlabel -wB /dev/da0s1
you'll have to edit the disklabel (sometimes you'll have to: # export
EDITOR=/mnt2/usr/bin/vi):
# bsdlabel -e /dev/da0s1
... and change partition a from "unused" to "4.2BSD" as partition type
create the future "/" a.k.a. root-filesystem on it:
# newfs -m 0 -o space /dev/da0s1a

mount the filesystem for installation:
# mount /dev/da0s1a /mnt

install freebsd on /mnt:
# export DESTDIR=/mnt
# cd /dist/<RELEASENAMEHERE>
# for i in base manpages catpages
# do
#   cd $i; echo y|./install.sh; cd ..;
# done

go to the kernels directory and install a kernel of your choice:
[default is GENERIC kernel; change to "smp" for smp-machines]
# rmdir /mnt/boot/kernel
# cd kernels;
# cat generic.??|tar --unlink -xpzf - -C /mnt/boot
# cd /mnt/boot && mv GENERIC kernel

now, tell freebsd to mount the right root-filesystem:
# echo "/dev/da0  /  ufs  rw,noatime  1  1" >/mnt/etc/fstab

create your rc.conf.local in /mnt/etc to redefine some settings:
# cat <<EOFRCCONF >/mnt/etc/rc.conf.local
#!/bin/sh
tmpmfs="YES"
tmpsize="128m"
varmfs="YES"
varsize="128m"
populate_var="YES"
hostname="daisy.duck.home"
keyrate="fast"
EOFRCCONF

# chmod 0755 /mnt/etc/rc.conf.local

set a new root password manually, if you want (default="")
# chroot /mnt /usr/bin/passwd root

well, there are many other things you could do like configuring
hosts, networks, dns, users, add. filesystems, etc... but this
is another stuff!

cu & have fun!

ps: just reply to the list for comments/flames, i'm on it ;-)
pps: thx 2 the installer team for keeping things simple and easy!



More information about the freebsd-questions mailing list