8.1 memstick installation

Morgan Wesström freebsd-questions at pp.dyndns.biz
Sun Sep 12 16:52:40 UTC 2010


> 2010/8/23 Morgan Wesström<freebsd-questions at pp.dyndns.biz>:
>> On 2010-08-23 19:34, Friedemann Becker wrote:
>>> Hello,
>>>
>>> I have some questions about an installation on a memorystick.
>>>
>>> I have (a few weeks still) a very poor internet connection at home
>>> that's unusable for anything beyond email. I tried some hacking on
>>> musescore (yes I know that it can't work, but that's not my problem
>>> for now). Since I don't want to carry missing ports/packages/other
>>> stuff around on a stick everytime I miss something - which takes one
>>> day each - i would like to have a working system (not installation
>>> image) on usb-stick.
>>> Can i use fdimage with the memorystick installation image on windows,
>>> or any hacked versions of it?
>>> And how do turn this stick in a running system?
>>> Or is there any kind of live-stick-images out there, and if it is, how
>>> to move these on the stick (since windows is missing dd and nero
>>> doesn't like burning sticks :-) )
>>>
>>> Thanks in advance
>>>
>>
>> Check my old message on how to do this in FreeBSD 7.2. The same
>> instructions should work for 8.1 too, just change the version references.
>> http://lists.freebsd.org/pipermail/freebsd-questions/2009-July/201928.html
>> /Morgan
>>
On 2010-08-26 13:52, Friedemann Becker wrote:
> Thanks a lot,
> this seems to work. Is there any chance to get this into the faq or
> handbook? It's seems way more usefull to me than a live-CD. Best thing
> would be putting it into sysinstall, but maybe this is not reallistic.
>
> Best regards,
> Friedemann
>

For the archives - below I've updated my installation guide to work with 
FreeBSD 8.1-RELEASE, GPT and ZFS if anyone finds it useful.

Make sure your usb memory stick is empty and unpartitioned, then plug it 
in and boot from the FreeBSD DVD.

Select your country and keyboard layout.

Enter the Fixit environment and use the live filesystem on your DVD.

Your usb memory stick will most likely be da0 but you can (and should) 
check it with "camcontrol devlist" before you continue.

Create a new GPT partitioning scheme:
  # gpart create -s gpt da0

Create a 64KiB partition for the zfs bootcode starting at LBA 1920:
  # gpart add -b 1920 -s 128 -t freebsd-boot da0

Create a zfs partition spanning the remainder of the usb memory stick 
and give it a label we can refer to:
  # gpart add -t freebsd-zfs -l FreeBSDonUSB da0

(The starting LBA for the first partition is there to align the 
partitions to the flash memory's erase block size. This is particularly 
important for the main zfs partition. The main partition above will 
start at exactly 1MiB (LBA 2048) which will align it to any erase block 
size used today. This alignment is also of great importance if you use 
this guide to install FreeBSD to one of the newer harddrives using 4096 
byte sectors.)

Install the protective MBR to LBA 0 and the zfs bootcode to the first 
partition:
  # gpart bootcode -b /dist/boot/pmbr -p /dist/boot/gptzfsboot -i 1 da0

Create /boot/zfs (for zpool.cache) and load the zfs kernel modules:
  # mkdir /boot/zfs
  # kldload /dist/boot/kernel/opensolaris.ko
  # kldload /dist/boot/kernel/zfs.ko

Create a zfs pool and set its bootfs property:
  # zpool create zrootusb /dev/gpt/FreeBSDonUSB
  # zpool set bootfs=zrootusb zrootusb

Switch to fletcher4 checksums and turn off access time modifications:
  # zfs set checksum=fletcher4 zrootusb
  # zfs set atime=off zrootusb

Extract at a minimum, base and the generic kernel:
  # cd /dist/8.1-RELEASE/base
  # DESTDIR=/zrootusb ./install.sh
  # cd ../kernels
  # DESTDIR=/zrootusb ./install.sh generic

Delete the empty, default kernel directory and move the generic kernel 
into its place:
  # rmdir /zrootusb/boot/kernel
  # mv /zrootusb/boot/GENERIC /zrootusb/boot/kernel

Make sure the zfs modules are loaded at boot:
  # echo 'zfs_load="YES"' > /zrootusb/boot/loader.conf
  # echo 'vfs.root.mountfrom="zfs:zrootusb"' >> \
     /zrootusb/boot/loader.conf

Create /etc/rc.conf. Adjust and add to your own needs:
  # echo 'ifconfig_DEFAULT="DHCP"' > /zrootusb/etc/rc.conf
  # echo 'hostname="freebsd"' >> /zrootusb/etc/rc.conf
  # echo 'keymap="swedish.iso"' >> /zrootusb/etc/rc.conf
  # echo 'ntpdate_enable="YES"' >> /zrootusb/etc/rc.conf
  # echo 'sshd_enable="YES"' >> /zrootusb/etc/rc.conf
  # echo 'zfs_enable="YES"' >> /zrootusb/etc/rc.conf

Setup your time zone:
  # cp /zrootusb/usr/share/zoneinfo/Europe/Stockholm \
     /zrootusb/etc/localtime

Create an empty fstab to avoid startup warnings:
  # touch /zrootusb/etc/fstab

Set the root password in the new environment:
  # cd
  # chroot /zrootusb /bin/sh
  # passwd root
  # exit

Copy zpool.cache:
  # cp /boot/zfs/zpool.cache /zrootusb/boot/zfs

Unmount the filesystem and set its mountpoint:
  # zfs unmount -a
  # zfs set mountpoint=legacy zrootusb

Exit SYSINSTALL and reboot. You now have a fully functional and bootable 
FreeBSD installation on your usb memory stick.


Regards
Morgan Wesström


More information about the freebsd-questions mailing list