.\"	$NetBSD: install,v 1.31 2009/01/26 00:14:42 snj Exp $
.\"
.\" Copyright (c) 1999-2002 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.
Installing
.Nx
is a relatively complex process, but if you have
this document in hand it shouldn't be too much trouble.
.Pp
There are several ways to install
.Nx
onto a disk.
The easiest way in terms of preliminary setup is to install from CD-ROM.
If you don't have access to a CD-ROM or CD-ROM burner, you
can use a miniroot image that can be booted off your local disk's swap
partition.
Alternatively, if your UltraSPARC is hooked up in a network
you can find a server and arrange for a diskless setup which is a convenient
way to install on a machine whose disk does not currently hold a usable
operating system (see the section
.Sx Installing NetBSD by using a diskless setup
below).
.Pp
If you have problems with these or you are installing 
.Nx
onto the same disk as 
.Tn Solaris ,
see the section below on
.Sx "Manual Installation of NetBSD using Solaris"
.
.Ss2 Installing NetBSD from CD-ROM
.
Installing from CD-ROM is the least painful way to install
.Nx .
Simply insert the CD-ROM in the drive, power up the computer, and type:
.(disp
.No ok Ic "boot cdrom"
.disp)
.Pp
This Open Firmware boot command will cause the
.Nx
kernel contained in the CD-ROM to be booted.
After the initial probe messages you'll be
asked to start the install or upgrade procedure.
Proceed to the section
.Sx "Running the sysinst installation program"
below.
.
.Ss2 Installing NetBSD by using the NetBSD miniroot
.
The miniroot is a self-contained
.Nx
file system holding all utilities
necessary to install
.Nx
on a local disk.
It is distributed as a plain
file designed to be transferred to a raw disk partition from which it can
be booted using the appropriate OpenFirmware command.
Usually, the miniroot will be loaded into the swap partition of a disk.
If needed, you can use any other unused partition,
but remember that the partition will then not
available during the installation process.
.Pp
Loading the miniroot onto your raw partition is simple using the
.Xr dd 1
command.  Just remember to first uncompress the miniroot image and boot 
your OS with the
.Li -s
flag so that it runs 
.Dq "single-user"
and does not attempt to start swapping.
.(disp
.No ok Ic "boot -s"
.disp)
.Pp
On
.Tn Solaris
you use a command like:
.(disp
.No # Ic "gunzip miniroot.fs.gz"
.No # Ic "dd if=miniroot.fs of=/dev/rdsk/c0t0d0s1 bs=4k"
.disp)
On
.Nx
the command is:
.(disp
.No # Ic "gunzip miniroot.fs.gz"
.No # Ic "dd if=miniroot.fs of=/dev/rsd0b bs=4k"
.disp)
Replace
.Li /dev/rdsk/c0t0d0s1
or
.Li /dev/rsd0b
with your swap partition.
.Pp
After transferring the miniroot to disk, bring the system down by:
.(disp
.No # Ic halt
.disp)
Then boot the miniroot by typing the appropriate command at the 
OpenFirmware prompt:
.(disp
.No ok Ic "boot disk:b netbsd"
.disp)
If you've loaded the miniroot onto some other disk than
.Li sd0
use the correct 
.Pa devalias ,
such as
.(disp
.No ok Ic "boot disk1:b netbsd"
.disp)
This Open Firmware boot command will cause the
.Nx
kernel contained in the
miniroot image to be booted.
After the initial probe messages you'll be
asked to start the install or upgrade procedure.
Proceed to the section
.Sx "Running the sysinst installation program"
below.
.
.Ss2 Installing NetBSD by using a NetBSD kernel on a Solaris partition
.
This procedure is very straightforward.  You will be putting the
.Nx
installation kernel (kernel with a RAM disk installer) on your
.Tn Solaris
partition and telling Open Firmware to boot the
.Nx
kernel.
.Pp
CAVEAT: this method is a bit fragile.  Depending on physical partition layout,
partition size, and parameters used to create the filesystem of your
.Tn Solaris
root partition, bugs in the bootloader might be triggered and cause this
method to fail.
.Pp
First, copy the 
.Pa netbsd-INSTALL.gz
kernel and bootloader to the root level of your hard drive and halt your 
system
.(disp
.No # Ic "cp binary/kernel/netbsd-INSTALL.gz /"
.No # Ic "cp installation/misc/ofwboot /"
.No # Ic "halt"
.disp)
At the Open Firmware prompt, boot
.Nx .
.(disp
.No ok Ic "boot disk:a /ofwboot -a"
.disp)
The
.Li -a
flag is needed so that the bootloader will ask you to find your 
installation kernel.
.(disp
Rebooting with command: boot disk:a /ofwboot -a
Boot device: /pci@1f,4000/scsi@3/disk@0,0:a  File and args: /ofwboot -a
.No Enter filename [/ofwboot]: Ic "\*[Lt]return\*[Gt]
\*[Gt]\*[Gt] NetBSD/sparc64 OpenFirmware Boot, Revision 1.7
\*[Gt]\*[Gt] (autobuild@tgm.netbsd.org, Thu May 20 16:29:20 UTC 2004)
.No Boot: Ic netbsd-INSTALL.gz
.disp)
After the initial probe messages you'll be
asked to start the install or upgrade procedure.
Proceed to the section
.Sx "Running the sysinst installation program"
below.
.
.Ss2 Installing NetBSD by using a netboot setup
.
.so ../common/netboot
.Pp
Now, netboot your system from the server by entering the appropriate
.Ic boot
command at the Open Firmware prompt.
.(disp
.No ok Ic "boot net netbsd"
.disp)
After the initial probe messages you'll be
asked to start the install or upgrade procedure.
Proceed to the section
.Sx "Running the sysinst installation program"
below.
.
.so ../common/sysinst
.Pp
Skip down to the section on
.Sx "Booting NetBSD for the first time"
.
.Ss2 Manual Installation of NetBSD using Solaris
.
(Adapted from Murray Stokely's \*[Lt]murray@osd.bsdi.com\*[Gt] instructions)
.Pp
You can use 
.Tn Solaris 
to prepare the 
.Nx
user-friendly installer or to perform a full manual installation of 
.Nx .
If you want to use the user-friendly miniroot installer or RAM disk 
installation kernel, follow the sections 
.Sx "Installing NetBSD by using the NetBSD miniroot"
or
.Sx "Installing NetBSD by using a NetBSD kernel on a Solaris partition" .
.Pp
Manual installation from Solaris 10 is not possible because NetBSD
cannot use the resulting UFS file system.  It is possible to install
Solaris 10 and NetBSD on the same disk.  To do so, partition the disk
with the Solaris format command, then boot NetBSD and perform a manual
installation.  Be careful not to write a NetBSD disklabel.  Use the
disklabel command to read the partition size, as constructed from the
Solaris disklabel.  By default the NetBSD newfs command writes a NetBSD
disklabel.  Avoid this by using the -F and -s arguments to newfs.
.Pp
.(bullet
.To 2 "Preparing the disk in Solaris"
.Em "Preparing the disk in Solaris"
.Pp
The first step is to format and label the disk that you would like to
use with
.Nx .
This can be accomplished with the 
.Xr format 1M
command in Solaris, which allows you to partition a disk and write a 
disklabel.  It also is used to perform a low-level format on SCSI drives.
You will want to create a root partition and a swap partition.
Depending on your preferences, you may also wish to create separate
.Pa /usr No or Pa /var
partitions.
.Pp
.(disp
.No #  Ic "/usr/sbin/format"
Searching for disks...
Mode sense page(3) reports nsect value as 280, adjusting it to 218
done

c0t1d0: configured with capacity of 16.95GB

AVAILABLE DISK SELECTIONS:
       0. c0t0d0 \*[Lt]SUN4.2G cyl 3880 alt 2 hd 16 sec 135\*[Gt]
          /pci@1f,4000/scsi@3/sd@0,0
       1. c0t1d0 \*[Lt]IBM-DXHS18Y-0430 cyl 8152 alt 2 hd 20 sec 218\*[Gt]
          /pci@1f,4000/scsi@3/sd@1,0
.No "Specify disk (enter its number):" Ic 1
selecting c0t1d0
[disk formatted]
.No "Disk not labeled.  Label it now?" Ic y

.No "format\*[Gt]" Ic format
Ready to format.  Formatting cannot be interrupted
and takes 114 minutes (estimated). Continue? y
Beginning format. The current time is Sat May 29 22:15:13 2004

Formatting...
done
Verifying media...
        pass 0 - pattern = 0xc6dec6de
   8151/19/208  
        pass 1 - pattern = 0x6db6db6d
   8151/19/208  

Total of 0 defective blocks repaired.
.No "format\*[Gt]" Ic partition
.No "partition\*[Gt]" Ic print
Current partition table (original):
Total disk cylinders available: 8152 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders        Size            Blocks
  0       root    wm       0 -   60      129.86MB    (61/0/0)     265960
  1       swap    wu      61 -  121      129.86MB    (61/0/0)     265960
  2     backup    wu       0 - 8151       16.95GB    (8152/0/0) 35542720
  3 unassigned    wm       0               0         (0/0/0)           0
  4 unassigned    wm       0               0         (0/0/0)           0
  5 unassigned    wm       0               0         (0/0/0)           0
  6        usr    wm     122 - 8151       16.69GB    (8030/0/0) 35010800
  7 unassigned    wm       0               0         (0/0/0)           0

.No "partition\*[Gt]" Ic label
.No "Ready to label disk, continue?" Ic y
.No "partition\*[Gt]" Ic quit
.No "format\*[Gt]" Ic quit
.disp)
.Pp
After your disk has been labeled you need to create file systems on
your slices.
The Solaris 
.Xr newfs 1M
command will create ffs file systems that can be used by
.Nx .
.(disp
.No # Ic "/usr/sbin/newfs /dev/dsk/c0t1d0s0"
.No # Ic "/usr/sbin/newfs /dev/dsk/c0t1d0s6"
.disp)
.
.It
.To 2 "Installing NetBSD Software from Solaris"
.Em "Installing NetBSD Software from Solaris"
.Pp
You should now mount your
.Nx
root and
.Pa /usr
partitions under Solaris so that you can populate the file systems with
.Nx
binaries.
.(disp
.No # Ic "/usr/sbin/mount /dev/dsk/c0t1d0s0 /mnt"
.No # Ic "mkdir /mnt/usr"
.No # Ic "/usr/sbin/mount /dev/dsk/c0t1d0s6 /mnt/usr"
.disp)
.Pp
Now extract the distribution file sets
.(disp
.No # Ic "cd ~/netbsd/binary/sets"
.No # Ic "gunzip *.tar.gz"
.No # Ic "echo ~/netbsd/binary/sets/*.tar | (cd /mnt; xargs -n1 pax -rpe -f )"
.disp)
.Pp
Now you should copy the
.Nx
second stage bootloader into your new root partition and install the 
bootblocks using Solaris's 
.Xr installboot 1M
command.
.(disp
.No # Ic "cp ~/netbsd/installation/misc/ofwboot /mnt"
.No # Ic "/usr/sbin/installboot ~/netbsd/installation/misc/bootblk /dev/rdsk/c0t1d0s0"
.disp)
.
.It
.To 2 "Creating NetBSD Device Nodes under Solaris"
.Em "Creating NetBSD Device Nodes under Solaris"
.Pp
This is not a necessary step.  If your 
.Pa /dev
directory is empty,
.Xr init 8
will create a RAM disk with all of the 
essential device nodes each time the system boots.  If you want to create 
the device nodes on disk, you will need to use the Solaris
.Xr mknod 1M
command.  Look in 
.Pa /dev/MAKEDEV
for the correct names, major and minor numbers, ownership, and 
permissions.
.
.It
.To 2 "Configuring the NetBSD system from Solaris"
.Em "Configuring the NetBSD system from Solaris"
.Pp
To save effort, you may want to use your favorite Solaris editor 
to configure some of the files in 
.Pa /etc
before booting into 
.Nx
the first time.  In particular, you should look at
.Pa /etc/fstab ,
.Pa /etc/rc.conf ,
.Pa /etc/resolv.conf ,
and
.Pa /etc/hosts .
See the section below on
.Sx "Post installation steps"
before
.Sx "Booting NetBSD for the first time" .
.bullet)
.
.Ss Booting NetBSD for the first time
.
.Pp
Now it is time to boot
.Nx
for the first time.
You will boot from your disk using similar syntax as described above in
.Sx "Setting up Open Firmware" 
and
.Sx "Determining how to boot from an SBUS or PCI card" .
To boot from your first disk, type:
.(disp
.No ok Ic "boot disk"
.disp)
