Difference between revisions of "NetBSD"

From PrgmrWiki
(Continue my updates)
(Continue to update NetBSD install procedure)
Line 105: Line 105:
 
When presented with the option, choose
 
When presented with the option, choose
 
<br><b>b: Use existing partition sizes</b>
 
<br><b>b: Use existing partition sizes</b>
<br>The next screen should show the existing BSD-disklabel partitions, as follows for a 6G allocation.  
+
<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
 
     Start  MB  End  MB  Size  MB FS type    Newfs Mount Mount point
Line 111: Line 111:
 
  a:        0        0        0 unused
 
  a:        0        0        0 unused
 
  b:        0        0        0 unused
 
  b:        0        0        0 unused
  c:        0      6143     6144 NetBSD partition
+
  c:        0      3071     3072 NetBSD partition
  d:        0      6143     6144 Whole disk
+
  d:        0      3071     3072 Whole disk
  e:        0        38       39 Linux Ext2
+
  e:        0        29       30 Linux Ext2
  f:        0        0        0 unused
+
  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>
 
<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>
  
The purpose of examining this screen is to note that the Linux Ext2 partition used for the installer occupies the first 39 (numbered 0 thru 38) sectors of the partition. We need to set the NetBSD root after that, starting with sector 39.  
+
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).
  
Select "x: Partition sizes ok" and "no" to the opportunity to edit the partition table again. The installation will be aborted and you'll be returned to an earlier screen, which is intended by this tutorial. Proceed as before through the next few screens, but this time select
+
You can also set the mount point for e:.
<br><b>a: Set sizes of NetBSD partitions</b>
 
<br>which will set up the default root and swap partitions.
 
 
 
Optional, Recommended: <i>(but I haven't been able to do this successfully yet)</i> <b>"Add a user defined partition"</b> at /boot so that you can update the kernels and adjust the menu.lst later. The size should be as noted earlier for the linux partition, 39MB in this example.
 
 
 
Select "accept these sizes", and you'll get a screen with one more chance, which we'll take, to modify the partitions, by selecting the DiskLabel 'a' and changing the start point from 0 to 39 (MB).
 
 
 
<i>If you added a label for /boot</i>, you'll see it in the table, and it needs to be modified. Set the start to 0, and in response to the size prompt, answer with 'a' to have the partition end at the beginning of disklabel 'a'.
 
  
 
Here is an example disklabel setup for a 3072M disk
 
Here is an example disklabel setup for a 3072M disk
with a 32M boot partition:
+
with a 30M boot partition:
 
<pre>
 
<pre>
    Start  MB  End  MB  Size  MB FS type    Newfs Mount Mount point
+
    Start  MB  End  MB  Size  MB FS type    Newfs Mount Mount point
 
     --------- --------- --------- ---------- ----- ----- -----------
 
     --------- --------- --------- ---------- ----- ----- -----------
  a:        31     2912     2882 FFSv1     Yes  Yes  /
+
  a:        30      2942     2912 FFSv2     Yes  Yes  /
  b:      2913     3040       128 swap
+
  b:      2943     3071       128 swap
 
  c:        0      3071      3072 NetBSD partition
 
  c:        0      3071      3072 NetBSD partition
 
  d:        0      3071      3072 Whole disk
 
  d:        0      3071      3072 Whole disk
  e:        0        30       31 Linux Ext2
+
  e:        0       29       30 Linux Ext2       Yes  /boot
 
  f:        0        0        0 unused
 
  f:        0        0        0 unused
g: Show all unused partitions
 
h: Change input units (sectors/cylinders/MB)
 
>x: Partition sizes ok
 
 
</pre>
 
</pre>
  
Continue with the installation.
+
 
 +
Select "accept these sizes" and continue with the installation.
  
 
Install by FTP
 
Install by FTP
  
 +
Try to use DHCP.  If it doesn't work,
 
Use the actual values observed (above) for  
 
Use the actual values observed (above) for  
 
<br>YOUR_IP, NETMASK, GATEWAY, and NAMESERVER
 
<br>YOUR_IP, NETMASK, GATEWAY, and NAMESERVER
Line 157: Line 149:
  
 
<pre>
 
<pre>
The installation of NetBSD-5.0.2 is now complete.  The system should boot
+
The installation of NetBSD is now complete.  The system should boot
 
from hard disk.  Follow the instructions in the INSTALL document about final
 
from hard disk.  Follow the instructions in the INSTALL document about final
 
configuration of your system.  The afterboot(8) manpage is another
 
configuration of your system.  The afterboot(8) manpage is another
Line 168: Line 160:
  
 
Reboot.
 
Reboot.
 
Something's wrong :( with the way I disklabelled /boot. Everything is fine if I skip that step.
 
  
 
{{u}} {{distros}}
 
{{u}} {{distros}}

Revision as of 16:15, 22 October 2011

c33ris2's gentle guide to installing NetBSD in a prgmr DomU (January 2009)

Note: By June 2010 (or earlier) some 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 bug in NetBSD that breaks networking when running in a Xen4 domU.

Note: what Xen version is marshall? It also has the issue.

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.

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:

Run 'ifconfig eth0' and note your "inet addr" and "Mask" values.
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

From 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.

fdisk /dev/xvda

From within fdisk,

  • delete the existing partition, *which will destroy your current OS image and data*
  • create a new primary partition #1, with first cylinder at default=1 and last cylinder at +32M
  • create a new primary partition #2, directly after partition 1 and last cylinder at end of disk
  • change the ID of the new partition #2 to 'a9' (NetBSD)
  • write the new parition table to the disk.
  • exit fdisk

Success to this point is evidenced by the prseence of /dev/xvda1 which must now be formatted, mounted, and a /boot directory created:

mkfs.ext2 /dev/xvda1
mount -n /dev/xvda1 /mnt
mkdir /mnt/boot
mkdir /mnt/boot/grub

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 ...

ifconfig eth0 up YOUR_IP/NETMASK
route add default gw GATEWAY eth0
echo "nameserver NAMESERVER" >/etc/resolv.conf

wget and extract to /mnt/boot/ :

cd /mnt/boot
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

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:

timeout 5

title NetBSD run
        root (hd0,0)
        kernel --type=netbsd /boot/netbsd-XEN3_DOMU

title NetBSD install
        root (hd0,0)
        kernel --type=netbsd /boot/netbsd-INSTALL_XEN3_DOMU

Skip to #Booting the Installer

Unpacking the Installer

This section presumes the presence, in the rescue instance, of /distros/netbsd64.tar.gz
Unpack this into the new boot menu, and shutdown.

tar zxf /distros/netbsd64.tar.gz -C /mnt/boot/
shutdown -h now


Booting the Installer

Returning to 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 a tutorial exists at netbsd.org

Install onto xbd0

When presented with the option, choose
b: Use existing partition sizes
The next screen should show the existing BSD-disklabel partitions, as follows for a 3G allocation.

    Start  MB   End  MB  Size  MB FS type    Newfs Mount Mount point
    --------- --------- --------- ---------- ----- ----- -----------
 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

If you're new to NetBSD partitioning, which I am, which is why I'm writing this, refer to this NetBSD Guide section

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).

You can also set the mount point for e:.

Here is an example disklabel setup for a 3072M disk with a 30M boot partition:

    Start  MB   End  MB  Size  MB FS type    Newfs Mount Mount point
    --------- --------- --------- ---------- ----- ----- -----------
 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


Select "accept these sizes" and continue with the installation.

Install by FTP

Try to use DHCP. If it doesn't work, Use the actual values observed (above) for
YOUR_IP, NETMASK, GATEWAY, and NAMESERVER
when prompted by the installer


The installation of NetBSD is now complete.  The system should boot
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.

Reboot.