Table of Contents
This chapter collects various topics, in sparse order
Sysinst, the NetBSD installation program usually installs the NetBSD boot manager on the hard disk. The boot manager can also be installed or reconfigured at a later time, if needed, with the fdisk command. For example:
fdisk -B wd0
If NetBSD doesn't boot from the hard disk, you can boot it from the installation floppy and start the kernel on the hard disk. Insert the installation disk and, at the boot prompt, give the following command:
This boots the kernel on the hard disk (use the correct device, for example sd0a for a SCSI disk).
Sometimes fdisk -B doesn't give the expected result (at least it happened to me), probably if you install/remove other operating systems like Windows 95 or Linux with LILO. In this case, try running fdisk -i (which is known as fdisk /mbr from DOS) and then run again fdisk from NetBSD.
Though this is not an operation that you need to perform frequently, it can be useful to know how to do it in case of need. Please be sure to know exactly what you are doing before performing this kind of operation. For example:
dd if=/dev/zero of=/dev/rwd0c bs=8k count=1
The previous command deletes the disklabel (not the MBR partition
To completely delete the disk, the whole device
must be used.
dd if=/dev/zero of=/dev/rwd0d bs=8k
The commands above will only work as expected on the i386 and amd64 ports
of NetBSD. On other ports, the whole device will end in c, not d (e.g.
I found this tip on a mailing list (I don't remember the author).
To output a sound from the speaker (for example at the end of a
long script) the spkr driver can be used in
the kernel config, which is mapped on
/dev/speaker. For example:
echo 'BPBPBPBPBP' > /dev/speaker
The spkr device is not enabled in the generic kernel; a customized kernel is needed.
If you forget root's password, not all is lost and you can still recover the system with the following steps: boot single user, mount / and change root's password. In detail:
Boot single user: when the boot prompt appears and the five seconds countdown starts, give the following command:
At the following prompt
Enter pathname of shell or RETURN for sh:
Write the following commands:
fsck -y /
mount -u /
fsck -y /usr
Change root's password:
passwd rootChanging local password for root. New password:
(not echoed)Retype new password:
Exit the shell to go to multiuser mode.
If you get the error “Password file is busy”, please see the section below.
If you try to modify a password and you get the mysterious
message “Password file is busy”, it probably
means that the file
/etc/ptmp has not
been deleted from the system. This file is a temporary copy
/etc/master.passwd file; check
that you are not losing important information and then
If the file
/etc/ptmp exists you can
also receive a warning message at system startup. For
root: password file may be incorrect - /etc/ptmp exists
This section describes how to add a new hard disk to an
already working NetBSD system. In the following example a
new SCSI controller and a new hard disk, connected to the
controller, will be added. If you don't need to add a new
controller, skip the relevant part and go to the hard disk
configuration. The installation of an IDE hard disk is
identical; only the device name will be different
wd# instead of
As always, before buying new hardware, consult the hardware compatibility list of NetBSD and make sure that the new device is supported by the system.
When the SCSI controller has been physically installed in the system and the new hard disk has been connected, it's time to restart the computer and check that the device is correctly detected, using the dmesg command. This is the sample output for an NCR-875 controller:
ncr0 at pci0 dev 15 function 0: ncr 53c875 fast20 wide scsi ncr0: interrupting at irq 10 ncr0: minsync=12, maxsync=137, maxoffs=16, 128 dwords burst, large dma fifo ncr0: single-ended, open drain IRQ driver, using on-chip SRAM ncr0: restart (scsi reset). scsibus0 at ncr0: 16 targets, 8 luns per target sd0(ncr0:2:0): 20.0 MB/s (50 ns, offset 15) sd0: 2063MB, 8188 cyl, 3 head, 172 sec, 512 bytes/sect x 4226725 sectors
If the device doesn't appear in the output, check that it is supported by the kernel that you are using; if necessary, compile a customized kernel (see Chapter 32, Compiling the kernel).
Now the partitions can be created using the fdisk command. First, check the current status of the disk:
fdisk sd0NetBSD disklabel disk geometry: cylinders: 8188 heads: 3 sectors/track: 172 (516 sectors/cylinder) BIOS disk geometry: cylinders: 524 heads: 128 sectors/track: 63 (8064 sectors/cylinder) Partition table: 0: sysid 6 (Primary 'big' DOS, 16-bit FAT (> 32MB)) start 63, size 4225473 (2063 MB), flag 0x0 beg: cylinder 0, head 1, sector 1 end: cylinder 523, head 127, sector 63 1: <UNUSED> 2: <UNUSED> 3: <UNUSED>
In this example the hard disk already contains a DOS partition, which will be deleted and replaced with a native NetBSD partition. The command fdisk -u sd0 allows to modify interactively the partitions. The modified data will be written on the disk only before exiting and fdisk will request a confirmation before writing, so you can work relaxedly.
To create the BIOS partitions the command fdisk -u must be used; the result is the following:
Partition table: 0: sysid 169 (NetBSD) start 63, size 4225473 (2063 MB), flag 0x0 beg: cylinder 0, head 1, sector 1 end: cylinder 523, head 127, sector 63 1: <UNUSED> 2: <UNUSED> 3: <UNUSED>
Now it's time to create the disklabel for the NetBSD partition. The correct steps to do this are:
disklabel sd0 > tempfile
disklabel -R -r sd0 tempfile
Now we create some disklabel partitions, editing the
tempfile as already explained. The
# size offset fstype [fsize bsize cpg] a: 2048004 63 4.2BSD 1024 8192 16 # (Cyl. 0*- 3969*) c: 4226662 63 unused 0 0 # (Cyl. 0*- 8191*) d: 4226725 0 unused 0 0 # (Cyl. 0 - 8191*) e: 2178658 2048067 4.2BSD 1024 8192 16 # (Cyl. 3969*- 8191*)
When the disklabel has been created it is possible to optimize it studying the output of the command newfs -N /dev/rsd0a, which warns about the existence of unallocated sectors at the end of a disklabel partition. The values reported by newfs can be used to adjust the sizes of the partitions with an iterative process.
The final operation is the creation of the file systems for the newly defined partitions (a and e).
The disk is now ready for usage, and the two partitions can be mounted. For example:
mount /dev/sd0a /mnt
If this succeeds, you may want to put an entry for the partition
First shutdown to single user, partitions still mounted
(read-write); You can do that by just typing shutdown
now while you are in multi user mode, or reboot with
-s option and make
/dev read-writable by doing.
mount -u /
mount -u /dev
cp /dev/MAKEDEV* .
sh ./MAKEDEV all
mv dev olddev
mv newdev dev
rm -r olddev
Or if you fetched all the sources in
cp /usr/src/etc/MAKEDEV.local .
( cd /usr/src/etc ; make MAKEDEV )
cp /usr/src/etc/obj*/MAKEDEV .
sh ./MAKEDEV all
mv dev olddev; mv newdev dev
rm -r olddev
You can determine $arch by