Installing FreeBSD Manually
From FBSD_tips
WARNING: THESE METHODS ARE DESTRUCTIVE. BACKUP ALL DATA BEFORE YOU START, OR IT WILL BE LOST
I don't like sysinstall. I consider it to be the worst part of FreeBSD and an experience that no new user should have to go through. That
said, here are instructions for installing FreeBSD without using the sysinstall interface.
Note: you need disc1, not just bootonly. bootonly lacks a livefs.
This assumes you are making a Dedicated Disk, without an MBR.
Contents |
[edit] Starting the installation
[edit] From the FreeBSD CD
In the initial sysinstall menu, go to Fixit -> CD/DVD.
[edit] From an existing FreeBSD Installation
You can just as easily install from an existing freebsd installation, just remember that the disk commands are not usable if you are mounted from that disk.
A common use is to populate a jail, simply export DESTDIR=/path/to/jail, and jump to the extraction
[edit] Environment Variables
A few environment variables need to be set, first:
export EDITOR=ee
or
export EDITOR=vi
export DESTDIR=/mnt
this is where our freebsd install will be mounted to so we can install the sets.
[edit] Disk Preperation
first, choose the disk you are going to use. In my example I'm going to use ad0 (primary master ATA hard drive)
to get a list, use:
geom disk list
now, the strange part. the livefs is mounted in /mnt2, but alot of the geom utilities are relative to /, so they don't work (at least on my -current snapshot). to be safe, chroot to /mnt2, create a devfs there, and do all geom work there:
chroot /mnt2
and
mount -t devfs devfs /dev
first, we give the drive a name, let's call it drive0: (loading the geom class is unnecessary on FreeBSD 7.x, so skip too the next)
geom label load
then:
geom label label -v drive0 /dev/ad0
Now, if you want to use a mirror instead, first load it with:
geom mirror load
and label the drives you want to be part of the mirror:
geom mirror label -v gm0 /dev/ad0 /dev/ad1
then set the mirror device to drive0:
geom label label -v drive0 /dev/mirror/gm0
Now you are using a mirror instead of a single drive (note, you can't do this with most other geom classes, see Advanced Installation for notes on it.
Also remember to add:
geom_mirror_load="YES"
to loader.conf in the last step.
GEOM labeling now will give you alot of flexibility when it comes to the disks, no matter where the disk is or what id number it gets the geom_label driver will assign it this device name. It makes writing fstab and config files alot simpler.
now, we write a label the disk:
bsdlabel -w /dev/label/drive0
and make it bootable:
bsdlabel -B /dev/label/drive0
now, we edit the label:
bsdlabel -e /dev/label/drive0
(if you haven't exited out of the chroot, you'll get an error as it will attempt to write to the read-only cd, just type exit and continue with the instructions)
this will open EDITOR and let you edit the disk label, resizing and so on. for the example, we'll just change a's fstype from unused to 4.2BSD and exit out. this will give one big root filesystem, and no swap space. You can just as simply add more partitions. Just remember you need to add them to fstab!
[edit] Creating the Filesystem
first, we create a clean ufs2 filesystem on a, and name it 'root'
newfs -L root /dev/label/drive0a
now, we mount it:
mount /dev/ufs/root /mnt
[edit] Extracting distfiles
in /mnt2, there will be a directory named, for example, 7.0-CURRENT-200610, or 6.1-RELEASE.
this directory contains the distribution sets and the installer files.
the two we definately need are base, and kernels.
first:
cd base
then:
./install.sh
It'll prompt for an 'are you SURE', then begin copying all the system binaries to the hard drive.
now:
cd ../kernels
all dists are installed using a ./install.sh script, some, like kernels', need an extra option. for example, the name of the kernel you want to install. 6 has SMP and GENERIC on the cd, so pick the kernel and type:
./install.sh KERNELNAME
[edit] The two most important steps
1) run:
$EDITOR /mnt/etc/fstab
you'll be given an empty file, but write in the name of each partition you've created, and where they are mounted to. For our example, it would be:
/dev/ufs/root / ufs rw 1 1
2) run:
$EDITOR /mnt/boot/loader.conf
you'll also be given an empty file, but add these two lines:
kernel="GENERIC" geom_label_load="YES"
now:
umount /mnt
exit sysinstall or just power off the machine.
[edit] Notes
NOTHING IS SET UP! rc.conf is empty and the root account is passwordless. This /is/ a base FreeBSD install. Please note this and edit rc.conf and passwd your accounts accordingly.
The root filesystem will have the same name on every machine; for a few reasons, this is considered a bad thing to do; If you'd like to avoid it, look here
