Diff for /wikisrc/tutorials/how_to_install_a_server_with_a_root_lfs_partition.mdwn between versions 1.1 and 1.2

version 1.1, 2011/11/20 20:55:21 version 1.2, 2012/02/05 07:14:36
Line 1 Line 1
 In this article I will explain, step by step, how to install a NetBSD server with a root LFS partition.  In this article I will explain, step by step, how to install a NetBSD server with a root LFS partition. 
   
 **Contents**  **Contents**
   
 [[!toc]]  [[!toc]]
   
 #Foreword  #Foreword
   
 Since LFS is considered experimental, it is highly advised to test this setup on a testbed / Virtual Machine. Use at your own risk.  Since LFS is considered experimental, it is highly advised to test this setup on a testbed / Virtual Machine. Use at your own risk.
   
 In this setup, the server will solely run under LFS without any FFS partitions.  In this setup, the server will solely run under LFS without any FFS partitions.
   
 There are a lot of ways to accomplish this task. This is how I do it.  There are a lot of ways to accomplish this task. This is how I do it.
 #What is LFS  #What is LFS
   
 LFS is an implementation of a [log-structured file system](http://en.wikipedia.org/wiki/Log-structured_File_System_%28BSD%29).  LFS is an implementation of a [log-structured file system](http://en.wikipedia.org/wiki/Log-structured_File_System_%28BSD%29).
   
 For example [Sun's ZFS](http://en.wikipedia.org/wiki/ZFS) is a log-structured file system.  For example [Sun's ZFS](http://en.wikipedia.org/wiki/ZFS) is a log-structured file system.
 #What are the advantages  #What are the advantages
   
 LFS can recover faster from a crash, because it does not need to fsck the whole disk. It is faster than FFS.  LFS can recover faster from a crash, because it does not need to fsck the whole disk. It is faster than FFS.
 #What are the disadvantages  #What are the disadvantages
   
     It has never worked reliably.      It has never worked reliably.
     It is limited to 2 Terabytes.      It is limited to 2 Terabytes.
     It does not perform very well at constant high disk activity like ftp uploads/downloads.      It does not perform very well at constant high disk activity like ftp uploads/downloads.
     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.      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. 
                  
 #How do we aproach  #How do we aproach
   
 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.  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.
 Requirements  Requirements
   
 Physical access to the server.  Physical access to the server.
   
 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>.  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>.
   
 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.  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.
   
 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.  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.
   
 A tutorial on how to build current can be found here: [[How to build NetBSD-current]].  A tutorial on how to build current can be found here: [[How to build NetBSD-current]].
   
 The sets have to be accessible from the liveCD in some way. For example via http, ftp or scp.  The sets have to be accessible from the liveCD in some way. For example via http, ftp or scp. 
   
 #Booting from the liveCD  #Booting from the liveCD
   
 Please boot into the liveCD on the server you want to install.  Please boot into the liveCD on the server you want to install.
   
 Gain root privileges (su -).  Gain root privileges (su -).
 #fdisk  #fdisk
   
 Use fdisk to create an active NetBSD (ID 169) partition.  Use fdisk to create an active NetBSD (ID 169) partition.
   
     # fdisk -iu wd0      # fdisk -iu wd0
   
 #disklabel  #disklabel
   
 Use disklabel to prepare your disk. This part of the tutorial is with purpose not very detailed. You should get comfortable with disklabel beforehand.  Use disklabel to prepare your disk. This part of the tutorial is with purpose not very detailed. You should get comfortable with disklabel beforehand.
   
 Enter  Enter
   
     # disklabel -i -I wd0      # disklabel -i -I wd0
   
 on the command line to enter the interactive disklabel menu. I am assuming you are using wd0. Otherwise substitute with your drive (sd0, ld0...)  on the command line to enter the interactive disklabel menu. I am assuming you are using wd0. Otherwise substitute with your drive (sd0, ld0...)
   
 We will create one big "a" partition in this example. Feel free to try another setup in your second try.  We will create one big "a" partition in this example. Feel free to try another setup in your second try.
   
 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.  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.
   
 Use 4.4LFS as your file system.  Use 4.4LFS as your file system.
   
 Partition b is used as swap. Start from the end of partition a until the end ($).  Partition b is used as swap. Start from the end of partition a until the end ($).
   
 Partition c and d are the disks itself and should be of type **unused** starting from 0 to the end.  Partition c and d are the disks itself and should be of type **unused** starting from 0 to the end.
   
 Remove all other partitions (e-p).  Remove all other partitions (e-p).
   
 When you are finished your label should look like this:  When you are finished your label should look like this:
 <pre><code>  <pre><code>
 #        size    offset     fstype [fsize bsize cpg/sgs]  #        size    offset     fstype [fsize bsize cpg/sgs]
  a:  73400320        63     4.4LFS      0     0     0  # (Cyl.      0*-  72817*)   a:  73400320        63     4.4LFS      0     0     0  # (Cyl.      0*-  72817*)
  b:   2097152  73400383       swap                     # (Cyl.  72817*-  77504*)   b:   2097152  73400383       swap                     # (Cyl.  72817*-  77504*)
  c:  78124937        63     unused      0     0        # (Cyl.      0*-  77504*)   c:  78124937        63     unused      0     0        # (Cyl.      0*-  77504*)
  d:  78125000         0     unused      0     0        # (Cyl.      0 -  77504*)   d:  78125000         0     unused      0     0        # (Cyl.      0 -  77504*)
 </code></pre>  </code></pre>
 Label the disk (N), Write changes to disk (W), and quit (Q).  Label the disk (N), Write changes to disk (W), and quit (Q).
 #newfs_lfs  #newfs_lfs
   
 You can now create the LFS filesystem on the disk you just labeled.  You can now create the LFS filesystem on the disk you just labeled.
   
     # newfs_lfs wd0a      # newfs_lfs wd0a
   
 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.  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.
 #mounting  #mounting
   
 The rest is trivial. We mount the filesystem and extract our sets.  The rest is trivial. We mount the filesystem and extract our sets.
   
     # mkdir /tmp/targetroot      # mkdir /tmp/targetroot
     # mount /dev/wd0a /tmp/targetroot      # mount /dev/wd0a /tmp/targetroot
   
 Create another directory to store the sets in.  Create another directory to store the sets in.
   
     # mkdir /tmp/sets      # mkdir /tmp/sets 
   
 Change in that directory  Change in that directory
   
     # cd /tmp/sets      # cd /tmp/sets
   
 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.  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.
   
     # ftp 192.168.0.200      # ftp 192.168.0.200
   
     ...      ...
 #extracting the sets  #extracting the sets
   
 extract your sets using option -p (important).  extract your sets using option -p (important).
   
     # cd /tmp/sets      # cd /tmp/sets
     # tar xvzpf base.tgz -C /tmp/targetroot      # tar xvzpf base.tgz -C /tmp/targetroot
   
 repeat with all your sets, but extract only one GENERIC kernel named kern-GENERIC.tgz  repeat with all your sets, but extract only one GENERIC kernel named kern-GENERIC.tgz
 #configure the new system  #configure the new system
   
 change into /tmp/targetroot and do a base configuration. Edit etc/fstab  change into /tmp/targetroot and do a base configuration. Edit etc/fstab
   
     /dev/wd0a       /               lfs     rw      1 1      /dev/wd0a       /               lfs     rw      1 1
     /dev/wd0b       none            swap    sw      0 0      /dev/wd0b       none            swap    sw      0 0
     ptyfs           /dev/pts        ptyfs   rw      0 0      ptyfs           /dev/pts        ptyfs   rw      0 0
     tmpfs           /tmp            tmpfs   rw      tmpfs           /tmp            tmpfs   rw
   
 ptyfs and tmpfs are optional, but recommended.  ptyfs and tmpfs are optional, but recommended.
   
 Edit etc/rc.conf  Edit etc/rc.conf
   
     rc_configured=yes      rc_configured=yes
   
 #bootstrap  #bootstrap
   
 Copy boot to the targetroot.  Copy boot to the targetroot.
   
     # cp /tmp/targetroot/usr/mdec/boot /tmp/targetroot      # cp /tmp/targetroot/usr/mdec/boot /tmp/targetroot 
   
 And bootstrap  And bootstrap
   
     # /usr/sbin/installboot -v -m i386 -o timeout=5,console=pc /dev/rwd0a /tmp/targetroot/usr/mdec/bootxx_lfsv2      # /usr/sbin/installboot -v -m i386 -o timeout=5,console=pc /dev/rwd0a /tmp/targetroot/usr/mdec/bootxx_lfsv2
   
 #creating devices  #creating devices
   
 Don't forget to create all devices.  Don't forget to create all devices.
   
     # cd /tmp/targetroot/dev      # cd /tmp/targetroot/dev
     # ./MAKEDEV all      # ./MAKEDEV all
   
 this may take a while.  this may take a while.
 #reboot  #reboot
   
 That's it. Sync and reboot.  That's it. Sync and reboot.
   
     # sync      # sync
     # sync      # sync
     # sync      # sync
     # reboot      # reboot
   
 If everything went well, your system should boot. Once you have logged in, you can configure your system and do all the fine tuning.  If everything went well, your system should boot. Once you have logged in, you can configure your system and do all the fine tuning.
 #Disk capacity  #Disk capacity
   
 You should not fill up your LFS partition over 75%. This could damage the file system (at the moment).  You should not fill up your LFS partition over 75%. This could damage the file system (at the moment).
 #Remote installation  #Remote installation
   
 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.   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. 
   

Removed from v.1.1  
changed lines
  Added in v.1.2


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb