Difference between revisions of "NetBSD"

From PrgmrWiki
(NetBSD 6.x)
Line 1: Line 1:
== c33ris2's gentle guide to installing NetBSD in a prgmr DomU (January 2009) ==
+
= Grub or Grub2? =
Note: By June 2010 (or earlier) <b><i>some</i></b> of the dom0 hosts have packed the installer files into the /distros collection available to many recovery images. In these cases, the fetching activity is no longer required.
 
  
'''Note:''' for mantle/chessboard users: Mantle is currently running Xen 4.0.1. There is a [http://mail-index.netbsd.org/port-xen/2010/06/15/msg006105.html bug] in NetBSD that [http://lists.xensource.com/archives/html/xen-users/2010-08/msg00076.html breaks networking] when running in a Xen4 domU.
+
Using GRUB2 with NetBSD is much easier than legacy pvgrub. GRUB2 with 64-bit NetBSD works everywhere. If you want to use 32-bit NetBSD, however, GRUB2
 +
may not be supported. You can check by [[Grub2#Changing_bootloader|trying to change the bootloader]] . If i386+grub2 is not supported, you can either contact support to see if you
 +
can be moved to a server that does support it or you can use a special partition scheme as documented below.
  
'''Note:''' what Xen version is marshall?  It also has the issue.
+
= Partitioning for use with pv-grub =
  
'''Note:''' A -current NetBSD kernel is required to run under Xen 4.x.  When NetBSD 6 is released, these notes will go away.  -current is for EXPERTS ONLY.
+
From the [[Management Console]], to make accessing the live rescue image more easy verify you are using "pv-grub"
 
 
'''Note:''' Daily binary kernels (and bootable installers) with Xen 4.x compatibility are available at http://nyftp.netbsd.org/pub/NetBSD-daily/netbsd-5/201110240510Z/ and later.
 
 
 
'''Note:''' It seems that loadable kernel modules are not supported under Xen. See http://gnats.netbsd.org/43796. Among other things, this renders pf firewalling unusable under the default NetBSD kernel, as loading the pf module <code>(modload /usr/lkm/pf.o)</code> will cause the kernel to crash; building a new kernel with pf built-in may work.
 
 
 
 
 
===Getting Started===
 
Installing NetBSD as DomU is easy, but not trivial.
 
 
 
Boot your preconfigured system, in order to discover, and note for later use, YOUR_IP, NETMASK, GATEWAY, and NAMESERVER as follows:
 
 
<pre>
 
<pre>
Run 'ifconfig eth0' and note your "inet addr" and "Mask" values.
+
9. swap pvgrub/grub2 bootloaders currently "pv-grub"
Run 'route' or 'ip route' and note the IP of the default gateway.
 
Run 'cat /etc/resolv.conf' and note the IP of the nameserver
 
</pre>
 
 
 
From [[Prgmr_menu|the control menu on your dom0 host]], destroy/shutdown the instance, and restart ("create/start") it, selecting the "rescue" option from the bootloader. Login as 'root'.
 
 
 
Your fixed disk, as known to the linux rescue image, is /dev/xvda. Later, when booted to the NetBSD installer, it is identified as /dev/xbd0.
 
 
 
For NetBSD, this disk must be partitioned, and the NetBSD installer files placed therein.
 
<pre>fdisk /dev/xvda</pre>
 
 
 
From within fdisk,
 
<ul>
 
  <li>delete the existing partition, <b>*which will destroy your current OS image and data*</b></li>
 
  <li>create a new primary partition #1, with first cylinder at default=1 and last cylinder at +32M</li>
 
  <li>create a new primary partition #2, directly after partition 1 and last cylinder at end of disk</li>
 
  <li>change the ID of the new partition #2 to 'a9' (NetBSD)
 
  <li>write the new parition table to the disk.
 
  <li>exit fdisk
 
</ul>
 
 
 
Success to this point is evidenced by the prseence of /dev/xvda1 which must now be formatted, mounted, and a /boot directory created:
 
<pre>mkfs.ext2 /dev/xvda1
 
mount -n /dev/xvda1 /mnt
 
mkdir /mnt/boot
 
mkdir /mnt/boot/grub
 
 
</pre>
 
</pre>
 
+
Verify whether you are running in 32 bit (i386) or 64 bit (amd64) mode by looking at
If the file 'netbsd64.tar.gz' exists in /distros, skip over to [[#Unpacking the Installer]]
 
 
 
'''Note:''' if you will be using a -current install, then don't bother with /distros
 
 
 
Otherwise you'll have to proceed here with
 
 
 
===Fetching the Installer===
 
 
 
Substituting actual values observed (above) for
 
YOUR_IP, NETMASK, GATEWAY, and NAMESERVER ...
 
 
<pre>
 
<pre>
ifconfig eth0 up YOUR_IP/NETMASK
+
    6. swap i386/amd64 bootloaders currently "i386"
route add default gw GATEWAY eth0
 
echo "nameserver NAMESERVER" >/etc/resolv.conf
 
 
</pre>
 
</pre>
 +
and switch if desired.<br>
  
wget and extract to /mnt/boot/ :
+
Shut down your machine if it is running. Then select
 
 
 
<pre>
 
<pre>
cd /mnt/boot
+
    2. create/start, opens OOB console (try this if the machine is not running)
wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-5.1/amd64/binary/kernel/netbsd-INSTALL_XEN3_DOMU.gz
 
wget ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-5.1/amd64/binary/kernel/netbsd-XEN3_DOMU.gz
 
gunzip netbsd-INSTALL_XEN3_DOMU.gz
 
gunzip netbsd-XEN3_DOMU.gz
 
 
</pre>
 
</pre>
 
+
This will bring up a menu resembling:
'''Note:''' if you will be using -current, you must get a current build from NetBSD's releng. (http://releng.netbsd.org).  Check for a successful amd64 build in the log data, then determine the corresponding location in the binary snapshots.
 
 
 
===Configuring Boot Menu===
 
 
 
Create a file boot/grub/menu.lst with this content:
 
 
 
 
<pre>
 
<pre>
timeout 5
+
    GNU GRUB  version 0.97  (131072K lower / 0K upper memory)
  
title NetBSD run
+
+-------------------------------------------------------------------------+
        root (hd0,0)
+
| user bootloader configuration                                          | 
        kernel --type=netbsd /boot/netbsd-XEN3_DOMU
+
| Debian GNU/Linux, kernel 3.2.0-4-amd64 Live Rescue                      |
 
+
| Debian GNU/Linux, kernel 3.2.0-4-amd64 (single-user mode) Live Rescue  |
title NetBSD install
+
| ubuntu-trusty-14.04-64 rescue                                          |
        root (hd0,0)
+
| ubuntu-trusty-14.04-64 install                                          |
        kernel --type=netbsd /boot/netbsd-INSTALL_XEN3_DOMU
+
| centos5-64 rescue                                                      |
 +
| centos5-64 install                                                     |
 +
| debian-wheezy-7.0-64 rescue                                            |
 +
| debian-wheezy-7.0-64 install                                            |
 +
| fedora20-64 rescue                                                      |
 +
| fedora20-64 install                                                    |
 +
| centos6-64 rescue                                                      | v
 +
+-------------------------------------------------------------------------+
 +
    Use the ^ and v keys to select which entry is highlighted.
 +
    Press enter to boot the selected OS, 'e' to edit the
 +
    commands before booting, or 'c' for a command-line.
 
</pre>
 
</pre>
  
<b>Skip to [[#Booting the Installer]]</b>
+
Boot <code>Debian GNU/Linux Live Rescue</code> from GRUB.
  
===Unpacking the Installer===
+
Log in as <tt>root</tt>.
This section presumes the presence, in the rescue instance, of /distros/netbsd64.tar.gz
 
<br>Unpack this into the new boot menu, and shutdown.
 
  
<pre>tar zxf /distros/netbsd64.tar.gz -C /mnt/boot/
+
Run the following:
shutdown -h now
 
</pre>
 
 
 
'''NOTE''' This step isn't necessary if you perform a network install
 
 
 
===Booting the Installer===
 
 
 
Returning to [[Prgmr_menu|the control menu on your dom0 host]], change your bootloader selection to 'amd64' instead of 'i386'.  Destroy/shutdown your instance if it is running, and create/start it again, this time selecting first the "user bootloader configuration" from the options presented by the dom0, and after that  select the installer from your new user bootloader. This should take you to the NetBSD  Installer, for which [http://netbsd.org/docs/guide/en/chap-exinst.html#exinst-starting  a tutorial exists at netbsd.org]
 
 
 
Install onto xbd0
 
 
 
When presented with the option, choose
 
<br><b>b: Use existing partition sizes</b>
 
<br>The next screen should show the existing BSD-disklabel partitions, as follows for a 3G allocation.
 
 
<pre>
 
<pre>
    Start  MB  End  MB  Size  MB FS type    Newfs Mount Mount point
+
wipe-and-reinstall /distros/<tab complete to desired distro>
    --------- --------- --------- ---------- ----- ----- -----------
 
a:        0        0        0 unused
 
b:        0        0        0 unused
 
c:        0      3071      3072 NetBSD partition
 
d:        0      3071      3072 Whole disk
 
e:        0        29        30 Linux Ext2
 
f:        30    3071      3041 4.2BSD    Yes  Yes  /
 
g:        0        0        0 unused
 
 
</pre>
 
</pre>
  
<i>If you're new to NetBSD partitioning, which I am, which is why I'm writing this, refer to [http://netbsd.org/docs/guide/en/chap-inst.html#chap-inst-install-partition this NetBSD Guide section]</i>
+
This will create a boot partition and add the normal kernel, install kernel, and menu.lst to that boot partition.
 +
Write and quit. "Reboot" the machine so that you can boot the NetBSD installer.
  
In order to install NetBSD properly, lets move the root partition to label:a and create swap.  Select a:, set the partition type to "FFSv2" instead of "unused", and use 'e' as the start of your partition.  Leave space at the end for swap.  I used 128 MB, but you may want more depending on your application and VM allocation.  Make sure to set Newfs, Mount, and Mount point correctly.  Select b: and create swap until the end of the disk (-1).
+
= Booting NetBSD installer =
  
You can also set the mount point for e:.
+
From the [[Management Console]], to make accessing the live rescue image more easy verify you are using "pv-grub"
 
 
Finally, remove (the now obsolete) label:f by setting it to unused.
 
 
 
Here is an example disklabel setup for a 3072M disk
 
with a 30M boot partition:
 
 
<pre>
 
<pre>
    Start MB  End  MB  Size  MB FS type    Newfs Mount Mount point
+
  9. swap pvgrub/grub2 bootloaders currently "pv-grub"
    --------- --------- --------- ---------- ----- ----- -----------
 
a:        30      2942      2912 FFSv2      Yes  Yes  /
 
b:      2943      3071      128 swap
 
c:        0      3071      3072 NetBSD partition
 
d:        0      3071      3072 Whole disk
 
e:        0        29        30 Linux Ext2      Yes  /boot
 
f:        0        0        0 unused
 
 
</pre>
 
</pre>
 
+
Verify whether you are running in 32 bit (i386) or 64 bit (amd64) mode by looking at
 
 
Select "accept these sizes" and continue with the installation.
 
 
 
When prompted by the installer, select "use existing bootblocks".
 
 
 
Install by FTP
 
 
 
When prompted by the installer, use the xennet0 device and when it asks for "Network media type" just press enter.
 
 
 
Try to use DHCP.  If it doesn't work,
 
Use the actual values observed (above) for
 
<br>YOUR_IP, NETMASK, GATEWAY, and NAMESERVER
 
<br>when prompted by the installer
 
 
 
 
 
 
<pre>
 
<pre>
The installation of NetBSD is now complete. The system should boot
+
    6. swap i386/amd64 bootloaders currently "i386"
from hard disk.  Follow the instructions in the INSTALL document about final
 
configuration of your system.  The afterboot(8) manpage is another
 
recommended reading; it contains a list of things to be checked after the
 
first complete boot.
 
 
 
At a minimum, you should edit /etc/rc.conf to match your needs.  See
 
/etc/defaults/rc.conf for the default values.
 
 
</pre>
 
</pre>
 +
and switch if desired.<br>
  
Reboot.
+
Shut down your machine if it is running. Then select
 
 
===Mount boot partition in NetBSD domU===
 
Log in as root.
 
 
<pre>
 
<pre>
# mkdir /extboot
+
    2. create/start, opens OOB console (try this if the machine is not running)
# vi /etc/fstab
 
 
</pre>
 
</pre>
find the line in fstab that contains /dev/xbd0e and make it look like this:
+
This will bring up a menu resembling:
 
<pre>
 
<pre>
/dev/xbd0e              /extboot        ext2fs    rw              0 0
+
    GNU GRUB  version 0.97  (131072K lower / 0K upper memory)
</pre>
 
  
Now it will be readable:
+
+-------------------------------------------------------------------------+
 
+
| user bootloader configuration                                          | 
<pre>
+
| Debian GNU/Linux, kernel 3.2.0-4-amd64 Live Rescue                      |
# mount /extboot
+
| Debian GNU/Linux, kernel 3.2.0-4-amd64 (single-user mode) Live Rescue  |
# cd /extboot/boot/
+
| ubuntu-trusty-14.04-64 rescue                                          |
# ls
+
| ubuntu-trusty-14.04-64 install                                          |
grub                      netbsd-INSTALL_XEN3_DOMU netbsd-XEN3_DOMU
+
| centos5-64 rescue                                                      |
 +
| centos5-64 install                                                      |
 +
| debian-wheezy-7.0-64 rescue                                            |
 +
| debian-wheezy-7.0-64 install                                            |
 +
| fedora20-64 rescue                                                      |
 +
| fedora20-64 install                                                    |
 +
| centos6-64 rescue                                                      | v
 +
  +-------------------------------------------------------------------------+
 +
    Use the ^ and v keys to select which entry is highlighted.
 +
    Press enter to boot the selected OS, 'e' to edit the
 +
    commands before booting, or 'c' for a command-line.
 
</pre>
 
</pre>
  
 +
Boot <code>netbsd install</code> from GRUB.
  
{{u}} {{distros}}
+
== Installation for pv-grub ==
  
 +
You may choose whatever options you want as long as the first partition is preserved as-is. If the boot partition is formatted or removed, however, you will be unable to boot.
  
===NetBSD 6.x===
+
== Installation for grub2 ==
 +
You may install with whatever options you choose as long as the first partition has room for the netbsd kernel (approximately 8MiB) and the
 +
[[grub2#Compatible_file_systems|file system]] is compatible with grub2.<br>
  
As of December 2012, it has been reported that NetBSD can also be installed following these directions, using these images:
+
After finishing the install, you will need to manually add the Xen kernel. Enter a shell from the installer and perform the following:
 +
<pre>
 +
mount /dev/xbd0d /mnt
 +
chroot /mnt
  
ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.0/amd64/binary/kernel/netbsd-XEN3_DOMU.gz
+
pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/6.1.5/sysutils/grub2-2.00nb4.tgz
 +
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.1.5/amd64/binary/kernel/netbsd-XEN3_DOMU.gz
 +
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.1.5/amd64/binary/kernel/MD5
 +
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.1.5/amd64/binary/kernel/SHA512
 +
#Do not use if this fails
 +
grep "$(/usr/bin/cksum -a md5 netbsd-XEN3_DOMU.gz)" MD5
 +
#Do not use if this fails
 +
grep "$(/usr/bin/cksum -a sha512 netbsd-XEN3_DOMU.gz)" SHA512
 +
mkdir /grub
 +
/usr/pkg/sbin/grub-mkconfig -o /grub/grub.cfg
 +
exit
 +
umount /mnt
 +
exit
 +
</pre>
  
ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.0/amd64/binary/kernel/netbsd-INSTALL_XEN3_DOMU.gz
+
Select "Back to main menu" and then "Reboot the computer" to complete the install.
  
 +
= Rescuing NetBSD install =
  
As of September 2013, NetBSD 6.1.1 i386 and AMD64 can be installed successfully, ex.
+
The shell available from the NetBSD installer from the initial pv-grub boot menu may be used as a minimal rescue image.
ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.1.1/i386/binary/kernel/netbsd-INSTALL_XEN3PAE_DOMU.gz
 
ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.1.1/i386/binary/kernel/netbsd-XEN3PAE_DOMU.gz
 

Revision as of 19:35, 4 September 2015

Grub or Grub2?

Using GRUB2 with NetBSD is much easier than legacy pvgrub. GRUB2 with 64-bit NetBSD works everywhere. If you want to use 32-bit NetBSD, however, GRUB2 may not be supported. You can check by trying to change the bootloader . If i386+grub2 is not supported, you can either contact support to see if you can be moved to a server that does support it or you can use a special partition scheme as documented below.

Partitioning for use with pv-grub

From the Management Console, to make accessing the live rescue image more easy verify you are using "pv-grub"

 9. swap pvgrub/grub2 bootloaders currently "pv-grub"

Verify whether you are running in 32 bit (i386) or 64 bit (amd64) mode by looking at

    6. swap i386/amd64 bootloaders currently "i386"

and switch if desired.

Shut down your machine if it is running. Then select

    2. create/start, opens OOB console (try this if the machine is not running)

This will bring up a menu resembling:

    GNU GRUB  version 0.97  (131072K lower / 0K upper memory)

 +-------------------------------------------------------------------------+
 | user bootloader configuration                                           |  
 | Debian GNU/Linux, kernel 3.2.0-4-amd64 Live Rescue                      |
 | Debian GNU/Linux, kernel 3.2.0-4-amd64 (single-user mode) Live Rescue   |
 | ubuntu-trusty-14.04-64 rescue                                           |
 | ubuntu-trusty-14.04-64 install                                          |
 | centos5-64 rescue                                                       |
 | centos5-64 install                                                      |
 | debian-wheezy-7.0-64 rescue                                             |
 | debian-wheezy-7.0-64 install                                            |
 | fedora20-64 rescue                                                      |
 | fedora20-64 install                                                     |
 | centos6-64 rescue                                                       | v
 +-------------------------------------------------------------------------+
    Use the ^ and v keys to select which entry is highlighted.
    Press enter to boot the selected OS, 'e' to edit the
    commands before booting, or 'c' for a command-line.

Boot Debian GNU/Linux Live Rescue from GRUB.

Log in as root.

Run the following:

wipe-and-reinstall /distros/<tab complete to desired distro>

This will create a boot partition and add the normal kernel, install kernel, and menu.lst to that boot partition. Write and quit. "Reboot" the machine so that you can boot the NetBSD installer.

Booting NetBSD installer

From the Management Console, to make accessing the live rescue image more easy verify you are using "pv-grub"

 9. swap pvgrub/grub2 bootloaders currently "pv-grub"

Verify whether you are running in 32 bit (i386) or 64 bit (amd64) mode by looking at

    6. swap i386/amd64 bootloaders currently "i386"

and switch if desired.

Shut down your machine if it is running. Then select

    2. create/start, opens OOB console (try this if the machine is not running)

This will bring up a menu resembling:

    GNU GRUB  version 0.97  (131072K lower / 0K upper memory)

 +-------------------------------------------------------------------------+
 | user bootloader configuration                                           |  
 | Debian GNU/Linux, kernel 3.2.0-4-amd64 Live Rescue                      |
 | Debian GNU/Linux, kernel 3.2.0-4-amd64 (single-user mode) Live Rescue   |
 | ubuntu-trusty-14.04-64 rescue                                           |
 | ubuntu-trusty-14.04-64 install                                          |
 | centos5-64 rescue                                                       |
 | centos5-64 install                                                      |
 | debian-wheezy-7.0-64 rescue                                             |
 | debian-wheezy-7.0-64 install                                            |
 | fedora20-64 rescue                                                      |
 | fedora20-64 install                                                     |
 | centos6-64 rescue                                                       | v
 +-------------------------------------------------------------------------+
    Use the ^ and v keys to select which entry is highlighted.
    Press enter to boot the selected OS, 'e' to edit the
    commands before booting, or 'c' for a command-line.

Boot netbsd install from GRUB.

Installation for pv-grub

You may choose whatever options you want as long as the first partition is preserved as-is. If the boot partition is formatted or removed, however, you will be unable to boot.

Installation for grub2

You may install with whatever options you choose as long as the first partition has room for the netbsd kernel (approximately 8MiB) and the file system is compatible with grub2.

After finishing the install, you will need to manually add the Xen kernel. Enter a shell from the installer and perform the following:

mount /dev/xbd0d /mnt
chroot /mnt

pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/6.1.5/sysutils/grub2-2.00nb4.tgz
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.1.5/amd64/binary/kernel/netbsd-XEN3_DOMU.gz
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.1.5/amd64/binary/kernel/MD5
ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.1.5/amd64/binary/kernel/SHA512
#Do not use if this fails
grep "$(/usr/bin/cksum -a md5 netbsd-XEN3_DOMU.gz)" MD5
#Do not use if this fails
grep "$(/usr/bin/cksum -a sha512 netbsd-XEN3_DOMU.gz)" SHA512
mkdir /grub
/usr/pkg/sbin/grub-mkconfig -o /grub/grub.cfg
exit
umount /mnt
exit

Select "Back to main menu" and then "Reboot the computer" to complete the install.

Rescuing NetBSD install

The shell available from the NetBSD installer from the initial pv-grub boot menu may be used as a minimal rescue image.