Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Mar 2008 11:37:58 -0500
From:      Walker <zflyer@gmail.com>
To:        jhall@vandaliamo.net, freebsd-questions@freebsd.org
Subject:   Re: Booting from Memory Stick
Message-ID:  <6293ba970803020837s40797f5eqfe72303e6ea5126b@mail.gmail.com>
In-Reply-To: <49540.65.117.48.155.1204406604.squirrel@admintool.trueband.net>
References:  <49540.65.117.48.155.1204406604.squirrel@admintool.trueband.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Mar 1, 2008 at 4:23 PM,  <jhall@vandaliamo.net> wrote:
> I am working on getting a FreeBSD system to boot from a USB memory stick.

FWIW, my cut/paste script for installing 7.0 to a USB flash drive.
This is adapted from a post by Ceri Davies (thank you!).

** This assumes the drive is at /dev/da0 and that /dev/md0 is not in use **

# set these; the two mount points should not exist
export ISOFILE='/tmp/7.0-RELEASE-i386-disc1.iso'
export ISOMNT='/a'
export USBMNT='/b'

# zero the device for better compression when were done (optional)
dd bs=10m if=/dev/zero of=/dev/da0

# mdconfig and mount the media
mkdir -m 555 ${ISOMNT} ${USBMNT}
mdconfig -a -t vnode -u 0 -f ${ISOFILE}
mount -t cd9660 /dev/md0 ${ISOMNT}

# label and newfs the flash drive
fdisk -BI /dev/da0
bsdlabel -B -w da0s1
newfs -U -L FBSDusb /dev/da0s1a
mount /dev/da0s1a ${USBMNT}

# install the OS
cd ${ISOMNT}/*RELEASE/base
DESTDIR=${USBMNT} ./install.sh

# install the generic kernel
cd ${ISOMNT}/*RELEASE/kernels
DESTDIR=${USBMNT} ./install.sh generic
rmdir ${USBMNT}/boot/kernel
mv ${USBMNT}/boot/GENERIC ${USBMNT}/boot/kernel

# set boot0 options
boot0cfg -v -B -o noupdate -t 90 da0

# install a fstab; adjust as needed (like /tmp size)
cat >> ${USBMNT}/etc/fstab << EOF
# Device Mountpoint FStype Options Dump Pass
/dev/ufs/FBSDusb / ufs rw,noatime 1 1
md /tmp mfs rw,-s150M,nosuid,noatime 0 0
md /var/run mfs rw,-s4M,nosuid,noatime 0 0
md /var/log mfs rw,-s16M,nosuid,noatime 0 0
/dev/acd0 /cdrom cd9660 ro,noauto,nosuid 0 0
/proc /proc procfs rw,noauto 0 0
/tmp /var/tmp nullfs rw 0 0
EOF

# install an rc.conf
cat >> ${USBMNT}/etc/rc.conf << EOF
ifconfig_DEFAULT="DHCP"
ifconfig_fwe0="NOAUTO"
ifconfig_plip0="NOAUTO"
sshd_enable="YES"
syslogd_flags="-vv"
sendmail_enable="NONE"
EOF

# set root password and timezone (optionally add users here as well)
chroot ${USBMNT} /bin/sh
passwd root
tzsetup

# clean up
cd /
umount ${ISOMNT} ${USBMNT}
rmdir ${ISOMNT} ${USBMNT}
mdconfig -d -u 0

# backup and compress (~ 84MB) (optional)
dd bs=10m if=/dev/da0 of=usbflash-freebsd_7.0.img
nice bzip2 usbflash-freebsd_7.0.img

# done



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6293ba970803020837s40797f5eqfe72303e6ea5126b>