1: In this article I will explain, step by step, how to install a NetBSD server with a root LFS partition.
9: Since LFS is considered experimental, it is highly advised to test this setup on a testbed / Virtual Machine. Use at your own risk.
11: In this setup, the server will solely run under LFS without any FFS partitions.
13: There are a lot of ways to accomplish this task. This is how I do it.
14: #What is LFS
16: LFS is an implementation of a [log-structured file system](http://en.wikipedia.org/wiki/Log-structured_File_System_%28BSD%29).
18: For example [Sun's ZFS](http://en.wikipedia.org/wiki/ZFS) is a log-structured file system.
19: #What are the advantages
21: LFS can recover faster from a crash, because it does not need to fsck the whole disk. It is faster than FFS.
22: #What are the disadvantages
24: It has never worked reliably.
25: It is limited to 2 Terabytes.
26: It does not perform very well at constant high disk activity like ftp uploads/downloads.
27: It can't handle situations where the disc is almost full, i.e. it usually crashes requiring a newfs, though most data can be recovered manually.
29: #How do we aproach
31: We need to install a NetBSD system from scratch without sysinst, since sysinst is lacking LFS support at the moment. This may change in the future.
34: Physical access to the server.
36: We need a NetBSD [liveCD](http://www.jibbed.org/) to access the hard disks. Only liveCDs with LFS support compiled in will work. Therefore please download the Jibbed LiveCD from <http://www.jibbed.org>.
38: We will also need the NetBSD sets (base.tgz, comp.tgz, etc.tgz, man.tgz, misc.tgz, text.tgz ...). It is recommended to download all sets.
40: You can either download the latest sets from the NetBSD autobuild cluster (<ftp://ftp.netbsd.org/pub/NetBSD-daily/HEAD/>) or you can build your own release and use your own sets. I recommend to use the latest NetBSD sources.
42: A tutorial on how to build current can be found here: [[How to build NetBSD-current]].
44: The sets have to be accessible from the liveCD in some way. For example via http, ftp or scp.
46: #Booting from the liveCD
48: Please boot into the liveCD on the server you want to install.
50: Gain root privileges (su -).
53: Use fdisk to create an active NetBSD (ID 169) partition.
55: # fdisk -iu wd0
59: Use disklabel to prepare your disk. This part of the tutorial is with purpose not very detailed. You should get comfortable with disklabel beforehand.
63: # disklabel -i -I wd0
65: on the command line to enter the interactive disklabel menu. I am assuming you are using wd0. Otherwise substitute with your drive (sd0, ld0...)
67: We will create one big "a" partition in this example. Feel free to try another setup in your second try.
69: In disklabel create one big partition "a" spanning the whole disk starting from sector 63 (63s) until the end minus the space you want to give to the swap partition.
71: Use 4.4LFS as your file system.
73: Partition b is used as swap. Start from the end of partition a until the end ($).
75: Partition c and d are the disks itself and should be of type **unused** starting from 0 to the end.
77: Remove all other partitions (e-p).
79: When you are finished your label should look like this:
81: # size offset fstype [fsize bsize cpg/sgs]
82: a: 73400320 63 4.4LFS 0 0 0 # (Cyl. 0*- 72817*)
83: b: 2097152 73400383 swap # (Cyl. 72817*- 77504*)
84: c: 78124937 63 unused 0 0 # (Cyl. 0*- 77504*)
85: d: 78125000 0 unused 0 0 # (Cyl. 0 - 77504*)
87: Label the disk (N), Write changes to disk (W), and quit (Q).
90: You can now create the LFS filesystem on the disk you just labeled.
92: # newfs_lfs wd0a
94: There are more options like -A and different segment and frag sizes. But we will stick to the default 1M segment size, since other values may get LFS unstable.
97: The rest is trivial. We mount the filesystem and extract our sets.
99: # mkdir /tmp/targetroot
100: # mount /dev/wd0a /tmp/targetroot
102: Create another directory to store the sets in.
104: # mkdir /tmp/sets
106: Change in that directory
108: # cd /tmp/sets
110: And download your sets, for example via ftp. This are the sets you have prepared upfront by either compiling a release or downloading them from the autobuild cluster.
112: # ftp 192.168.0.200
115: #extracting the sets
117: extract your sets using option -p (important).
119: # cd /tmp/sets
120: # tar xvzpf base.tgz -C /tmp/targetroot
122: repeat with all your sets, but extract only one GENERIC kernel named kern-GENERIC.tgz
123: #configure the new system
125: change into /tmp/targetroot and do a base configuration. Edit etc/fstab
127: /dev/wd0a / lfs rw 1 1
128: /dev/wd0b none swap sw 0 0
129: ptyfs /dev/pts ptyfs rw 0 0
130: tmpfs /tmp tmpfs rw
132: ptyfs and tmpfs are optional, but recommended.
134: Edit etc/rc.conf
140: Copy boot to the targetroot.
142: # cp /tmp/targetroot/usr/mdec/boot /tmp/targetroot
144: And bootstrap
146: # /usr/sbin/installboot -v -m i386 -o timeout=5,console=pc /dev/rwd0a /tmp/targetroot/usr/mdec/bootxx_lfsv2
148: #creating devices
150: Don't forget to create all devices.
152: # cd /tmp/targetroot/dev
153: # ./MAKEDEV all
155: this may take a while.
158: That's it. Sync and reboot.
160: # sync
161: # sync
162: # sync
163: # reboot
165: If everything went well, your system should boot. Once you have logged in, you can configure your system and do all the fine tuning.
166: #Disk capacity
168: You should not fill up your LFS partition over 75%. This could damage the file system (at the moment).
169: #Remote installation
171: If you want to install an LFS root file system on your server in your data center remotely, console access is beneficial, but not necessary. The minimum requirement is a rescue console. This is mostly a linux ramdisk. One way is to build a custom boot floppy including LFS and newfs_lfs. Because newfs_lfs does not fit on the disk, you have to exclude unnecessary tools. Then write a small shell script that is executed when you boot the floppy, summing up all steps in the tutorial including adding a user account and setting up ifconfig, resolv.conf, default gateway, to be able to log in afterwards. Make a backup of the first 5 MB you are going to overwrite with dd. Now just dd the floppy image to server harddisk and reboot. Good luck.
CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb