VMWare and the Joys of Vitualization

Like many sys admins I have used VMWare Workstation to test and deploy new environments and OS. I am starting to use VMWare server in production environments. My current employer is a private university and we have a large amount of individual labs that we support the web sites. In the past we had used one Apache server to handle all the labs. This has become problematic, mainly in the area of stability and security, where one labs script would bring down the entire server.
We have now deployed a VMWare Server that runs on a native Linux 2.6 environment. Each lab gets a virtual server that contains their own virtual machine with a default copy of Apache. We are still in the early stages and have not worked out the details on how many virtuals are most efficient per each server, nor have we work on HA solutions.

Posted in VMWare | Leave a comment

Updating FreeBSD 6.0 to FreeBSD 6.1

Preliminary Work

1) First make sure that you have cvsup installed

pkg_add -r cvsup-without-gui

2) Setup your standard-supfile to update to the Release English 6.1 Sources

cp /usr/src/share/examples/cvsup/standard-supfile ~/

3) Edit the standard-supfile file:

vi standard-supfile


*default release=cvs tag=RELENG_6_0


*default release=cvs tag=RELENG_6_1

Also make sure that you edit the

*default host=CHANGE_THIS.FreeBSD.org

to the mirror that you want to use.

Updating your Source Tree

1) Download and install your new sources

cvsup -g -L 2 standard-supfile

2) Be sure to read /usr/src/UPDATING.

Installing New Sources

1) Build your world

cd /usr/src
make clean;make cleanworld
make buildworld

2) Back up your current kernel. If you have a custom kernel config, back it up, make a copy of the new GENERIC to your old custom config name, and then edit the new file since some things may have changed since the last time you updated. In the example below, our custom kernel config is MYKERNEL.

cd /usr/src/sys/i386/conf/

3) Build and install the new kernel.

cd /usr/src
make buildkernel KERNCONF=MYKERNEL
make installkernel KERNCONF=MYKERNEL
mergemaster -p

Mergemaster checks to see if any critical files need updated to ensure the rest of the process will work smoothly. Just follow the prompts and PAY ATTENTION to what its asking you. Do not just overwrite files or you may lose users, groups etc.

Now reboot and drop into single user mode:

shutdown -h now

and at the boot prompt, choose single user mode. On some systems you have to hit the SPACE bar and then enter boot -s at the prompt if you do not see an option.

At the shell prompt mount the disks and turn on swap

fsck -p
mount -u /
mount -a -t ufs
swapon -a

Install and run mergemaster again:

cd /usr/src
make installworld

This last run of mergemaster checks any other files that should be merged/updated due to the upgrade. Do the same as last time, pay attention.


At this point the system should be on the 6.1 release.  I then run:

portmanager -u -f

This rebuild all installed ports to ensure we are using all our new libs and installs.

Posted in FreeBSD -- General | Leave a comment

Making a Custom Kernel

update source tree
To update your system, you should check /usr/src/UPDATING for any pre-buildworld steps necessary for your version of the sources and then use the following procedure:

make -j4 buildworld
make buildkernel
make installkernel

Note: The -j4 switch is used to spawn multiple processes and according the FreeBSD Handbook, testing shows that this speeds up building world even on a single CPU system.
Note: There are a few rare cases when an extra run of mergemaster -p is needed before the buildworld step. These are described in UPDATING. In general, though, you can safely omit this step if you are not updating across one or more major FreeBSD versions.
After installkernel finishes successfully, you should boot in single user mode (i.e. using boot -s from the loader prompt). Then run:

mount -a
mergemaster -p
make installworld

This chapter assumes that you are using the i386 architecture in the examples. If this is not the case for your situation, make appropriate adjustments to the path names for your system’s architecture.

Note: If there is not a /usr/src/sys directory on your system, then the kernel source has not been installed. The easiest way to do this is by running sysinstall (/stand/sysinstall in FreeBSD versions older than 5.2) as root, choosing Configure, then Distributions, then src, then sys. If you have an aversion to sysinstall and you have access to an “official” FreeBSD CDROM, then you can also install the source from the command line:

mount /cdrom
mkdir -p /usr/src/sys
ln -s /usr/src/sys /sys
cat /cdrom/src/ssys.[a-d]* | tar -xzvf –

Next, move to the arch/conf directory and copy the GENERIC configuration file to the name you want to give your kernel. For example:

cd /usr/src/sys/i386/conf

Traditionally, this name is in all capital letters and, if you are maintaining multiple FreeBSD machines with different hardware, it is a good idea to name it after your machine’s hostname. We will call it MYKERNEL for the purpose of this example.

Tip: Storing your kernel configuration file directly under /usr/src can be a bad idea. If you are experiencing problems it can be tempting to just delete /usr/src and start again. After doing this, it usually only takes a few seconds for you to realize that you have deleted your custom kernel configuration file. Also, do not edit GENERIC directly, as it may get overwritten the next time you update your source tree, and your kernel modifications will be lost.

You might want to keep your kernel configuration file elsewhere, and then create a symbolic link to the file in the i386 directory.

For example:

cd /usr/src/sys/i386/conf
mkdir /root/kernels
cp GENERIC /root/kernels/MYKERNEL
ln -s /root/kernels/MYKERNEL

Now, edit MYKERNEL with your favorite text editor. If you are just starting out, the only editor available will probably be vi, which is too complex to explain here, but is covered well in many books in the bibliography. However, FreeBSD does offer an easier editor called ee which, if you are a beginner, should be your editor of choice. Feel free to change the comment lines at the top to reflect your configuration or the changes you have made to differentiate it from GENERIC.
If you have built a kernel under SunOS™ or some other BSD operating system, much of this file will be very familiar to you. If you are coming from some other operating system such as DOS, on the other hand, the GENERIC configuration file might seem overwhelming to you, so follow the descriptions in the Configuration File section slowly and carefully.

Note: If you sync your source tree with the latest sources of the FreeBSD project, be sure to always check the file /usr/src/UPDATING before you perform any update steps. This file describes any important issues or areas requiring special attention within the updated source code. /usr/src/UPDATING always matches your version of the FreeBSD source, and is therefore more up to date with new information than this handbook.

You must now compile the source code for the kernel. There are two procedures you can use to do this, and the one you will use depends on why you are rebuilding the kernel and the version of FreeBSD that you are running.

  • If you have installed only the kernel source code, use procedure 1.
  • If you are running a FreeBSD version prior to 4.0, and you are not upgrading to FreeBSD 4.0 or higher using the make buildworld procedure, use procedure 1.
  • If you are building a new kernel without updating the source code (perhaps just to add a new option, such as IPFIREWALL) you can use either procedure.
  • If you are rebuilding the kernel as part of a make buildworld process, use procedure 2.

If you have not upgraded your source tree in any way since the last time you successfully completed a buildworld-installworld cycle (you have not run CVSup, CTM, or used anoncvs), then it is safe to use the config, make depend, make, make install sequence.

Procedure 1. Building a Kernel the “Traditional” Way
1) Run config(8) to generate the kernel source code.

/usr/sbin/config MYKERNEL

2) Change into the build directory. config(8) will print the name of this directory after being run as above.

cd ../compile/MYKERNEL

For FreeBSD versions prior to 5.0, use the following form instead:

cd ../../compile/MYKERNEL

3) Compile the kernel.

make depend

4) Install the new kernel.

make install

Procedure 2. Building a Kernel the “New” Way
1) Change to the /usr/src directory.

# cd /usr/src

2) Compile the kernel.

# make buildkernel KERNCONF=MYKERNEL

3) Install the new kernel.

# make installkernel KERNCONF=MYKERNEL

Note: This method of kernel building requires full source files. If you only installed the kernel source, use the traditional method, as described above.

Tip: By default, when you build a custom kernel, all kernel modules will be rebuilt as well. If you want to update a kernel faster or to build only custom modules, you should edit /etc/make.conf before starting to build the kernel:

MODULES_OVERRIDE = linux acpi sound/sound sound/driver/ds1 ntfs

This variable sets up a list of modules to build instead of all of them. For other variables which you may find useful in the process of building kernel, refer to make.conf(5) manual page.
The new kernel will be copied to the /boot/kernel directory as /boot/kernel/kernel and the old kernel will be moved to /boot/kernel.old/kernel. Now, shutdown the system and reboot to use your new kernel. If something goes wrong, there are some troubleshooting instructions at the end of this chapter that you may find useful. Be sure to read the section which explains how to recover in case your new kernel does not boot.

Note: In FreeBSD 4.X and earlier, kernels are installed in /kernel, modules in /modules, and old kernels are backed up in /kernel.old. Other files relating to the boot process, such as the boot loader(8) and configuration are stored in /boot. Third party or custom modules can be placed in /modules, although users should be aware that keeping modules in sync with the compiled kernel is very important. Modules not intended to run with the compiled kernel may result in instability or incorrectness.

Note: If you have added any new devices (such as sound cards) and you are running FreeBSD 4.X or previous versions, you may have to add some device nodes to your /dev directory before you can use them. For more information, take a look at Making Device Nodes section later on in this chapter.

Posted in FreeBSD -- Setup | Leave a comment

Install Gnome 2.14 for FreeBSD

This information comes from FreeBSD/Gnome FAQ

There are two ways to install GNOME 2.14 on FreeBSD. One way is to use packages, and the other way is to use ports. Before doing either installation, you should first familiarize yourself with the GNOME 2.14 release notes.

Install GNOME 2.14 from packages.

To install GNOME 2.14 from packages, use the command:

# pkg_add -r gnome2

This will download the latest GNOME 2.14 packages from the FreeBSD FTP site, and proceed to install them on your system.

Up-to-date GNOME packages for i386 and amd64 for all supported versions of FreeBSD are also available from the GNOME Tinderbox.

To build GNOME 2.14, you must first obtain the latest ports tree skeleton. This is most easily accomplished with portsnap(8) or cvsup. Then:

# cd /usr/ports/x11/gnome2
# make clean
# make install clean

Enable File Alteration Monitor (FAM) support for your 2.14 desktop.

GNOME includes support for the File Alteration Monitor (devel/gamin) by default, in order to improve the GNOME desktop’s ability to respond to files being added, deleted, or modified by other programs.

Make GNOME 2.14 start when X starts.

Once you have the GNOME 2.14 desktop installed, GNOME 2.14 can be started by adding the following line to ~/.xsession or ~/.xinitrc, as appropriate:

exec gnome-session

Important Note

Only the core desktop is included in the gnome2 package. Here are some other GNOME meta-ports that offer convenient groupings of popular GNOME 2 software.

  • GNOME 2 Fifth Toe (x11/gnome2-fifth-toe) consists of stable GNOME 2 applications that many users expect to find in a functional desktop environment. This includes image manipulation applications, chat and instant messenger applications, and music and multimedia players.
  • GNOME 2 Hacker Tools (devel/gnome2-hacker-tools) consists of applications developers would need to create and maintain GNOME software projects. This includes IDEs, interface builders, “hacker” editors, and code generation tools.
  • GNOME 2 Office (editors/gnome2-office) consists of applications that are commonly found in office or productivity suites. This includes a spreadsheet application, word processor, project management application, database access application, groupware suite, and diagramming application.
  • GNOME 2 Power Tools (x11/gnome2-power-tools) consists of utilities and applets for the technically-minded GNOME user. It also contains many useful add-on utilities for some of the applications found in the Desktop and Fifth Toe.

To install any of these from packages:

# pkg_add -r meta-port

For example, to install the GNOME 2 Fifth Toe from packages:

# pkg_add -r gnome2-fifth-toe

To install any of these from ports:

# cd /usr/ports/category/meta-port
# make clean
# make install clean

For example, to install the GNOME 2 Fifth Toe from ports:

# cd /usr/ports/x11/gnome2-fifth-toe
# make clean
# make install clean

Posted in FreeBSD -- Setup | Leave a comment

X11 and Terminal.app

Add this to /etc/profile:

# added to allow X11 applications to run
if [[ -z $DISPLAY ]]
export DISPLAY=:0.0

And this to /etc/csh.cshrc:

# added to allow X11 applications to run
if (! $?DISPLAY) then
setenv DISPLAY :0.0

Posted in Mac OS X | Leave a comment

FreeBSD 6 as guest OS on VMWare

VMWare Install Notes:

{Early notes} I was having clock problem and one of these solved it.

Gordon Rayburn reported that:

“I was getting “calcru: runtime went backwards” errors until sysctl.conf was updated with “kern.timecounter.hardware=TSC”. Timecounter was using two clocks, the VPC clock and the host system clock. I chose the TSC clock as it was reported as slower than the ACPI-safe clock. I figured (guessed) that it was better to use the slower clock as I have my VPC setup to use less cpu when off-focus of the guest o/s”

Matthew Swinbourne writes that, if you notice the clock running very quickly, then

“..if you set kern.timecounter.hardware=i8254 in /etc/sysctl.conf and reboot or set it via the cmd line “sysctl kern.timecounter.hardware=i8254″ it slows down to normal time”

Posted in VMWare | Leave a comment

Notes on Keeping FreeBSD 6 up to date

Updating FreeBSD 6.x

Before you start
Setup environment for packages:

setenv PACKAGESITE ftp://ftp2.us.freebsd.org/pub/FreeBSD/ports/i386/packages-6-stable/Latest/

Using freebsd-update to update standard kernels
1) Add freebsd update package:

pkg_add -r freebsd-update

2) Setup and use freebsd-update:

cp /usr/local/etc/freebsd-update.conf.sample /usr/local/etc/freebsd-update.conf
mkdir /usr/local/freebsd-update
freebsd-update fetch
freebsd-update install
shutdown -r now

Updating packages and ports

1) install portaudit package

pkg_add -r portaudit

2) Check for updates

/usr/local/sbin/portaudit -Fda

3) Updating of Ports tree

pkg_add -r portsnap (bundled with 6.x)
portsnap fetch
portsnap extract (only have to do this once on a new install)
portsnap update

4) Updating Applications

pkg_add -r portupgrade
portversion -v -l “<" portupgrade -varRPP (tells it to be verbose, act on up and down depends, and upgrade only with packages)
on any that fail then do portupgrade -varR (this tells it to build from ports)

Posted in FreeBSD -- General | Leave a comment