FreeBSD Tips


  1. How to add or remove a package?
  2. How to burn a CD?
  3. Use "dmesg" command to see recent messages.
  4. Install Linux in a FreeBSD OS
  5. NFS Setting
  6. Account Expire problem after using KUser

package and ports

Use "pkg_add" to install a software, which named "port" in FreeBSD, the /usr/ports/ directory include all the source file for a software such as emacs, mysql....
pkg_add -f : force update or install
pkg_add -r get remote from ftp site. Note it depends on the current Freebsd version for corresponding package, not the newest one.
pkg_delete -f force delete
pkg_info -a show all package informations
pkg_version show all version information of installed ports. "=" means match, "< " ">" "?": mismatch.

To burn a CD, there 3 options:

1. use "burncd" command for ATAPI CD-RW. However, burncd does not support all CD-ROW, only a quite short list of products.

2. use "cdrecord". It's designed for SCSI device. Use CAM to map a ATAPTI CDRW to a SCSI device.To do this, first you have to add some lines (such as "device atapicam" in the kernel configure and then rebuild the kernel.

3. Use K3b. This is a GUI front-end for burning software.

To install Dual systems two OS: Linux+FreeBSD, I installed FreeBSD first in /dev/hda1, and also instlled Boot Manager. Then, I instll Red Hat in /dev/hda2. However, this does not work. The linux does not come up.
Then, I re formatted disk ( left FreeBSD unchange) to create a Boot sector /bootand a Linux partition (ext3) and swap partition. Also, I choose to install GRUB as the boot manager.
In grub.conf, I added some line as

title FreeBSD 4.10
                root (hd0,a)
                kernel /boot/loader ro root=/dev/hda1

Then, both freebsd and Linux can be choosed to boot up in GRUB.

Setting NFS in two freebsd machines

However, the new-appearing problem is that NFS failire. It always prompt "Permission Denied". After hours' debugging, I realized that it's becasue I use explict domain name in the /etc/exports file: It reads as:

/usr/users /usr/groups /usr/proj /usr/testbed   boss.orbit-lab.org -maproot=root
/share  boss.orbit-lab.org -maproot=root
/var    boss.orbit-lab.org -maproot=root
The nameserver in 192.168.164.2 will resolve those servers as 192.168.164.* not 10.*.*.* Because of this inconsistency, the request from boss (10.0.0.2) is rejected by ops A quick solution to all thses are add boss and ops to /etc/hosts file for each other. as
boss 10.0.0.2
boss orbit-lab-org
Some commands to manually debug NFS
#killall -hup mountd
#mountd
#mount ops:/usr/users /users
#showmount -e
The file /etc/exports stores informationa about NFS


Produce a image fro TFTP service
1. DESCRIPTION:

This directory contains the kernel and root filesystem image used for
the network-booted Emulab "admin MFS".  This MFS is use primiary for
creating new disk images: the system is booted into the MFS and "imagezip"
is run to take a snapshot of the disk. 

This system started as a FreeBSD 4.7 (4.3?) system that was scaled-back
dramatically for loading over the network.  In the current invocation,
it includes a FreeBSD 4.10 kernel and the July 2004 Emulab client code.


2. CONTENTS:

README
	This file

boot.4th
defaults
loader.4th
loader.bigdata.conf
loader.conf
loader.conf.local
loader.help
loader.rc
support.4th
	Boot loader related files, some standard, some customized for
	network booting.

kernel
	FreeBSD 4.10 GENERIC kernel with minor additions:
	- MROUTING
	- HZ=1000
	- IPOD (Emulab "ping of death" mod)

mfsroot
	Filesystem image used as the root FS.  See below for how to
	access and update.

prepare
	Script to "prepare" this directory for use.  All this script does
	is create gzip'ed version of the various files that are needed to
	bootstrap the MFS-based system.  These files speed up the boot process
	considerably.

3. INSTALLATION (assumes you have unpacked this in /tftpboot/freebsd)

A. Mount the filesystem image on /mnt so you can customize it
	(See #4 below for details on how to tweak the MFS):
	  cd /tftpboot/freebsd/boot
	  sudo vnconfig vn0 mfsroot
	  sudo mount /dev/vn0c /mnt

B. Put your client ssh host keys in /mnt/etc/ssh.
	We use the same ssh1-rsa, ssh2-rsa, ssh2-dsa host keys on all
	OSes on all our clusters nodes.  So if you do not already have
	such keys from an existing image, create them now:
	  /usr/bin/ssh-keygen -t rsa1 -N "" -f /mnt/etc/ssh/ssh_host_key
	  /usr/bin/ssh-keygen -t rsa -N ""  -f /mnt/etc/ssh/ssh_host_rsa_key
	  /usr/bin/ssh-keygen -t dsa -N ""  -f /mnt/etc/ssh/ssh_host_dsa_key

C. Put your boss root ssh public key in /mnt/root/.ssh/authorized_keys.
	That would be boss:/root/.ssh/identity.pub.  The key that is in
	the file already is Utah's boss key, remove it if you want.

D. Set the root password.
	A real PITA here, do:
	  vipw -d /mnt/etc
	and fill in a hash string that you have precomputed.
	(e.g., grab it from /etc/master.passwd on an existing node,
	or use passwd on some BSD node to set a password to the desired
	string and then grab the hash out of the master.passwd file)
	Also plug that value into /mnt/etc/emulab/master.passwd as both
	the "root" and "toor" hash.

E. Set the local timezone if you care.
	Grab the appropriate file from /usr/share/zoneinfo on a BSD box.

F. Unmount the filesystem and run the prepare script
	sudo umount /mnt
	sudo ./prepare


4. MODIFYING AN MFS:

If you want to see what is in one of the MFSes or otherwise customize it,
you simply mount the MFS as a filesystem.  This takes two steps in BSD:
associating a "virtual disk" with the file and then mounting that disk,
e.g. as root:

	vnconfig vn0 /tftpboot/freebsd/boot/mfsroot
	mount /dev/vn0c /mnt

When you are done, just unmount the filesystem and rerun the prepare
script:

	umount /dev/vn0c
	cd /tftpboot/freebsd/boot; ./prepare

If you aren't going to do any more mods for a while, then you can
unconfigure the disk as well:

	vnconfig -u vn0

though this isn't necessary in order for your changes to make it into
the MFS that is downloaded (it *is* essential that you rerun the prepare
script above or else the node will continue to download mfsroot.gz instead
of your updated mfsroot).

Note that you may have to create vnode-disk devices in /dev:

	cd /dev; ./MAKEDEV vn0 vn1


5. INSTALLING A NEW KERNEL:

The kernel which drives the MFS-based system is not in the MFS itself.
So to install a new kernel, you do not have to do the MFS nonsense above.
You just have to stick your kernel into /tftpboot/blah-blah/boot, ala:

	cp kernel /tftpboot/freebsd/boot
	cd /tftpboot/freebsd/boot; ./prepare

Again, it is important to rerun prepare.

Account Expire problem after using KUser

IT HAS been found that KDE 3.1 or higher version has a serious problem with freebsd 4.9 or higher version. After running
KUser to manage user accounts, the passwd.master file has been wrongly modified and all user accounts (including root) are set as expired. Thus, the phenomenon is : system can no longer be logged in.   This caused a system re-install earlier this year. And it happened today again. And finally I found the problem and  have to boot into single-user mode to fix that file and rebulid user database with "vipw". ( change root password only does not fix...)

กก

กก