Chapter 5. The second boot

Table of Contents
5.1. dmesg
5.2. Mounting the CD-ROM
5.3. Mounting the floppy
5.4. Accessing a DOS/Windows partition
5.5. Adding users
5.6. Shadow passwords
5.7. Localization
5.8. Stopping and rebooting the system

During the first boot you have set up a basic system configuration. This chapter describes some common commands and operations.

5.1. dmesg

At system startup the kernel displays a long sequence of messages on the screen: these messages give information about the kernel status (for example, available memory) and the peripherals that have been detected on the system. This information is very important for diagnosing hardware or configuration problems, and for determining the name of the devices for the peripherals (for example you can check if your network card has been detected as ne0 or ne1.) Usually these messages scroll on the screen too fast to be useful, but you can use the dmesg command to view them again.

# dmesg | more    

If something on your system doesn't appear to work correctly and you ask for help on one of the NetBSD mailing lists, always remember to include the relevant dmesg output in your post: it will help other people diagnose your problem.

5.2. Mounting the CD-ROM

New users are often surprised by the fact that although the installation program recognized and mounted their CD-ROM perfectly, the installed system seems to have "forgotten" how to use the CD-ROM. There is no special magic for using a CD-ROM: you can mount it as any other file system, all you need to know is the device name and some options to the mount command. You can find the device name with the aforementioned dmesg command. For example, if dmesg displays:

# dmesg | grep ^cd
cd0 at atapibus0 drive 1: <ASUS CD-S400/A, , V2.1H> type 5 cdrom removable    

the device name is cd0, and you can mount the CD-ROM with the following commands:

# mkdir /cdrom
# mount -t cd9660 -o ro /dev/cd0a /mnt/cdrom
    

To make things easier, you can add a line to the /etc/fstab file.

/dev/cd0a /cdrom cd9660 ro,noauto 0 0    

Without the need to reboot, you can now mount the cdrom with:

# mount /mnt/cdrom    

When the cdrom is mounted you can't eject it manually; you'll have to unmount it before you can do that:

# umount /mnt/cdrom    

There is also a software command which unmounts the cdrom and ejects it:

# eject cd0    

5.3. Mounting the floppy

To mount a floppy you must know the name of the floppy device and the file system type of the floppy. For example, to read and write a floppy in MS-DOS format, first create the mount point:

# mkdir /mnt/floppy    

Now you can mount the floppy with the following command:

# mount -t msdos /dev/fd0a /mnt/floppy    

Instead of /mnt/floppy, you can use another directory of your choice. If you do a lot of work with MS-DOS floppies, you will want to install the "mtools" package, which enables you to access a MS-DOS floppy (or hard disk partition) without the need to mount it. It is very handy for quickly copying a file from/to floppy.

5.4. Accessing a DOS/Windows partition

If NetBSD shares the hard disk with MS-DOS or Windows, it is possible modify the disklabel and make the DOS partitions visible from NetBSD. First, you must determine the geometry of the DOS partition , for example using fdisk.

# fdisk wd0
NetBSD disklabel disk geometry:
cylinders: 6232 heads: 16 sectors/track: 63 (1008 sectors/cylinder)
...
Partition table:
0: sysid 6 (Primary 'big' DOS, 16-bit FAT (> 32MB))
    start 63, size 2088516 (1019 MB), flag 0x80
        beg: cylinder    0, head   1, sector  1
        end: cylinder  259, head   0, sector  4
1: sysid 169 (NetBSD)
    start 2088579, size 4193277 (2047 MB), flag 0x0
        beg: cylinder  259, head   0, sector  4
        end: cylinder  779, head   0, sector  1
2: <UNUSED>
3: <UNUSED>    

Note: this example uses the wd0 hard disk: substitute the device for your hard disk.

The output of the fdisk command shows that the DOS partition begins at sector 63 and has a size of 2088516 sectors. The NetBSD partition begins at sector 2088579 (2088579 = 2088516 + 63). You will use this data to modify the BSD disklabel: all you have to do is add one line which defines the position and type of the MS-DOS partition, choosing one of the still unused partition id letters. Use the disklabel command to modify the disklabel. If you give the -e option to disklabel it will invoke your favourite editor ($EDITOR) to modify the disklabel. For example:

# disklabel -e wd0
...
#        size   offset     fstype  [fsize bsize  cpg]
...
  e:  3450624  2831232    4.2BSD    1024  8192    16   # (Cyl.  2808* - 6231)
  f:  2088516       63    MSDOS    

The partitions from "a" to "e" were already used by NetBSD and the first available id was "f". The "size" and "offset" fields have been filled with the previously calculated numbers. Next, the mount point must be created. For example:

# mkdir /msdos    

finally, a line will be added to the /etc/fstab file.

/dev/wd0f /msdos msdos rw,noauto 1 3    

Now the MS-DOS partition can be mounted with a simple command:

# mount /msdos    

With this method you can mount FAT and FAT32 partitions. If you want to mount the partition(s) automatically at startup, remove the "noauto" option from /etc/fstab.

/dev/wd0f /msdos msdos rw 1 3    

5.5. Adding users

Users and groups are added with the useradd(8) and groupadd(8) commands. For example, to add the new user carlo belonging to a new group with the same name, first create the group:

# groupadd carlo    

now create the user:

# useradd -G wheel -g carlo -m -s /bin/ksh carlo    

With this last command we have performed several tasks:

-G wheel

means that the user should be added to the "wheel" group (the group of the superuser). This gives carlo the right to use the su.

-g carlo

this is the group to which the new user belongs.

-m

requests the creation of the home directory for the new user.

-s /bin/ksh

selects a shell for the user. This is needed only if you don't want to use the default shell.

carlo

the name of the new user to be created.

In this example we have manually selected the ksh shell, but it is possible to customize the useradd command: see the manual page. For example, to make ksh the default shell:

# useradd -D -s /bin/ksh    

To list the current defaults:

# useradd -D    

Note: to add or edit a user profile manually the right tool is vipw, which lets you safely edit the password file.

5.6. Shadow passwords

Shadow passwords are enabled by default on NetBSD and can't be disabled: all the passwords in /etc/passwd contain an '*'; the encrypted passwords belong to another file, /etc/master.passwd, that can be read only by root. When you start vipw to edit the password file, the program opens a copy of /etc/master.passwd; when you exit, vipw checks the validity of the copy, creates a new /etc/passwd and installs a new /etc/master.passwd file. Finally, vipw launches pwd_mkdb, which creates the files /etc/pwd.db and /etc/spwd.db, two databases equivalent to /etc/passwd and /etc/master.passwd but faster to process.

As you can see, passwords are handled automatically by NetBSD; if you use vipw to edit the password file you don't need any special administration procedure.

It's very important to always use vipw and the other tools for account administration (chfn, chsh, chpass, passwd) and to never modify directly /etc/master.passwd.

5.7. Localization

Support for localization in the stable release of NetBSD is still lacking, although the necessary source code has already been added to -current, which means that it will be part of some future release. In the meantime, european users can get partial support for accented letters by downloading the locale.tgz tarball from the NetBSD site and installing it with the following commands:

# cd /
# gunzip < /path/to/locale.tgz | tar xvf -
    

Next add the following settings to the appropriate global configuration file for the shell you are using (eg. /etc/profile). For Italian:

LANG=it
export LANG
LC_CTYPE=iso_8859_1
export LC_CTYPE    

With these settings you can use accented letters and have menus in Italian in some programs (for example mutt).

5.8. Stopping and rebooting the system

The command used to halt and/or reboot the system is shutdown.

# shutdown -h now
# shutdown -r now
    

Two other commands perform the same tasks:

# halt
# reboot
    

halt/reboot and shutdown are not synonyms: the latter is more sophisticated. On a multiuser system you should really use shutdown: you can also schedule a shutdown, notify users, etc. For a more detailed description, see shutdown(8), halt(8) and reboot(8).