NetBSD Howto

From LinodeWiki

(Redirected from BSD Howto)
Jump to: navigation, search

This is a writeup/commentary on using one of NetBSD's small install images to install normally (without moving an pre-built image over). The original idea for this is thanks to "bdragon" who left a note on the talk page of BSD Howto.

Contents

[edit] Overview

NetBSD's XEN support is quite thorough and now that Linode's pv-grub support is somewhat stable, I'm writing up this howto. There are still a few caveats, of course:

  • This isn't officially supported by Linode, it's still, after all, Linux-node.
  • SMP isn't supported in 5.0 and 5.1 and will probably continue to be unsupported for some time.. This hasn't bothered me as my own needs come nowhere to using the full capacity of my Linode but for production systems it may be a roadblock. But, given the shared nature of the hosting, you may still end up getting 40% of one CPU vs. 10% of four.
  • 5.0.x only works with amd64. To repeat: NetBSD 5.0.x XENPAE i386 will panic on Linode. At the time of this writing, 5.1 is a RC and 5.1_RC1 XENPAE i386 does indeed boot multiuser and run very stable. i386 should be supported for future versions as well.
  • Booting without using a small assist-partition is awkward.
  • shutdown -h now and halt do not properly halt the machine, leaving you in a spinlock on the console "Press any key to reboot..." which is hard on the VM host and Linode frowns on it. Use "reboot" which will send the appropriate signal, shutting down everything.

[edit] Strategy

The overall method here is very simple. We will create a small (16+ MB) disk image which should be ext2 or ext3. We will use Finnix to download NetBSD's INSTALL kernel image which includes the installer and enough to connect to the network and download the rest of the system. We will also download the normal XEN kernel for booting. We'll then use pv-grub to boot the INSTALL kernel and do a normal install of NetBSD, then we'll again use pv-grub to boot NetBSD and you'll be running!

Use the XEN3PAE_DOMU for i386 and the normal XEN3_DOMU kernels for amd64.

The INSTALL and normal kernels for NetBSD 5.0.2 amd64 are:

ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-5.0.2/amd64/binary/kernel/netbsd-INSTALL_XEN3_DOMU.gz (amd64)

ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-5.0.2/amd64/binary/kernel/netbsd-XEN3_DOMU.gz (amd64)

The INSTALL and normal kernels for NetBSD 5.1_RC1 i386 are:

ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-5.1_RC1/i386/binary/kernel/netbsd-INSTALL_XEN3PAE_DOMU.gz (i386)

ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-5.1_RC1/i386/binary/kernel/netbsd-XEN3PAE_DOMU.gz (i386)

Future releases should be easy to find.

[edit] On the Dashboard

On the Dashboard,

  • Create a small ext2/ext3 image called "boot". 16 MB should be sufficient.
  • Create an image of whatever size you like called "netbsd". This will be the image to which the entire netbsd system is installed so space it accordingly. I used 16 GB.
  • Create a profile (I named mine Finnix :)) for Finnix.
    • Set the kernel to Finnix (recovery)
    • Set /dev/xvda to "Recovery - Finnix (iso)"
    • Set /dev/xvdb to "boot" (or whatever you named your boot image)
    • Set "Uncompressed initrd image" to "Recovery -- Finnix initrd"
    • Save this profile
  • Create another profile (I called my NetBSD) for pv-grub to boot both the installer and the final system.
    • Set the kernel to "pv-grub-x86_64" if you will be using NetBSD amd64 (this is the only version that works with NetBSD 5.0.x) or set it to "pv-grub-x86_32" if you will be using NetBSD 5.1+ i386.
    • Set /dev/xvda to "boot"
    • Set /dev/xvdb to "netbsd" (or whatever you named your netbsd image)
    • Disable all the Helper Options as they won't work with NetBSD.
    • Save this profile

[edit] Using Finnix to grab the kernel images

  • Boot the Finnix profile and connect to the Lish console.
  • Mount the /dev/xvdb device and change to the directory it's mounted at:
 root@hvc0:~# mount /dev/xvdb ; cd /mnt/xvdb
  • wget the two files appropriate for what you're going to be running. I will use the amd64 version of 5.0.2 for the examples.
 root@hvc0:/mnt/xvdb# wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-5.0.2/amd64/binary/kernel/netbsd-INSTALL_XEN3_DOMU.gz
 root@hvc0:/mnt/xvdb# wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-5.0.2/amd64/binary/kernel/netbsd-XEN3_DOMU.gz
  • And that's it, halt the system.
 root@hvc0:/mnt/xvdb# halt

[edit] Booting NetBSD install

  • Boot your NetBSD profile (connect to the Lish console if necessary again).
  • After a few seconds you'll get to a screen like:
     GNU GRUB  version 0.97  (368640K lower / 0K upper memory)
 
        [ Minimal BASH-like line editing is supported.   For
          the   first   word,  TAB  lists  possible  command
          completions.  Anywhere else TAB lists the possible
          completions of a device/filename.  ESC at any time
          exits. ]
 
 grubdom>
  • If things are a bit corrupted just type "clear" and hit enter.
  • At the grubdom prompt type:
 grubdom> kernel (hd0)/netbsd-INSTALL_XEN3_DOMU.gz       (use the right file as appropriate)
 grubdom> boot
  • NetBSD should boot:
 NetBSD 5.0.2 (INSTALL_XEN3_DOMU) #0: Sat Feb  6 13:42:42 UTC 2010
         builds@b8.netbsd.org:/home/builds/ab/netbsd-5-0-2-RELEASE/amd64/20100206
 1851Z-obj/home/builds/ab/netbsd-5-0-2-RELEASE/src/sys/arch/amd64/compile/INSTALL
 _XEN3_DOMU
 total memory = 360 MB
 avail memory = 335 MB
 ...
 ...
  • Congratulations. You might want to hit ctrl-C and run "TERM=vt100" to correct terminal problems. You can restart sysinst with "sysinst"
  • Perform a normal installation of NetBSD on xbd1 (which corresponds to xvdb in your profile). Partition as you like, make sure to create some swap space. All those partitions will be inside the "netbsd" image that you created earlier.
    • DHCP configuration will work for xennet0, so just FTP the distribution sets off a mirror local to where your Linode is hosted.
  • Once the install is finished, halt the system.

[edit] Setting up a menu.lst for Grub to boot automatically

  • Boot into your Finnix profile again and remount /mnt/xvdb.
  • Create the boot/grub directory under this file system that Grub will look for.
 root@hvc0:~# cd /mnt/xvdb/ ; mkdir boot boot/grub
  • Use nano/vi/etc. to create the file /mnt/xvdb/boot/grub/menu.lst
  • Put this into it:
 default 0
 timeout 10
 
 title NetBSD
 root (hd0)
 kernel /netbsd-XEN3_DOMU.gz bootdev=xbd1    (again, use the right file for your setup)
  • Halt the system.

[edit] First boot

  • Boot the NetBSD profile again.
  • Grub should find the menu.lst file and proceed to boot NetBSD.
 ...
 ...
 Tue May  4 08:31:42 EDT 2010
 
 NetBSD/amd64 (Amnesiac) (console)
 
 login: 
  • If you're having problems with grub you can boot the kernel manually:
 grubdom> kernel (hd0)/netbsd-XEN3_DOMU.gz bootdev=xbd1
 grubdom> boot

[edit] Final Notes

  • The first thing you should do is add another user belonging to group "wheel" and setup sshd so you can log in remotely as that user, and su to root, and not use the Lish console.
 # useradd -m -G wheel mynewuser
 # passwd mynewuser
 Enter new password: 
 Retype new password: 
 # cat >> /etc/rc.conf
 sshd=yes
 (ctrl-D)
 # /etc/rc.d/sshd start
  • You might want to remove the extra entries in /etc/ttys. Those getty instances for all but "console" are useless. You only need the one line for the Lish console login:
 # name  getty                           type    status          comments
 #
 console "/usr/libexec/getty Pc"         vt100   on secure
  • Enjoy NetBSD on Linode!
Personal tools