Skip to main content.
Google custom search

NetBSD Documentation: Other FAQs and HOWTOs

General questions about NetBSD

User configuration

Printing and Scanning

Disks & Filesystems

Boot-Related Questions

Memory/Swap Configuration

Common (and less common) problems

Other Questions


General questions about NetBSD

What changed between NetBSD releases? (top)

A relatively up-to-date list of all changes (including those in NetBSD-current) is available.

There is also a CHANGES file in the top level directory of each release, and maintained online for previous and the next release.

Is NetBSD a 64 bit operating system? (top)

NetBSD runs on both 32 bit and 64 bit CPUs. On the alpha CPU the kernel and userland run in a mode known as LP64, where ints are 32 bit, and longs and pointers (and the address space) are 64 bit. The amd64 and sparc64 ports run in both 32-bit and 64-bit configurations. A 64 bit kernel (LP64) supports 32-bit applications in 64-bit mode. A 32 bit kernel, which uses 32 bits for all of integers, pointers and long integers (IPL32) can not run 64 bit programs.

On other 64 bit capable CPUs, such as R4000 and newer MIPS (used by a number of ports) NetBSD runs in 32 bit mode though is in the process of being modified to 64 bit.

All NetBSD ports support 64 bit arithmetic, both in the kernel and in userland programs. In the kernel this is used for various counters and for FFS, which is the 64 bit 'Fast File System'.

Is NetBSD exportable from the US? (top)

Up to (and including) NetBSD 1.4.x, everything except the security distribution (i.e. secr.tgz) was exportable from the US. The secr.tgz distribution file contained the libraries for crypt. Starting with NetBSD 1.5, crypto code is included in the NetBSD base distribution. Please refer to the NetBSD document on exporting restricted code or binaries.

For what is NetBSD used? (top)

In the words of Chris G. Demetriou (cgd@NetBSD.org):

NetBSD, in general, is meant as a "stable research platform" -- that is, a system that can be used for commercial, home, and research work... what _you_ do with it is up to you. In general, those of us working on NetBSD are trying to improve the system in whatever way we can -- support for more hardware, stability, performance, documentation...

See our features page for an idea of what opportunities NetBSD provides you with!


User configuration

Adding a user (top)

You can use the useradd(8) command to add users. Editing /etc/passwd will not work. If you want to edit the password database, use vipw(8). See pwd_mkdb(8) for more information.

Changing the information displayed via finger? (top)

Use the chfn(1) and chsh(1) commands, or use vipw(8) to edit /etc/master.passwd

Problems logging in as, or 'su'ing to, root (top)

This covers a number of possible problems:

  • Unable to login directly as root
    NetBSD will only allow direct root login on terminals marked as 'secure' in /etc/ttys (see ttys(5)). To be able to login directly as root across the network (not recommended) you will need to add 'secure' to the end of every network terminal line. For those who prefer not to have to edit each line you can (as root) type:
    		cd /etc
    		cp ttys ttys.orig
    		cat ttys.orig | sed 's/network$/network secure/' > ttys
  • Unable to 'su' to root
    NetBSD checks the contents of the 'wheel' group in /etc/group for any attempt to su(1) to root. If it is empty (wheel:*:0:) then anyone with the correct password can su to root. Otherwise it should be a comma separated (no spaces!) list of the permitted accounts.
  • Unable to 'su' to anyone

    Type "ls -l /usr/bin/su". The first 'word' on the output should be '-r-sr-xr-x'. If it is anything else (such as '-r-xr-xr-x'). Type (as root) "chmod 4555 /usr/bin/su". The 's' in that position indicates it is a 'setuid' binary, which in this case allows 'su' to run with root privileges.

    This problem can be caused by not giving the '-p' (preserve permissions) flag to tar when extracting the distribution. If this was the case then re-extract all the tarfiles (except etc.tar.gz) as various other utilities will also be broken.

Adding something to your path (top)

For example, to add /usr/X11R6/bin to your path, edit the file .login in your home directory and add the following:

set path = ( /usr/X11R6/bin $path )

This only works for the C-shell csh(1), and derivatives such as shells/tcsh. For sh(1) and derivatives (like shells/bash2), the correct syntax is:

PATH=/usr/X11R6/bin:$PATH
export PATH

Setting something for all users (top)

You can set something for all users running csh(1) or shells/tcsh by adding it to one of the following files:

  • /etc/csh.cshrc
    This is run every time a new shell is opened, before any .cshrc in the user's home directory.
  • /etc/csh.login
    This is run when the user logs in, after anything in /etc/csh.cshrc, but before any .login in the user's home directory.
  • /etc/csh.logout
    This is run when the user logs out, before any .logout in the user's home directory.

Cursor key editing or filename completion in a shell (top)

This depends on the type of shell you are using:

  • sh(1) (Bourne shell)
    This shell is used in single-user mode and is the standard user shell since NetBSD 4.0. Command line editing can be enabled with the command 'set -E' or 'set -o emacs'. Filename completion by TAB can be enabled by 'set -o tabcomplete'. The default configuration has both features enabled (in /etc/shrc, read from ~/.shrc). This can be added to the /.profile file so you always have command line editing in single-user mode.
  • csh(1) ('C' shell)
    This was the standard user shell until NetBSD 4.0, it supports filename completion ('set filec' and use the ESCAPE key) but does not support command line editing.
  • ksh(1) (Korn Shell)
    This is a public domain version of the Korn Shell, aka pdksh. It supports command line editing in both Emacs or Vi mode ('set -o {emacs,vi}'). In Emacs mode, filename and command completion by TAB is enabled by default. Use 'set -o vi-tabcomplete' or 'set -o vi-esccomplete' to get Vi mode with completion by TAB or ESC, respectively.
    The public domain korn shell is part of the NetBSD base system, but is also available from the NetBSD packages collection, under shells/pdksh for other operating systems. The KSH-93 is also available in shells/ast-ksh.
  • bash (GNU Bourne Again Shell)
    'bash' is another extended shell with command line editing, this time based on 'sh'. You can install it from the NetBSD packages collection, under shells/bash2.
  • tcsh (an extended 'C' shell)
    'tcsh' is a near perfect superset of csh, with many useful extra features, including filename completion (use TAB) and command line editing. You can install it from the NetBSD packages collection, under shells/tcsh.
  • Other shells
    The NetBSD packages collection also contains various other command line shells under the shells category.

Specifying a language for messages (top)

NetBSD uses the 'LANG' environment variable determine which language to use for error messages and suchlike. This can be set in csh or tcsh with the command 'setenv LANG XX' where XX is the two letter country code. For a list of supported codes type 'ls /usr/share/nls'.

Please note: Only certain messages have been translated. To test, set the LANG variable and type

  cd /a_directory_that_does_not_exist


Printing and Scanning

Printing man pages as PostScript (top)

Man pages are held in nroff(1) source in /usr/share/man/manX/manpage.X, where X is the section number (eg: 1 in the case of nroff). To convert them into PostScript one can use:

groff -Tps -mandoc /usr/share/man/manX/manpage.X

For example to convert the ls(1) man page into PostScript and send it directly to the default printer via lpr(1) you can use.

groff -Tps -mandoc /usr/share/man/man1/ls.1 |lpr

If you wish to print on a different type of printer you may want to use the print/ghostscript package from pkgsrc.

Printing to a remote SMB printer from NetBSD (top)

Please see this page for details.

Configuring a HP JetDirect Card via DHCP (top)

If you have a JetDirect print server such as the JetDirect EX Plus, you can use dhcpd(8) under NetBSD to configure the print server. The steps are: Create an entry in /etc/dhcpd.conf for the JetDirect server:

options jd-tftp-cfg		code 144 = string;
options jd-tftp-server		code 150 = string;

allow				bootp;

# [...]

host hp690c {
	fixed-address		hp690c;			# set to the DNS name or address of the JetDirect
	hardware ethernet	00:60:b0:00:11:22;	# set to the MAC address of the JetDirect
	option	log-servers	servername;		# set to the DNS name or address of log server
	option	jd-tftp-server	servername;		# set to the DNS name or address of tftp server
	option	jd-tftp-cfg	"hpnp/hp690c.cfg";	# name of the JetDirect config file
}

See dhcpd.conf(5) for more information on this file.

Make sure that tftpd is enabled in /etc/inetd.conf, Note the argument to "-s" on the tftp line of /etc/inetd.conf. This is the tftpd(8) root directory. For the rest of this example it is assumed that the tftpd(8) root directory is set to /tftpboot.

Make sure that dhcpd is enabled in /etc/rc.conf.

Next create a Network Printer Interface (NPI) configuration file. In this example, the file is /tftpboot/hpnp/hp690c.cfg. This file should look something like:

name: printer name
location: Location of the Printer
contact: Contact Person
idle-timeout: 1800
banner: 0

If you made changed to /etc/inetd.conf, make sure inetd(8) re-reads inetd.conf(5) by doing kill -HUP `cat /var/run/inetd.pid`. When you reboot the JetDirect print server (or printer with HP JetDirect card), the server should get configured by DHCP. On some printers, you may have to explicitly enable BOOTP/DHCP configuration from the front panel.

Why doesn't sh suppress the "burst" page on an HP JetDirect? (top)

The "burst" page is a function of the host with the locally attached printer, or in this case, the dedicated hardware emulating lpd(8). When NetBSD is used as a remote spooler, with rm, it never adds an additional burst page. The JetDirect's "burst" page is an unusual feature in a dedicated device. HP (TM) actually calls it a "trailer". You can disable it as above, by setting banner: 0, or simply telnet to port 23 of the device, and issue the command banner 0, then quit.

Some JetDirect units may need their firmware upgraded to add the banner command. You will need to use the appropriate JetDirect network management tools available from HP to do this. You may need to set the SNMP read and write community strings to known values in order to perform this upgrade. To set these, use the following lines in the NPI configuration file.

get-community-name: read-password
set-community-name: write-password

(See the above section on configuring the JetDirect cards with DHCP.) Just be aware of the security ramifications of leaving these entries in a publicly available (via TFTP) configuration file...

Scanning under NetBSD (top)

NetBSD supports various different SCSI scanners using the graphics/sane-backends scanning package. Frontends for accessing the API provided by that package are in the graphics/sane-frontends package, or it can be called directly by graphics tools such as the graphics/gimp.

Note: in versions of NetBSD before 1.4.2 the in kernel ss(4) scanner driver may cause problems with graphics/sane-backends and some scanners - the solution is either to recompile a kernel without ss(4) and use the uk(4) device, or to upgrade to 1.4.2 or later.


Disks & Filesystems

Adding a disk to an existing system (top)

  1. Halt the system
  2. Connect the new drive
  3. If your machine has a PROM or BIOS that can list drives, check that the drive is recognised:
    • recent sparc: Press [STOP][A] before the boot starts, then at the "ok" prompt, probe-scsi.
    • i386 with adaptec BIOS: Press [CTRL][A] before the boot starts to enter the BIOS.
    • other: more details welcomed :)
  4. boot
  5. Check dmesg(8) output to confirm that the drive is recognized
  6. Write a disklabel(5) including the partitions using disklabel(8)
    (if the disk doesn't have a disklabel yet, you'll probably do something like:
     disklabel -i -I sd1 # ignore any "sd1: no disk label"
    Partition 'c' is reserved for the entire NetBSD portion of a disk, and on some ports (notably i386), 'd' is similarly reserved for the entire disk. The following is a sample session setting the entire disk to be one filesystem 'e':
    	partition> e
    	Filesystem type [?] [unused]: 4.2BSD
    	Start offset [0c, 0s, 0M]:
    	Partition size ('$' for all remaining) [0c, 0s, 0M]: $
     	e: 234375000         0     4.2BSD      0     0     0   # (Cyl.    0 - 232514*)
    	partition> W
    	Label disk [n]? y
    	partition> Q
    Inside disklabel -i you can use '?' for additional help.
  7. For each filesystem added, newfs <filesystem> (where <filesystem> is the partition's raw device, like /dev/rsd1e, /dev/rwd1f, ...)
  8. Put the filesystems into /etc/fstab
  9. fsck(8) them:
    fsck -f <filesystem>
  10. mount(8) them:
    mount -va

Moving /usr from root to a different partition (top)

  1. Make sure that the desired new location (e.g. /dev/sd0e) does not overlap any existing partitions. Check the output from disklabel(8).
  2. If it does not already contain a filesystem, run
    # newfs /dev/sd0e
  3. Mount it and copy across data:
    # mount /dev/sd0e /mnt
  4. # cd /usr
  5. # pax -rw -pe . /mnt
  6. # umount /mnt
  7. Edit /etc/fstab and add '/dev/sd0e /usr ffs rw 1 2' (change /dev/sd0e for your situation).
  8. Shutdown to single user mode and make new mountpoint:
    # shutdown now
  9. # mv /usr /usr.old
  10. # mkdir /usr
  11. Bring system up, test, and when all OK, 'rm -rf /usr.old'.

How to mount a 'read-only' filesystem read/write? (top)

Use mount(8)'s -u (update) switch: 'mount -u /'. More than likely, you booted single-user which mounts the root filesystem read-only by default. This gives you a chance to run fsck by hand before bringing the system up into multi-user. One other way to mount all the filesystems in /etc/fstab as read/write is to use 'mount -a'.

However, the best way to do this is to go into multi-user mode by exiting from your single-user shell. This will mount all of the filesystems in /etc/fstab in whatever mode they are listed.

When is it safe to use fsck? (top)

Only use fsck(8) on an unmounted or read-only filesystem. Running fsck(8) on a r/w filesystem is dangerous and could corrupt the filesystem. If you bring the system up into single-user mode, the system will be mounted read-only. From there you can do an 'fsck -p' to check all filesystems before bringing the system up into multi-user mode. If the filesystem has previously been marked "clean," and you still want to check it, you can use the -f flag to fsck(8).

If you do make any changes to the filesystem using fsck, it is probably best to type 'reboot -n' to reboot the machine immediately without syncing the disks.

For what is /kern used? (top)

It is used for mounting the kernfs filesystem. See the mount_kernfs(8) manual page.

For what is /proc used? (top)

It is used for mounting the procfs filesystem. Consult The Design and Implementation of the 4.3BSD UNIX Operating System by Leffler, McKusick, et al., p. 104-5, 436. Also see the mount_procfs(8) manual page.

This is normally used by creating a '/proc' directory as root, then adding the following to /etc/fstab (see fstab(5)):
/proc /proc procfs rw 0 0

As /proc in NetBSD is intended for process-related data only, other entries known from linux are not present. This can be changed by adding the "linux" mount option to the file system flags, though:
/proc /proc procfs rw,-olinux 0 0

Encrypted swap with cgd(4) (top)

Since the topic of swap encryption pops up from time to time, this information could be useful for some people who are interested in encrypting their swap space but are not sure how to set it up.

Currently there is one limitation, cgd devices are created with disklabel containing only one slice marked as 4.2BSD which is not suitable for swapping into. This is the reason why using cgd drive as a swap device is not straightforward. Roland Dowdeswell is looking into this and it should be resolved in the near future.

A real world example: Our swap device wd0b will be configured as cgd1, using 256 bit aes-cbc key. Step by step instructions follows:

  1) generate a paramsfile for the cgd device.  the default file would be
     /etc/cgd/wd0b but i will use /etc/cgd/swap for better illustration:

     # cgdconfig -g -V none -k randomkey aes-cbc > /etc/cgd/swap

  2) configure the cgd device over wd0b, (make sure wd0b is not used as a
     swap device at this moment):

     # cgdconfig cgd1 /dev/wd0b /etc/cgd/swap

  3) edit disklabel for cgd1, we need to create a valid swap slice.  save
     the disklabel to a file:

     # disklabel -e -I cgd1

     # /dev/rcgd1d:
     type: cgd
     disk: cgd
     label: default label
     flags:
     bytes/sector: 512
     sectors/track: 2048
     tracks/cylinder: 1
     sectors/cylinder: 2048
     cylinders: 128
     total sectors: 263655
     rpm: 3600
     interleave: 1
     trackskew: 0
     cylinderskew: 0
     headswitch: 0           # microseconds
     track-to-track seek: 0  # microseconds
     drivedata: 0

     4 partitions:
     #        size    offset     fstype  [fsize bsize cpg/sgs]
      d:    263655         0     4.2BSD      0     0     0   # (Cyl.    0 - 128*)

     create a swap slice and change label (that's not really necessary, just for
     our information):

     # /dev/rcgd1d:
     type: cgd
     disk: cgd
     label: swap
     flags:
     bytes/sector: 512
     sectors/track: 2048
     tracks/cylinder: 1
     sectors/cylinder: 2048
     cylinders: 128
     total sectors: 263655
     rpm: 3600
     interleave: 1
     trackskew: 0
     cylinderskew: 0
     headswitch: 0           # microseconds
     track-to-track seek: 0  # microseconds
     drivedata: 0

     4 partitions:
     #        size    offset     fstype  [fsize bsize cpg/sgs]
      a:    263655         0       swap                      # (Cyl.    0 - 128*)

     and save it to a file:

     # disklabel cgd1 > /etc/cgd/swap.disklabel

  4) set up the cgd device to be configured automatically at boot.  add the
     following line into your /etc/cgd/cgd.conf:

     cgd1 /dev/wd0b /etc/cgd/swap

  5) now we need to restore our disklabel to the newly created cgd device at
     boot time.  create /etc/rc.conf.d/cgd with this simple function:

     swap_device="cgd1"
     swap_disklabel="/etc/cgd/swap.disklabel"
     start_postcmd="cgd_swap"

     cgd_swap()
     {
             if [ -f $swap_disklabel ]; then
                     disklabel -R -r $swap_device $swap_disklabel
             fi
     }

  6) add the cgd device into /etc/fstab as a swap device:

     /dev/cgd1a none swap sw 0 0

That's all. Now you can activate your swap partition with 'swapctl -a /dev/cgd1a' or just reboot.

What you see above is a setup from my laptop.

   Device      1K-blocks     Used    Avail Capacity  Priority
   /dev/cgd1a     131827     8828   122999     7%    0


Boot-Related Questions

What is single-user mode? Why and how should you use it? (top)

'single-user' mode is when the kernel has booted, but only runs a single shell on the console. If you boot single-user only the root filesystem will be mounted, and it will be mounted read-only. Among the many uses for single-user mode are:

  • fsck your filesystem due to suspected corruption.
  • edit corrupted system configuration files in /etc.
  • install a new set of binaries which you downloaded or compiled yourself.
  • make a backup of your filesystem without worrying about interference from user processes.

You can enter single-user mode by running 'shutdown now' as root on a running system, or by booting the system with the '-s' flag (the method for doing this varies from port to port).

Once booted single-user you may find some of the following commands useful:

  • fsck -p ; mount -va
    Check the filesystems with fsck(8), then make them available with mount(8).
  • set -E
    Enable command line editing.
  • TERM=vt220 ; export TERM
    Set and export the TERM variable, to permit editors such as vi(1) to work. Note: You may need to use a different terminal type from 'vt220', depending on the console type.
  • sh /etc/rc.d/network start
    Bring up the network. If you have any nfs mounted filesystems you may want to do this before the fsck and mount. If you have a system prior to NetBSD 1.5, the command to use is sh /etc/netstart.

How to switch from single-user to multi-user (top)

Exit the single-user shell with "exit" or ctrl-D.

The system will boot up to multi-user mode, starting all kind of services, etc. Note that disks are not checked when going from single-user to multi-user mode!

How to read the boot messages? (top)

The system message buffer can be displayed with dmesg(8). This is usually (in 1.4 and later) automatically stored in /var/run/dmesg.boot immediately after each boot. If kernfs (see mount_kernfs(8)) is enabled, as in install kernels, you can also more /kern/msgbuf.

How to shutdown the machine? (top)

To drop back into single-user mode, use 'shutdown now'. To halt the machine, use 'shutdown -h now'. On some ports, you may need to use 'shutdown -p now' to actually power off the machine. Please see the shutdown(8) manual page for complete details.

How to reboot the machine? (top)

Use 'shutdown -r now' or 'reboot'. See the shutdown(8) or reboot(8) manual pages for further details.

Starting a program at boot time (top)

To start programs at system boot time, any commands can be added to /etc/rc.local, which will be ran at the end of the boot process.

As an alternative mostly for non-root users, the Vixie cron(8) (used in NetBSD)'s special @reboot time specification can be used to start a given program at cron(8) startup time, which usually coincides with the system booting. This also allows users without root privileges to run commands automatically at startup.


Memory/Swap Configuration

How much swap space (top)

On older unix systems it was recommended to have twice as much swap space as RAM. This was because active pages in RAM had to have pages allocated in swap, effectively limiting the total virtual memory to the size of the swap space. On NetBSD this is no longer true, so total virtual memory is approximately swap + RAM.

Under NetBSD there are three primary uses for swap space:

  1. Additional virtual memory
    Less active pages containing modified data can be migrated to swap space allowing virtual memory to be larger than physical memory.
  2. An area for kernel core dumps
    This is then read by savecore(8), on boot. For this to work the primary swap partition must be slightly larger than the total RAM.
  3. For mfs(8) filesystems
    Classically mounted on /tmp in order to speed up any programs using /tmp, by adding the following to the fstab(5) file:
    	swap  /tmp  mfs  rw,-s=SIZE 0 0
    where SIZE is in 512byte blocks. The space required is taken from the swap space as the filesystem is used.

The 'correct' value for swap is dependent on the usage of the system, but for some general rules:

  • A good base size is the larger of RAM or 32MB, plus the total size of any mfs(8) filesystems.
  • If you intend to run X(7), add the larger of 1/2 of RAM or 16MB.
  • Always try to split swap across as many disks as possible to increase the available swap bandwidth.
  • Guess high, rather than low - running out of swap can cause the system to have to kill running processes.

Adding more swap to a running system (top)

Systems should be configured with sufficient swap space, as per the How much swap entry.

There are three ways to add swap to a configured system:

  1. Rebuild the system disk, using a larger swap partition.
    While arguably the cleanest solution, this obviously involves significant disruption.
  2. Add an additional swap partition.
    When you add a disk it is usually a good idea to include a small 'b' partition for additional swap, and add an entry of the form:
    	/dev/DISKb       none    swap sw 0 0
    to your /etc/fstab file to automatically enable on boot. (Where DISK is the disk name such as 'sd1' or 'wd2').
  3. Create a swap file.

    The quickest and simplest option is to create a file in an existing filesystem, and use it as additional swap space. While accessing this will be slightly slower than dedicated swap partitions (due to fragmentation and filesystem overhead), it is ideal for solving a temporary swap shortage.

    To add 10 MBytes of swap space is as easy as selecting a filesystem with sufficient free space and:

    	# dd if=/dev/zero bs=1m count=10 of=/somefilesystem/swap
    	# chmod 600 /somefilesystem/swap
    	# swapctl -a -p 1 /somefilesystem/swap

    The dd(1) command creates a 10 MByte file `/somefilesystem/swap'. This swap file needs to be chmod(1) 600 so that unprivileged users may not read its contents (swapctl(8) will reject world readable files). Then swapctl(8) command adds /somefilesystem/swap to the system swap space at priority 1. Priority 0 is the (default) highest priority, and since swapping to files is slightly slower we only want the system to use the file when conventional swap has all been used.

    To make swapping to that file permanent and enable it on every reboot, put something like the following into /etc/fstab:

    /somefilesystem/swap none swap sw,priority=1 0 0

Tuning Virtual Memory to improve performance on low-memory systems (top)

According to a post by Simon Burge on the tech-kern list, it is possible to greatly improve the performance of small-memory machines by tweaking the virtual memory settings. While it is in your best interests to read his entire post and decide for yourself what your settings should be, the gist is that you'll want to run sysctl -w vm.anonmax=95. According to the sysctl(3) page, this changes "The percentage of physical memory which will be reclaimed from other types of memory usage to store anonymous application data."


Common (and less common) problems

/usr/bin/nroff: not found when running 'man' (top)

You need to install the 'text' set, text.tgz. See your base install notes.

'Unable to lock mailbox: Permission denied' when reading mail (top)

Check the permissions on the /var/mail directory. They should be 'drwxrwxrwt':

% ls -ld /var/mail
drwxrwxrwt  2 root  wheel  512 Nov  6 08:21 /var/mail

If they are not, as root run 'chmod 1777 /var/mail'.

netstat: kvm_read kvm_read: Bad address when running 'netstat -r' (top)

This is nothing to worry about. Basically, the file /netbsd is not your current kernel. A number of programs (such as ps, who, systat etc.) and libkvm kvm(3), access /netbsd to learn what's going on in the kernel. So you can simply rename your current kernel to /netbsd to make this kind of error go away. Make sure that you are not overwriting a working kernel when you do this, though, unless that is exactly what you intend to do.

When I try 'netstat -r' I get an endless stream of question marks. What's wrong? (top)

That's a mis-match between libkvm/netstat and /netbsd. Or it's that you're running a kernel that's not named /netbsd. Other symptoms of this problem are likely to be that who, ps, ifconfig, and systat will not work either. If you update your binaries and your kernel at the same time, then you should be OK.

w, ps, and netstat do not work after upgrading to a new kernel (top)

One of two things. Either your currently booted kernel isn't named /netbsd or else you have a mismatch between your kernel and the binaries you are using. In the first case, simply making a link from your currently booted kernel to /netbsd will solve the problem.

In the second case, dynamically linked binaries can usually be fixed by upgrading libkvm to match your new kernel. Statically linked binaries need to be replaced with more recent versions. Since they are statically linked, if you are going to recompile them yourself, you need to rebuild libkvm.a before you rebuild the program in question.

Thanks to John Wittkowski (jpw@netscape.com), here is a list of most of the programs (besides /bin/ps) that depend on libkvm (all of these are in /usr/bin):

  • fstat
  • gdb
  • ipcs
  • netstat
  • nfsstat
  • systat
  • uptime
  • vmstat
  • w

After changing kernels, 'ps' reports "proc size mismatch" (top)

Like the previous three questions on this subject, the answer is most likely that your libkvm is out of sync with your kernel or binaries. To solve this problem, you can either get a binary distribution which matches your kernel, or you can build you own by following the instructions below:

If you get the "proc size mismatch" error and you determine
that you need to update your libs, here's what to do:

1. Get all the source code. If you're not willing to do this
   and recompile things than you'll have to find someone who
   will do it for you and you can try installing everything
   by hand.

2. Make sure that your include files are up to date. Do
   this by:
      cd /usr/src
      make includes
   This will take a while. I had some trouble with this
   because some of the Makefiles didn't have the INSTALL
   variable defined. Whenever the "make includes" failed,
   I went to the last directory listed and added the
   following line to the Makefile:
      INSTALL=/usr/bin/install
   I had to do this several times before the make finished
   without any errors.

   (If you make sure that /usr/bin/make and all the files in
   /usr/share/mk are up to date first, the above difficulties
   can probably be avoided)

3. Rebuild the libkvm and install it:
      cd /usr/src/lib/libkvm
      make
      make install
   Note that in order to get the libkvm to compile on
   my system I had to add the following link:
      cd /usr/include/machine
      ln -s ../m68k/kcore.h kcore.h
   This may have been a quirk of my system so try
   compiling without it first.

4. Then rebuild the binaries that are STATICALLY linked to
   libkvm. The only statically linked program that I am
   aware of is "/bin/ps". To rebuild ps, simply:
      cd /usr/src/bin/ps
      make
      make install

5. You may or may not need to rebuild the binaries that
   are dynamically linked to libkvm. This is because (I
   think) if the major version number of the lib changes
   then the old binaries will expect the old version
   number and not work with the newer version of the lib.
   For example, my old libkvm was libkvm.so.4.0. The new
   one was libkvm.so.5.0. Without recompiling the
   dynamically linked binaries, it would still complain
   about "proc size mismatch" (if the 4.0 lib was still
   there) or some lib missing error (if the 4.0 lib
   had been removed from /usr/lib). If the version minor
   number changes (4.0 to 4.1, for example), I think it
   will run with a warning and so you may not need to
   recompile all of these things.

   The dynamically linked binaries that I am aware of
   will give the  "proc size mismatch" error (if the 4.0
   lib was still there) or some lib missing error (if the
   4.0 lib had been removed from /usr/lib). If the version
   minor number changes (4.0 to 4.1, for example), I think
   it will run with a warning, and you may not need to
   recompile all of these things.

   The dynamically linked binaries that I am aware of
   are:
      /usr/bin/fstat
      /usr/bin/gdb
      /usr/bin/ipcs
      /usr/bin/netstat
      /usr/bin/nfsstat
      /usr/bin/systat
      /usr/bin/uptime (linked to /usr/bin/w)
      /usr/bin/vmstat
      /usr/bin/w
   Note that /usr/bin/uptime is a link to /usr/bin/w and
   will be set up properly when you do the "make install"
   for w.

   To recompile these, do the following:
      cd /usr/src/usr.bin/<cmd>
      make
      make install
   For example, to recompile /usr/bin/vmstat:
      cd /usr/src/usr.bin/vmstat
      make
      make install

Much thanks to John Wittkowski (jpw@netscape.com) for providing such a detailed answer for this one.

A little background: the reason that these system utilities need to grovel through kernel memory to get information, including going through all the trouble mentioned above, is that this method also works on kernel crash dumps, which can be quite a useful feature when debugging kernels.

'hash map "Alias0":unsafe map file /etc/aliases: No such file or directory' is displayed (top)

You can fix this by typing 'newaliases' as root.
Sendmail reports this when the aliases(5) file is not present. Note that sendmail(8) actually uses /etc/aliases.db (which is a fast lookup hash(3) map built from /etc/aliases), so the error message can be a little misleading. This should only really be noticed in NetBSD 1.3 to 1.4, other versions have a different /etc/sendmail.cf which instructs sendmail to automatically rebuild /etc/aliases.db as needed. If you are not running at least NetBSD 1.4.1 you should probably upgrade to a newer formal release.

How do I prevent portmap messages from showing up in shells, when logged in as root (top)

Use security/sudo and never log in as root.

If you must log in as root, then you can edit your /etc/syslog.conf file and remove the necessary facilities to prevent the annoying messages. In most cases, it's sufficient to disable auth.debug in the line reading:

*.notice;auth.debug                                     root

This will eliminate those annoying portmap [pid]: connect from some.other.host ... messages. Be sure to kill -HUP the pid of your syslogd process.

You may also wish to look at the FAQ entry for using an xconsole.

How do I get umlauts and other localised characters displayed? (top)

Per default, NetBSD has already numerous locales installed. You can find them in /usr/share/locale. Choose the locale most suitable for your location and set the LC_ALL environment variable accordingly. Note that it is not sufficient to set LC_ALL to, say, ``de_DE'', but that you should use the full locale, such as ``de_DE.ISO8859-15''.


Other Questions

How does Bluetooth support in NetBSD work? (top)

The first official NetBSD version that comes with Bluetooth support is NetBSD 4.0.

Editing files under NetBSD (top)

There are two obvious options in the base system:

There are a large number of editors available under the editors category in pkgsrc, including:

  • editors/joe
    A small, fast editor capable of emulating WordStar and emacs key bindings (jstar, jmacs). editors/joe will be familiar to people who have used Borland IDEs.
  • editors/pico
    A very simple to use text editor, as used in the mail/pine mail package.
  • editors/nedit
    A simple yet reasonably flexible X based GUI editor.
  • editors/emacs
    A proverbial 'everything and the kitchen sink' editor, including a complete lisp interpreter. Not recommended for small machines.

Rebuilding /dev (top)

The /dev directory contains the necessary device files for accessing hardware and pseudo devices. If it becomes damaged, much strangeness can ensue. To rebuild the /dev directory, you should first boot single-user (it should be possible to perform while multiuser, but this is not recommended), then:

mkdir /newdev
cd /newdev
cp /dev/M* .
sh MAKEDEV all
cd /
mv dev olddev; mv newdev dev
rm -r olddev

Connecting a UPS to a NetBSD system (top)

Connecting one is trivial, but monitoring it such that the NetBSD can shut down cleanly when the power is about to fail requires a little more:
Simon J. Gerraty has a page on using a APC Smart-UPS. If you are writing your own software to talk to the UPS you will probably need to set the softcar flag via tcsetattr(). Wolfgang Rupprecht has researched the field briefly:

There two different types of UPS interfaces, sometimes both are available on the same UPS. The 9-pin connector on the UPS is never a wired up as a normal PC-style rs-232. At best its a three-wire rs-232 interface, with the pins rearranged just to keep things interesting. At worst its a contact closure signal that is not even at the rs-232 signaling voltages and one must use a funny cable with level-translators in it to convert the voltages to something the rs-232 port can even see transitions on. The signal from the latter type of interface can only send out a one-bit (normal / powerfail) signal. It must be run into some modem-control line such as DCD and is then detected via a program that checks the status of that modem control line. Unless one is careful, it is possible to confuse the modem-control-line-only cables that come with some UPSs as a real rs-232 cable.

Poking around APC web page, and a few promising altavista hits revealed that they have 3 basic interfaces. Low end UPSs ("back UPS") have only the modem-control line type interface. The two high end lines ("Back UPS Pro", "Smart UPS") have both combination modem control line and 3-wire rs-232 signals available. In both cases one needs to use one of two special cables. The cable for the modem control line interface has transistors and diodes in it to do the level shifting (and power grabbing from some of the other wires). It's a real kludge, with the word UGLY coming to mind as the correct modifier. The second type of cable will get the UPS talking serially, but some of the 3-rd party docs indicated that the UPS will only talk if you send 2 stop bits. The protocols don't appear to be officially documented and the back-UPS pro and smart UPS appear to talk different serial line protocols. Only the back-UPS pro line appears to have any 3-rd party support, and many of the details of the protocol are only guessed at.

Competitors all seem to have similar offerings (modem control line only, and proprietary serial line protocols with special cables). In no case could I find someone with an openly documented standard.

After changing /etc/motd something reset it to its original contents (top)

If you delete the header of /etc/motd, the startup process will overwrite your changes on boot. This can be disabled by setting update_motd=NO in /etc/rc.conf, in which /etc/motd will not be touched at all, and you can change it at will.

Where to sell NetBSD related hardware? (top)

For occasional items you can generally post to a given port's mailing list, and to netbsd-forsale@mono.org. If you would be willing to donate any hardware to assist in the development of NetBSD you should check the Hardware contributions page, or contact finance-exec@NetBSD.org.

Setting up a striped (ccd) drive (top)

Disk striping can either be done with RAIDframe or ccd(4) in NetBSD. Here is how to use ccd(4):

  1. disklabel all disks:
    create the partitions you want to concatenate, make sure there's an offset to the beginning (I think 16 sectors is more than enough - but I'm not sure). I don't know if the type matters, I've used "normal" 4.2BSD partitions.
  2. configure the ccd.
    For performance tuning you will have to experiment a little to find the best interleave. 48 works fine for me with two disks. AFAIK with 16 and some other numbers it can happen that all inodes will be on the same disk, which should be avoided for performance reasons. IIRC I got some problems, if the number of sectors of an component is not a multiple of the interleave.
  3. disklabel the ccd as you would do with a normal harddisk
  4. newfs the ccd.
  5. mount it.

See the ccd(4) and ccdconfig(8) man pages for more information.

Utility for editing or creating console bitmap fonts? (top)

Install the sysutils/pcvt-utils package. It provides fed and fontedit: two font editors that can also be used on the fonts in /usr/share/wscons/fonts.