This project is not endorsed or supported by NetBSD or the NetBSD Foundation
[Get NetBSD Icon]

Get NetBSD

Download NetBSD now from one of the mirrors, or obtain a copy on CD.

How to install NetBSD on an USB Memory Stick

This describes how to install NetBSD on a Memory Stick. I took most of the information used for the partitioning section from here: http://wiki.netbsd.se/index.php/How_to_install_NetBSD_from_an_USB_Memory_Stick

I found it helped a lot!

Hardware I used
Make the NetBSD Memory Stick
Clean the Memory Stick

Access the memory stick and remove any pre-existing partition slices

# disklabel -i -I sd0

All currently existing partitions can be displayed issuing the command:

partition>P (RETURN)

Each partition can then be removed as follows (partition a is removed in this example):

partition>a (RETURN)
Filesystem type [?] [MSDOS]:unused (RETURN)
Start offset ('x' to start after partition 'x') [0c, 0s, 0M]:0 (RETURN)
Partition size ('$' for all remaining) [973.999c, 997375s, 487M]:0 (RETURN)

When finished removing each partition do the following:

partition>W (RETURN)
Label disk [n]:y (RETURN)
partition>Q (RETURN)
Install the Master Boot Record (MBR):
# fdisk -i /dev/rsd0d
Update the bootcode from /usr/mdec/mbr? [n]y (RETURN)
Should we write new partition table? [n]y (RETURN)
Create an fdisk partition for NetBSD:
# fdisk -u /dev/rsd0d
Do you want to change our idea of what BIOS thinks? [n]n (RETURN)
Remove existing fdisk partitions

For each partition do the following:

Which partition do you want to change?: [none]0 (RETURN)
The data for partition 0 is:
Primary DOS with 32 bit FAT (sysid 11)
start 8, size 997367 (487 MB, Cyls 0-973/127/8)
sysid: [0..255 default: 11]0 (RETURN)
Create the fdisk entry

Create the needed BSD partition:

Which partition do you want to change?: [none]0 (RETURN)
sysid: [0..255 default: 11]169 (RETURN)
start: [0..125cyl default: 63, 0cyl, 0MB](RETURN)
size: [0..125cyl default: 2015169, 125cyl, 984MB](RETURN)
bootmenu: [](RETURN)
Bootselector disabled.
Which partition do you want to change?: [none](RETURN)
We haven't written the MBR back to disk yet. This is your last chance.
Partition table:
0: NetBSD (sysid 169)
[..]
Bootselector disabled.
Should we write new partition table? [n]y (RETURN)
Set the NetBSD partition active (it's partition Number 0)
# fdisk -a /dev/rsd0d
Do you want to change the active partition? [n]y (RETURN)
Choosing 4 will make no partition active.
active partition: [0..4 default: 4]0 (RETURN)
Are you happy with this choice? [n]y (RETURN)
Should we write new partition table? [n]y (RETURN)
Create the NetBSD disklabel with partition a
# disklabel -i -I sd0
partition>a (RETURN)
Filesystem type [?] [unused]:4.2BSD (RETURN)
Start offset ('x' to start after partition 'x') [0.0078125c, 8s, 0.00390625M]:(RETURN)
Partition size ('$' for all remaining) [973.991c, 997367s, 486.996M]:$ (RETURN)
partition>W (RETURN)
Label disk [n]?y (RETURN)
Label written

diskabel may ask you to write the MBR:

We haven't written the MBR back to disk yet. This is your last chance.
Should we write new partition table? [n]y (RETURN)

Finish with:

partition>Q (RETURN)
Create a new NetBSD filesystem on partition sd0a
# newfs /dev/rsd0a
Please read the newfs.8 manual to optimize your file system. I assume NetBSD is made of "small" files so I used -b 4096 because this gives you better performances with writing/reading small files. I also used -o time to optimize the time spent allocating blocks (as opposed to minimize the space fragmentation on the disk). I don't know if this argument is any useful in this case though.
Make the root partition bootable
# mount /dev/sd0a /mnt
# cp /usr/mdec/boot /mnt
# installboot -v -o timeout=5 /dev/rsd0a /usr/mdec/bootxx_ffsv1
If the system tells you that the OLD BPB is too big, force the bootstrap installation by passing the -f flag to installboot
Build a custom kernel

The NetBSD kernel will need to know where to find the root device (sd0). You need to create a new kernel config. Comment the line that reads:

config netbsd root on ? type ?

And uncomment the one that reads:

config netbsd root on sd0a type ffs

Note: You may want to build a light kernel.

You then build the new kernel, gzip it and copy it to / on your memory stick. Help to build kernel: http://www.netbsd.org/docs/kernel/#how_to_build_a_kernel

Install Sets

You now have to untar the sets. Get them from a NetBSD FTP server, from an iso image or build them using /usr/src/build.sh

Minimal sets needed are base.tgz and etc.tgz

# tar xfzp base.tgz -C /mnt
# tar xfzp etc.tgz -C /mnt
Make Devices

You now have to create the devices or NetBSD will mount an MFS (Memory File System) filesystem containing a basic /dev directory which doesn't allow more than one tty and no pty at all (used by screen for instance)

# cd /mnt/dev
# sh MAKEDEV all
Configuration

Edit /etc/fstab and add a line concerning sd0a:

/dev/sd0a / ffs rw 1 1
You can also speed up file create/delete operations according to mount.8 using softdep. If you want to do so, change rw to rw,softdep.
Please read the manual to make sure you know what this option is as it can be really dangereous.

Edit /etc/rc.conf and change rc_configured from 'NO' to 'YES.

Enable multiple ttys (optional)

By default NetBSD gives you one console. If you want three other ttys:

Edit /etc/rc.conf and add

wscons=YES

Edit /etc/wscons.conf and make sure screen 1 to 3 are not commented:
screen 1 - vt100
screen 2 - vt100
screen 3 - vt100

Edit /etc/ttys and switch the status of ttyE1, ttyE2 and ttyE3 to on. That will load getty on those ttys:
ttyE1 "/usr/libexec/getty Pc" vt220 on secure
ttyE2 "/usr/libexec/getty Pc" vt220 on secure
ttyE3 "/usr/libexec/getty Pc" vt220 on secure
Booting the Memory Stick

On my laptop I can choose USB Hard Disk in the boot order of the BIOS or press F9 on boot to show the available drives menu.

Valid XHTML 1.0 Strict Valid CSS!