Everything you want to know about
Installing FreeBSD on a USB stick.
Chapter One
Installing FreeBSD on a USB stick.
Chapter One
In Release 8.0 the sysinstall process had a major overhaul as well as the kernels USB handling. So this document assumes the reader will be using a 8.0 or newer system when trying things described here.
To get everyone on the same page with terminology USB memory stick, flash drive, key, stick, and pen all mean the same thing. I will be using USB stick in this article.
Flash Memory Technology:
The memory chip, with the controller chip, is the most important element of a memory card. The memory chip is based on the flash memory technology which is solid-state, non-volatile and rewritable. Solid-State means it contains no moving parts and therefore is immune to mechanical failures and damages from movements and vibrations. It also operates completely silent with a zero decibel noise level. Non-Volatile flash memory stores bits of information in memory cells made of silicon wafers which do not require power to retain information when power is turned off.
In general flash memory functions like RAM memory and a hard disk drive combined. It stores digital data in memory cells like the RAM memory, and stores information like a hard disk drive when the power is turned off. In comparison to other storage media flash memory offers superior features such small form factor, high degree of durability, high degree of reliability, low power consumption and high transfer speed. Based on that flash memory technology is ideal for use in USB sticks. The only disadvantage is the manufacturing cost, which is higher compared to hard disk drives, CDs and DVDs.
There are two different technologies of flash memory, NOR and NAND. NAND flash memory is ideal for memory cards because is less expensive and can accommodate more storage capacity in the same die size. Memory card manufactures are using different NAND technologies for either boasting the memory cards performance or for decreasing the memory cards manufacturing costs. The most common flash memory technologies are the Single-Level Cell, Multi-Level Cell, Multi-Bit Cell and Chip Stacking. The Single-Level Cell technology is used to boast the memory cards performance while the rest are used for decreasing manufacturing costs. The most used technology of them all is the Multi-Level Cell.
A Single-Level Cell, SLC, memory card stores one bit in each cell, leading to faster transfer speeds, lower power consumption and higher cell endurance. The only disadvantage of Single-Level Cell is the manufacturing cost per MB. Based on that, the SLC flash technology is used in high-performance memory cards.
A Multi-Level Cell, MLC, memory card stores three or more bits in each cell. By storing more bits per cell, a Multi-Level Cell memory card will achieve slower transfer speeds, higher power consumption and lower cell endurance than a Single-Level Cell memory card. The advantage of Multi-Level Cell memory card is the lower manufacturing costs. The MLC flash technology is used mostly in standard memory cards. The Multi-Bit Cell, MBC, is a similar technology to the Multi-Level Cell but stores only two bits per cell.
Chip stacking technology is used by many manufactures to double the memory cards capacity at considerable lower manufacturing costs. This is achieved by putting two chips together to form a single chip. For example, by stacking two 256 MB chips together they will form a single 512 MB chip. This technology is far less expensive alternative to the single-die chips or even called monolithic chips.
USB sticks are most commonly manufactured using MLC (multi-level cell) or SLC (single-level cell) technology. MLC is a lot less expensive to manufacture, but is a lot slower than SLC. MLC have ‘write’ lifetimes in the 10,000 to 100,000 range.
SLC is a bit more expensive, but is very fast, and has ‘write’ lifetimes in the 100,000-millions range.
Which chip used in the manufacture of the USB stick is the most important thing that affects throughput and longevity.
What really sucks, is how hard it is to find out which type of chips are used in the USB stick before purchasing it. Some USB sticks come packaged with the vendors website listed. Check out their website looking for email address for tech support or sales dept. Email them and ask what chip type is used in the model of USB stick you are interested in purchasing.
Another point of interest is does your PC BIOS have option to boot from USB stick or even if the BIOS will recognize the USB stick media as bootable? This is a motherboard BIOS problem not un-common for PCs manufactured before 2008. Testing different vendor USB sticks on your PC maybe the only way to find one that will boot. Size as 2GB, 4GB, 8GB, what ever has no baring on this BIOS problem. Using a USB stick for storage only has never been a problem.
Installing FreeBSD on a USB stick to create a bootable USB stick is a lot of work just to test if the USB stick is recognized by your PC BIOS. A quick way is to dd an floppy image to your USB stick and try booting that.
Here are some commands that will help:
Code:
dd if=/dev/da0 count=2 | od -c to display the USB stick MBR
dd if=/dev/zero of=/dev/da0 count=2 to zero out the USB stick MBR
dd if=/path/floppy.img of=/dev/da0 to write the floppy bootable image
Download the floppy.img from http://www.daemonforums.org/attachment.php?attachmentid=300&d=1267845079
You may have to click the link a second time to get the save download box. Once you have it downloaded, rename it removing the .zip suffix.
Another way to do the same thing.
Use this windows image writer to write the bootable floppy.img file to the USB stick. You can download your own copy from:
https://launchpad.net/win32-image-writer/+download
The objective is to purchase a USB stick containing SLC (single-level chip) then you have no need to take special effort to limit writes like you would have to using a USB stick containing MLC (multi-level chip).
The 6 Types of USB stick Installs.
1. Putting the disc1.iso on a USB stick so it can be used to install FreeBSD on a target in the same way it’s commonly done from the disc1.iso burned to CD. In this usage the USB stick using MLC or SLC makes no difference as after the original writes to population it, there are only reads from that point on. Assuming you don't have any SCSI disks occupying the dax device range or USB external hard drive your USB stick will show up on /dev/da0.
The following fbsdiso2usb script will do this for you.
Code:
#!/bin/sh
# Purpose = Use to transfer the FreeBSD install disc1.iso files to
# a bootable USB stick drive so it can be used to install from.
# First fetch the FreeBSD 8.0-RELEASE-i386-disc1.iso to your
# hard drive /usr. Then execute this script from the command line
# fbsdiso2usb
# NOTE: This script has to be run from root and your USB stick drive
# has to be plugged in before running this script.
echo ' '
echo '****** Prepare disc1.iso for usage'
echo ' '
cd /usr
mkdir dis
mdconfig -a -f /usr/8.0-RELEASE-i386-disc1.iso md0
mount -v -t cd9660 /dev/md0 /usr/dis
echo ' '
echo '****** Prepare target usb stick'
echo ' '
dd if=/dev/zero of=/dev/da0 count=2
fdisk -vBI /dev/da0
bsdlabel -B -w da0s1
newfs -O 1 /dev/da0s1a
mount -v /dev/da0s1a /mnt
echo ' '
echo ' '
echo '****** Copy all the disc1.iso files onto the usb stick'
cd /usr/dis
find . -print -depth | cpio -dump /mnt
echo ' '
echo 'Finished do clean up now'
cd /usr
umount -v /mnt
umount -v /usr/dis
mdconfig -d -u md0
rmdir dis
echo ' '
echo ' '
echo "### Script finished ###"
2. With Release 8.0 an new USB stick livefs/sysinstall image is released. This memstick.img file is three times larger than the disc1.iso. It’s intended you dd this image to your USB stick. You can use it in fixit mode (it’s a complete running system) or in sysinstall mode. In this usage the USB stick using MLC or SLC makes no difference as after the original writes to population it, there are only reads from that point on. Assuming you don’t have any SCSI disks occupying the dax device range or USB external hard drive your USB stick will show up on /dev/da0.
Use this command:
Code:
dd if=8.0-RELEASE-i386-memstick.img of=/dev/da0 bs=10240
3. Installing FreeBSD on a USB stick containing SLC (single-level chip) from a CD burned from the disc1.iso results in a complete base release system which you can configure the way you like and install ports depending on the GB size of your USB stick. Assuming you don't have any SCSI disks occupying the dax device range or USB external hard drive your USB stick will show up on /dev/da0.
Last edited by a moderator: