Installing DragonFly BSD from the Live CD


revised 05/05/2004



Getting the CD etc.

This document describes the installation of DragonFly BSD on a plain i386 machine. Besides upgrading a FreeBSD 4.* system to run DragonFly, another way is installing from a bootable CD.

This CD is available at one of the current mirrors, which distribute the images by various protocols. You can find the authorative list at the DragonFly BSD official download page.

People of the DragonFly development team are working on an automatic installation tool, which simplifies the partitioning and installation. Until this tool is in place, these things must be done manually.

Since rumors say that there are people who don't have an extra machine at hand for every new operating system, the proceeding for installing in a multiboot-environment is documented as well.

If you use an old machine (like me, where the BIOS-management-tool was somewhere on the disk once upon a time), you maybe don't have the option to boot from a CD. Use a bootmanager on a floppy in those cases. A pretty cool and lightweight one is the Smart Bootmanager.

Preparing the partitions

Entire disk

Getting the disk ready for exclusive use with DFly is relatively simple:

Zero-out your MBR:
# dd if=/dev/zero of=/dev/ad0 bs=32k count=16
Tell fdisk to use the whole disk:
# fdisk -IB ad0

Multiple OS'es

Take your favourite partition-tool, which supports resizing partitions. I haven't heard of any fdisk version that supports that. I personally like GNU parted, a partitioner that works well with common filesystems and is pretty intuitive to handle. It can be found on the KNOPPIX-CD or on some bootdisks like the PAUD. The original bootimages from the GNU project's download sites aren't available at the moment.

Resize one of your old partitions and create a new primary one. Don't bother with formatting and stuff like that. If you're done, fire up your live CD and wait. Reading the README in the root-directory never hurts. It actually contains the major part of what you can read here.

Floppies

You may need a DOS-formatted floppy-disk somewhere in the middle of the installation process. To save you the hassle in case you don't know how, here the proceeding:

Create a floppy:
# fdformat /dev/fd0.1440
# disklabel -B -r -w /dev/fd0.1440 fd1440
# newfs_msdos /dev/fd0

Windows

Should you run Windows, you can use the Win NT/2000/XP bootmanager. I'm not a dedicated friend of Windows, but I think I found out how it works. It requires a bit of fiddling, though.

Back up the old MBR first:
# dd if=/dev/ad0 of=/root/win.mbr bs=512 count=1

Done that, install Dragonfly regularly as follows in the next paragraphs. You also have to install the DragonFly loader as usual. When you've rebooted DFly for the first time and you're sure it boots the way you want it, back up the new MBR too as described above. Then restore your old MBR and copy the DragonFly MBR to a floppy/USB-stick or so.

Restore Windows' MBR:
# dd if=/root/win.mbr of=/dev/ad0 bs=512 count=1

Boot Windows and copy the file from disk into the C:\ folder. Now tell boot.ini what you want it to do.

Append the following line at boot.ini:
c:\dfly.mbr="DragonFly BSD"

Don't forget to increase the timeout, should it be on zero.

Users of Win98 better choose the DragonFly bootmanager; this works quite well.

Unix-like systems

If you want to use the DragonFly bootmanager, you can zero-out your MBR as shown above, else tell your LILO/GRUB/whatever about the partition when you're done.

Disk formatting

Format your partition interactively:
# fdisk -u

It should be easy to find out which is the right one. If your partition or slice for DragonFly is for example the first, substitute the specified slice with ad0s1 in the next sections. Think twice before typing since you could destroy your other system(s).

Installing the bootblock

Don't do this if you want to use the bootloader of another OS like on this machine!

Install the boot0cfg bootmanager:
# boot0cfg -B ad0
Display configuration:
# boot0cfg -v ad0

boot0cfg boots from slice 1 by default; modify it with the -s SLICE option.

Creating and editing the disklabel

Substitute the slicenames depending on the one you want to use for DragonFly BSD. If the device-node of your specified slice does not exist, you have to create it before. The same holds for the partitions you might create. The only disk device-nodes created by default are ad0s1's.

Create a device-node
# cd /dev; ./MAKEDEV ad0s2

Now set up the partition-table:

Generate an initial label on the specified slice:
# disklabel -B -r -w ad0s2 auto

The next command will throw you into vi for editing the table to your needs. disklabel shows the offset from the beginning of the specified partition, so don't fear you might overwrite something important. An example disklabel can be found in /etc/disklabel.ad0s1, just to know the style.

Edit the label:
# disklabel -e ad0s2

A quite common configuration looks like this:

A standard partitioning scheme
partition size mountpoint
ad0s2a 256m This will be your /
ad0s2b 1024m This will be the swap-partition
ad0s2c leave alone This enty represents the whole slice
ad0s2d 256m This will be you /var
ad0s2e 256m This will be your /tmp
ad0s2f 8192m This will be /usr, should be at least 4096m
ad0s2g * All the rest goes into /home
Now that the partitions are in place, format them. The command newfs does the deed. Softupdates on the root-filesystem is normally not enabled (see README why).

Format filesystems:
# newfs /dev/ad0s2a
# newfs -U /dev/ad0s2d
# newfs -U /dev/ad0s2e
# newfs -U /dev/ad0s2f
# newfs -U /dev/ad0s2g

Mounting the filesystems and copying the CD

Get the fresh partitions into your system and copy the contents of the CD to disk.

Mounting:
# mount /dev/ad0s2a /mnt
# mkdir /mnt/var
# mkdir /mnt/tmp
# mkdir /mnt/usr
# mkdir /mnt/home
# mount /dev/ad0s2d /mnt/var
# mount /dev/ad0s2e /mnt/tmp
# mount /dev/ad0s2f /mnt/usr
# mount /dev/ad0s2g /mnt/home
Getting the files:
# cpdup / /mnt
# cpdup /var /mnt/var
# cpdup /etc /mnt/etc
# cpdup /dev /mnt/dev
# cpdup /usr /mnt/usr

Final Cleanup

Most of the installation-work is accomplished now, but there are still some things to be done.

If you made a /tmp-partition, it is reasonable to link /var/tmp to /tmp.

Linking /tmp:
# chmod 1777 /mnt/tmp
# rm -fr /mnt/var/tmp
# ln -s /tmp /mnt/var/tmp

To mount the right filesystems, set up fstab to reflect your configuration. Best modify /mnt/fstab.example and move it to fstab then. You maybe want to mount your /tmp directory on MFS, so it is truly temporary.

Bringing fstab in place:
# vi /mnt/etc/fstab.example
# mv /mnt/etc/fstab.example /mnt/etc/fstab

Backing up your current disklabel is a good idea, should you ever need it again (e.g. corrupted disk, lost partition table).

Save the disklabel:
# disklabel ad0s2 > /mnt/etc/disklabel.ad0s2

Last there are some files only required by the CD which you got to remove to get your system started from the harddisk.

Remove CD-files:
# rm /mnt/boot/loader.conf
# rm /mnt/boot.catalog
# rm -r /mnt/rr_moved

At this moment it should be possible to reboot and start off the disk. Don't just hit the reset-button, because you can't be sure that the disk is already sync'ed. Remove the CD before your machine boots anew.

Reboot correctly:
# reboot

Problems?

If you encounter complications on booting from disk, try these things:

  1. Old bootblocks can interfere with the initialization-process. To avoid this, zero-out the MBR.
  2. If you can select CHS or LBA mode in your BIOS, try changing the mode to LBA.
  3. Your DragonFly slice is maybe beyond cylinder 1023. Try boot0cfg -o packet ad0 in this case.

Afterboot

If your system works correctly from the harddisk, you should concern yourself with setting up a base configuration. This includes setting the hostname, choosing a keymap, configuring the network, setting up cron and so on.

Getting the right keymap:
# kbdmap

Choose your favourite one, remember the name and place an additional line in /etc/rc.conf to load it at startup (e.g. echo 'keymap="german.iso.kbd"' >> /etc/rc.conf).

To set the hostname, proceed the same way and insert a line like hostname="elektra" into /etc/rc.conf. Having done this, tell /etc/hosts about.

Have an overall look at /etc/rc.conf to enable cron, usbd and the like.

It is a good idea to set your timezone, because some progs which do a time-related syscall would be unhappy with a result of Dec 1969. Just in case.

Set up the timezone:
# tzsetup

If you're a lazy bone like me and hate to pwd all the time to know where you are, modify the line set prompt 0 "'hostname -s'# " in .cshrc to set prompt = "'hostname -s':%/# ".

Install a simpler text-editor

If you don't have a special affinity for vi, install an editor that is more simple to handle. I personally prefer nano, because it is small and simple. It will install into /usr/local/bin.

Compiling nano:
# ./configure --build=386bsd
# make
# make install

Initital network setup

Should your network-interface(s) not work properly, try to load some modules from /modules via kldload.

To configure DHCP, place a line like ifconfig_ep0="DHCP" in /etc/rc.conf; if you need a fixed IP, something like ifconfig_ep0="inet 132.199.32.25 netmask 255.255.255.0" is what you want.

Enable USB

Since USB is not fully loaded when DragonFly is started from CD, you have to activate is after an HD-install. This is mainly because USB is still under development and could prevent the CD from booting cleanly.

Initialize USB:
# kldload ehci.ko
# rcforce usbd

If you run out of device-nodes because you hav a lot of USB-devices, you maybe have to create additional ones.

Create some more USB device-nodes:
# cd /dev; ./MAKEDEV da4 da5

Don't forget to set usbd_enable to YES int /etc/rc.conf.

Using CVSup to obtain the CVS and ports

You can use CVSup to get the DragonFly repository, the FreeBSD ports-tree and anything else you find in any CVS-archive. CVSup is a port, but included on the CD. There are some examples provided in /usr/share/examples/cvsup; if you want to know more about it, try "man cvsup".

I will describe only how to obtain the DragonFly CVS-repository, the DragonFly supfile, the FreeBSD ports and the respective supfile, since this is what you really want. If you've done the initial setup and you are blessed with a permanent connection to the internet, you may want to create a cronjob to keep it up to date. But please do not run such an unattended job more than once a day.

Have a look at the supfiles first, since there's the additional option to use a 'checked out' copy of the source tree instead of syncing with the tree itself. This makes sense if you don't plan to do development work or are low on disk space. If you choose to do so, a cvsup SUPFILE suffices to get everything you need.

get the pository (in /home/dcvs):
# cvsup /usr/share/examples/cvsup/DragonFly-supfile
install the source from the CVS hierarchy:
# cd /usr
# cvs -R -d /home/dcvs checkout src
# cvs -R -d /home/dcvs checkout dfports
get the FreeBSD ports tree:
# cvsup -h cvsup.freebsd.org /usr/share/examples/cvsup/FreeBSD-ports-supfile

Doing buildworlds and buildkernel

To rebuild the system from the files obtained by CVS, do a build- and installworld.

Build the world:
# cd /usr/src
# make buildworld
# make installworld

If kernel-compiling is what your heart yearns for, proceed like described below. Create your custom kernel-config in /usr/src/sys/i386/conf/<YOURKERNEL>. If you do so, remember to keep a working kernel in /. /kernel.old is overwritten when you make installkernel; /kernel.GENERIC or /kernel.bak is a good thing to have if something goes wrong.

Rebuild the kernel
# cd /usr/src
# make buildkernel KERNCONF=GENERIC
# make installkernel KERNCONF=GENERIC

README

In any case you should consult the /README file, since by now it's the most up-to-date documentation-file for setting up DragonFly BSD. Some things mentioned there are not part of this writeup. If changes occur, you will likely find it in the README.

If you find some ugly written English here and feel provocated, drop me a mail. English is not my mothertongue.



This document was generated using AFT v5.094 and aft-dfly-html.pm