Diff for /wikisrc/guide/misc.mdwn between versions 1.1 and 1.2

version 1.1, 2013/03/05 22:57:52 version 1.2, 2013/03/05 23:33:53
Line 6  This chapter collects various topics, in Line 6  This chapter collects various topics, in
   
 ### fdisk  ### fdisk
   
 Sysinst, the NetBSD installation program, usually installs the NetBSD boot   Sysinst, the NetBSD installation program, usually installs the NetBSD boot
 manager on the hard disk. The boot manager can also be installed or reconfigured   manager on the hard disk. The boot manager can also be installed or reconfigured
 at a later time, if needed, with the   at a later time, if needed, with the
 [fdisk(8)](http://netbsd.gw.com/cgi-bin/man-cgi?fdisk+8+NetBSD-current)  [fdisk(8)](http://netbsd.gw.com/cgi-bin/man-cgi?fdisk+8+NetBSD-current)
 command. For example:  command. For example:
   
     # fdisk -B wd0      # fdisk -B wd0
   
 If NetBSD doesn't boot from the hard disk, you can boot it from the installation   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,   floppy and start the kernel on the hard disk. Insert the installation disk and,
 at the boot prompt, give the following command:  at the boot prompt, give the following command:
   
     > boot wd0a:netbsd      > boot wd0a:netbsd
   
 This boots the kernel on the hard disk (use the correct device, for example sd0a   This boots the kernel on the hard disk (use the correct device, for example sd0a
 for a SCSI disk).  for a SCSI disk).
   
 *Note*: Sometimes `fdisk -B` doesn't give the expected result (at least it   *Note*: Sometimes `fdisk -B` doesn't give the expected result (at least it
 happened to me), probably if you install/remove other operating systems like   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   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.  known as `fdisk /mbr` from DOS) and then run again `fdisk` from NetBSD.
   
 ### installboot  ### installboot
   
 There is another tool for installing a bootloader, named  There is another tool for installing a bootloader, named
 [installboot(8)](http://netbsd.gw.com/cgi-bin/man-cgi?installboot+8+NetBSD-current).  [installboot(8)](http://netbsd.gw.com/cgi-bin/man-cgi?installboot+8+NetBSD-current).
 Depending on the platform you are using, its usage differs, so you should read   Depending on the platform you are using, its usage differs, so you should read
 the manpage and its extensive *EXAMPLES* section.  the manpage and its extensive *EXAMPLES* section.
   
 E.g., if you want to install the bootloader for a ffs filesystem to the   E.g., if you want to install the bootloader for a ffs filesystem to the
 partition you have your NetBSD in (in this case, `sd0c`), you would use:  partition you have your NetBSD in (in this case, `sd0c`), you would use:
   
     installboot -v /dev/rsd0c /usr/mdec/bootxx_ffs      installboot -v /dev/rsd0c /usr/mdec/bootxx_ffs
   
 ## Deleting the disklabel  ## Deleting the disklabel
   
 Though this is not an operation that you need to perform frequently, it can be   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   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:  you are doing before performing this kind of operation. For example:
   
     # dd if=/dev/zero of=/dev/rwd0c bs=8k count=1      # dd if=/dev/zero of=/dev/rwd0c bs=8k count=1
   
 The previous command deletes the disklabel (not the MBR partition table). To   The previous command deletes the disklabel (not the MBR partition table). To
 completely delete the disk, the whole device `rwd0d` must be used. For example:  completely delete the disk, the whole device `rwd0d` must be used. For example:
   
     # dd if=/dev/zero of=/dev/rwd0d bs=8k      # dd if=/dev/zero of=/dev/rwd0d bs=8k
   
 The commands above will only work as expected on the i386 and amd64 ports of   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. `rwd0c`).  NetBSD. On other ports, the whole device will end in c, not d (e.g. `rwd0c`).
   
 ## Speaker  ## Speaker
   
 I found this tip on a mailing list (I don't remember the author). To output a   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  sound from the speaker (for example at the end of a long script) the
 [spkr(4)](http://netbsd.gw.com/cgi-bin/man-cgi?spkr+4+NetBSD-current)  [spkr(4)](http://netbsd.gw.com/cgi-bin/man-cgi?spkr+4+NetBSD-current)
 driver can be used in the kernel config, which is mapped on `/dev/speaker`. For   driver can be used in the kernel config, which is mapped on `/dev/speaker`. For
 example:  example:
   
     echo 'BPBPBPBPBP' > /dev/speaker      echo 'BPBPBPBPBP' > /dev/speaker
   
 *Note*: The `spkr` device is not enabled in the generic kernel; a customized   *Note*: The `spkr` device is not enabled in the generic kernel; a customized
 kernel is needed.  kernel is needed.
   
 ## Forgot root password?  ## Forgot root password?
Line 75  If you forget root's password, not all i Line 75  If you forget root's password, not all i
 system with the following steps: boot single user, mount `/` and change root's  system with the following steps: boot single user, mount `/` and change root's
 password. In detail:  password. In detail:
   
 1. Boot single user: when the boot prompt appears and the five seconds   1. Boot single user: when the boot prompt appears and the five seconds
    countdown starts, give the following command:     countdown starts, give the following command:
   
        > boot -s         > boot -s
Line 99  password. In detail: Line 99  password. In detail:
        Changing local password for root.         Changing local password for root.
        New password: (not echoed)         New password: (not echoed)
        Retype new password: (not echoed)         Retype new password: (not echoed)
        #          #
   
 5. Exit the shell to go to multiuser mode.  5. Exit the shell to go to multiuser mode.
   
Line 110  If you get the error `Password file is b Line 110  If you get the error `Password file is b
   
 ## Password file is busy?  ## Password file is busy?
   
 If you try to modify a password and you get the mysterious message `Password   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   file is busy, it probably means that the file `/etc/ptmp` has not been deleted
 from the system. This file is a temporary copy of the `/etc/master.passwd` file;   from the system. This file is a temporary copy of the `/etc/master.passwd` file;
 check that you are not losing important information and then delete it:  check that you are not losing important information and then delete it:
   
     # rm /etc/ptmp       # rm /etc/ptmp
   
 *Note*: If the file `/etc/ptmp` exists you can also receive a warning message at   *Note*: If the file `/etc/ptmp` exists you can also receive a warning message at
 system startup. For example:  system startup. For example:
   
     root: password file may be incorrect - /etc/ptmp exists      root: password file may be incorrect - /etc/ptmp exists
   
 ## Adding a new hard disk  ## Adding a new hard disk
   
 This section describes how to add a new hard disk to an already working NetBSD   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,   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   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   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   installation of an IDE hard disk is identical; only the device name will be
 different (`wd#` instead of `sd#`).  different (`wd#` instead of `sd#`).
   
 As always, before buying new hardware, consult the hardware compatibility list   As always, before buying new hardware, consult the hardware compatibility list
 of NetBSD or ask on a mailing list to make sure the new device is supported by   of NetBSD or ask on a mailing list to make sure the new device is supported by
 NetBSD.  NetBSD.
   
 When the SCSI controller has been physically installed in the system and the new   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   hard disk has been connected, it's time to restart the computer and check that
 the device is correctly detected, using the  the device is correctly detected, using the
 [dmesg(8)](http://netbsd.gw.com/cgi-bin/man-cgi?dmesg+8+NetBSD-current)  [dmesg(8)](http://netbsd.gw.com/cgi-bin/man-cgi?dmesg+8+NetBSD-current)
 command. This is the sample output for an NCR-875 controller:  command. This is the sample output for an NCR-875 controller:
Line 150  command. This is the sample output for a Line 150  command. This is the sample output for a
     sd0(ncr0:2:0): 20.0 MB/s (50 ns, offset 15)      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      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   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   kernel that you are using; if necessary, compile a customized kernel (see
 [[Compiling the kernel|guide/kernel]]).  [[Compiling the kernel|guide/kernel]]).
   
 Now the partitions can be created using the   Now the partitions can be created using the
 [fdisk(8)](http://netbsd.gw.com/cgi-bin/man-cgi?fdisk+8+NetBSD-current)  [fdisk(8)](http://netbsd.gw.com/cgi-bin/man-cgi?fdisk+8+NetBSD-current)
 command. First, check the current status of the disk:  command. First, check the current status of the disk:
   
Line 174  command. First, check the current status Line 174  command. First, check the current status
     2: <UNUSED>      2: <UNUSED>
     3: <UNUSED>      3: <UNUSED>
   
 In this example the hard disk already contains a DOS partition, which will be   In this example the hard disk already contains a DOS partition, which will be
 deleted and replaced with a native NetBSD partition. The command  deleted and replaced with a native NetBSD partition. The command
 `fdisk -u sd0` allows to modify interactively the partitions. The modified data   `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   will be written on the disk only before exiting and fdisk will request a
 confirmation before writing, so you can work relaxedly.  confirmation before writing, so you can work relaxedly.
   
 **Disk geometries**  **Disk geometries**
   
 The geometry of the disk reported by fdisk can appear confusing. Dmesg reports   The geometry of the disk reported by fdisk can appear confusing. Dmesg reports
 4226725 sectors with 8188/3/172 for C/H/S, but 8188\*3\*172 gives 4225008 and   4226725 sectors with 8188/3/172 for C/H/S, but 8188\*3\*172 gives 4225008 and
 not 4226725. What happens is that most modern disks don't have a fixed geometry   not 4226725. What happens is that most modern disks don't have a fixed geometry
 and the number of sectors per track changes depending on the cylinder: the only   and the number of sectors per track changes depending on the cylinder: the only
 interesting parameter is the number of sectors. The disk reports the C/H/S   interesting parameter is the number of sectors. The disk reports the C/H/S
 values but it's a fictitious geometry: the value 172 is the result of the total   values but it's a fictitious geometry: the value 172 is the result of the total
 number of sectors (4226725) divided by 8188 and then by 3.  number of sectors (4226725) divided by 8188 and then by 3.
   
 To make things more confusing, the BIOS uses yet another *fake* geometry (C/H/S   To make things more confusing, the BIOS uses yet another *fake* geometry (C/H/S
 524/128/63) which gives a total of 4225536, a value which is a better   524/128/63) which gives a total of 4225536, a value which is a better
 approximation to the real one than 425008. To partition the disk we will use the   approximation to the real one than 425008. To partition the disk we will use the
 BIOS geometry, to maintain compatibility with other operating systems, although   BIOS geometry, to maintain compatibility with other operating systems, although
 we will lose some sectors (4226725 - 4225536 = 1189 sectors = 594 KB).  we will lose some sectors (4226725 - 4225536 = 1189 sectors = 594 KB).
   
 To create the BIOS partitions the command `fdisk -u` must be used; the result is   To create the BIOS partitions the command `fdisk -u` must be used; the result is
 the following:  the following:
   
     Partition table:      Partition table:
Line 208  the following: Line 208  the following:
     2: <UNUSED>      2: <UNUSED>
     3: <UNUSED>      3: <UNUSED>
   
 Now it's time to create the disklabel for the NetBSD partition. The correct   Now it's time to create the disklabel for the NetBSD partition. The correct
 steps to do this are:  steps to do this are:
   
     # disklabel sd0 > tempfile      # disklabel sd0 > tempfile
Line 226  you get the following message Line 226  you get the following message
   
 because the disklabel does not yet exist on the disk.  because the disklabel does not yet exist on the disk.
   
 Now we create some disklabel partitions, editing the `tempfile` as already   Now we create some disklabel partitions, editing the `tempfile` as already
 explained. The result is:  explained. The result is:
   
     #      size   offset   fstype [fsize bsize   cpg]      #      size   offset   fstype [fsize bsize   cpg]
Line 235  explained. The result is: Line 235  explained. The result is:
     d:  4226725        0   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*)      e:  2178658  2048067   4.2BSD   1024  8192    16 # (Cyl.  3969*- 8191*)
   
 *Note*: When the disklabel has been created it is possible to optimize it   *Note*: 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   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   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   values reported by newfs can be used to adjust the sizes of the partitions with
 an iterative process.  an iterative process.
   
 The final operation is the creation of the file systems for the newly defined   The final operation is the creation of the file systems for the newly defined
 partitions (`a:` and `e:`).  partitions (`a:` and `e:`).
   
     # newfs /dev/rsd0a      # newfs /dev/rsd0a
     # newfs /dev/rsd0e      # newfs /dev/rsd0e
   
 The disk is now ready for usage, and the two partitions can be mounted. For   The disk is now ready for usage, and the two partitions can be mounted. For
 example:  example:
   
     # mount /dev/sd0a /mnt      # mount /dev/sd0a /mnt
   
 If this succeeds, you may want to put an entry for the partition into   If this succeeds, you may want to put an entry for the partition into
 `/etc/fstab`.  `/etc/fstab`.
   
 ## How to rebuild the devices in /dev  ## How to rebuild the devices in /dev
   
 First shutdown to single user, partitions still mounted `rw` (read-write); You   First shutdown to single user, partitions still mounted `rw` (read-write); You
 can do that by just typing `shutdown now` while you are in multi user mode, or   can do that by just typing `shutdown now` while you are in multi user mode, or
 reboot with the `-s` option and make `/` and `/dev` read-writable by doing.  reboot with the `-s` option and make `/` and `/dev` read-writable by doing.
   
     # mount -u /      # mount -u /

Removed from v.1.1  
changed lines
  Added in v.1.2


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb