ACKNOWLEDGMENTS
Lindsay, thanks for being so patient while I did computer nerd stuff in the middle of the night. Rachael, maybe now I'll have time to put that wheel cap on your car. Michelle, thanks for leaving your plasma TV with me when you move to Hawaii?
I'd like to thank Bill Pollock, Elizabeth Campbell, Ellen Har, Patricia Witkin, Leigh Poehler, and Tyler Ortman of No Starch Press for all of their hard work and dedication. They did an amazing job of transforming what was once a pile of notes into a truly useful book. Special thanks to Riley Hoffman of No Starch Press for wearing so many hats. She did a phenomenal job; I am forever grateful. Thanks again, Bill, for all of your input and guidance.
Thanks to Dru Lavigne for providing her technical expertise and guidance. Your commitment to FreeBSD and open source software is a source of inspiration for me. Thanks to Michael Lucas for the words of wisdom and for writing one of the best FreeBSD books around.
I'd also like to thank Richard Bejtlich for reviewing the first incarnation of this book; his suggestions led to improvements to this edition. Thanks to Derek Yee of Octopod Studios for the clever cover graphics. Thanks to Joseph Koshy and the other members of the FreeBSD community who donate their time selflessly. Lastly, thanks to all of the open source developers who created the excellent software mentioned in this book. I hope this book brings more people to appreciate the work you do.
Bryan J. Hong
San Francisco, CA
February 29, 2008
B.3. ADDING A SECOND HARD DISK
This guide assumes that you have added a Parallel or Serial ATA hard drive to the system. If you'll be using a USB or SCSI hard drive, you may substitute all references to ad with da and proceed normally. We are going to assume that the hardware installation is correct and complete, and that you don't intend to keep any data that may be on the new hard drive. After booting with the new hard drive installed, log in as the superuser.
To begin configuring the new drive, type sysinstall at the command prompt. You will be taken to the main menu. Scroll down to Configure and press [enter].
Select Fdisk and press [enter]. A dialog asking you to select the drive will appear. Select the appropriate drive and press [enter] (the new drive will probably be the second in the list with a name like ad1 or ad2). A warning message may appear explaining that your drive geometry is incorrect. FreeBSD will automatically adjust this, so press [enter] to continue.
You are now in the FDISK Partition Editor. Press A to automatically partition and then press W to write changes. A dialog will appear saying that this should only be performed on an existing installation and asking if you are sure you want to do this now. Confirm that you are modifying the correct physical drive by checking the upper left corner, where the disk name is displayed. If you are ready to erase the drive, select yes and press [enter]. A dialog asking if you want to install a boot manager will appear. Select none and press [enter]. The next dialog will say that the operation was successful. Press [enter]. Type Q to quit FDISK.
You will be returned to the Select Drive menu. Select cancel to return to the configuration menu. Select exit by pressing X and then [enter]. You will be at the sysinstall Main Menu; press X again to exit (you need to exit sysinstall for the changes to take effect).
You will be at the command prompt at this point. Restart sysinstall by typing sysinstall . Select Configure and press [enter]. Select Label and press [enter]. A dialog asking you to select the drive will appear. Select the appropriate drive and press [enter] (this will be the same drive you selected in step 2). The disk label editor will now appear. Press C to create a partition. A dialog will appear asking you to specify partition size. To use the whole drive, press [enter]. The next menu will ask you what type to create. Choose fs and press [enter]. The next prompt will ask you for a mount point (directory name). Type one of your choice ( /backup , for example; don't use the name of a directory that already exists because sysinstall will mount the new partition on top of it) and press [enter]. To finalize the changes, press W . The same dialog you saw in FDISK will appear. If you are ready, select yes and press [enter].
Write down the partition name(s) and the corresponding mount name(s); you will need this information in the following steps. When you are ready to continue, press Q to quit the label editor. You will be returned to the select drive menu. Select cancel to return to the configuration menu. Scroll up to exit and press [enter]. Select exit install and press [enter]. Your newly configured drive should now be mounted and ready for use.
The /etc/fstab file needs to be modified so that your new hard drive will mount each time the system starts. Open /etc/fstab :
# ee /etc/fstabAdd a new line and insert the partition name you wrote down in step 6. You'll need to precede the partition name with /dev/ . You'll also need to insert the mount name you used in step 6 under the mountpoint column. The remaining columns can be set to the values shown below:
# Device Mountpoint FStype Options Dump Pass#/dev/ad0s1b none swap sw 0 0/dev/ad0s1a / ufs rw 1 1/dev/ad0s1e /tmp ufs rw 2 2/dev/ad0s1f /usr ufs rw 2 2/dev/ad0s1d /var ufs rw 2 2/dev/acd0 /cdrom cd9660 ro,noauto 0 0/dev/ad1s1d /backup ufs rw 2 2
Save and exit. The new drive should now mount automatically at boot time.
Appendix C. MANAGING USER ACCOUNTS
This section is meant to give new administrators a brief look at adding, removing, and modifying users with FreeBSD. For more information, refer to the FreeBSD Handbook, http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/users.html.
C.1. ADDING USERS
FreeBSD includes the adduser command, which calls an interactive script that makes adding users quite easy. We'll create a theoretical user named John Doe and give him shell or command-line access.
After typing adduser at the command line, you will be prompted for a username. This is the login name; you can use any convention you like, but we are just using the first name in this example. Note that usernames are case sensitive, meaning john is not the same as John .