I've seen different methods of doing this, many using dump and restore. This method uses rsync.
At work, we will use this after customizing an install, especially if we think it's something we'll be wanting to use again in the near future. It speeds things up. We tend to just use one large / partition, depending upon use.
Once you have your FreeBSD system installed, insert the USB. For purposes of this article, let's say it shows up as da1. First zero it out.
dd if=/dev/zero of=/dev/da1 bs=1m count=25 |
Use fdisk to create the slice. You'll get back an error of invalid fdisk partition found, which can be ignored.
fdisk -I /dev/da1 |
You should now have a /dev/da1s1. Use bsdlabel to create a standard layout. The second bsdlabel command with the -B makes it bootable. Whether it was a typo or not, when I used -w -B it didn't work properly. I then used two separate commands and it did, and I keep forgetting to test it again, so I just use two commands.
bsdlabel -w /dev/da1s1 auto bsdlabel -B /dev/da1s1 |
We'll create a UFS filesystem that we'll call USBROOT. We should now have /dev/da1s1a.
newfs -U -L USBROOT /dev/da1s1a |
Mount the device and let's copy over the existing system.
mount /dev/da1s1a /mnt cd / rsync -aHv --exclude /mnt * /mnt |
This will take awhile. Once it's complete, edit the USB's /etc/fstab so that it will boot on any system.
/dev/ufs/USBROOT / ufs rw 1 1 |
Once this is done, umount the USB and reboot from it. It should boot up a system that matches the system you used to create it.