Planet Fox > Computer World > The MAINFRAME > Software and Operating System

Software and Operating System

There's really only one choice when it comes to OS, and that's FreeBSD, because Linux just isn't geeky enough. I always go with FreeBSD for projects like this, since it's stable, secure, easy to set up and administer, and of course I'm already pretty familiar with it, since for a couple of years I used it for a desktop on a machine that was too slow to run the current version of Windows. It's more or less made for a networking environment, since it supports telnet, SSH, FTP, NFS and a whole bunch of other acronyms right out of the box.

If you're planning on doing the software RAID thing, make sure that when you partition your drive you leave around 1MB of free space. Trust me, it makes things a lot easier later.

I set it up for four users, the root account, admin, www, and server. Admin is a high level account that's part of the wheel and operator groups, and I use it to login via telnet then su to root, since the system doesn't allow root to login directly that way. It's also used for day to day administrator type tasks like moving files around. Server is a limited account with read/write privileges only to its home directory. When I setup Samba this is the account I based the file share around, it's also what I use for remote FTP and NFS access. The Apache web server, httpd, runs under its own user account, www. A separate user account, webmaster, is part of the www group and is used to  load files to Apache's data directory, the permissions of which are set to 775.

The best part about FreeBSD is how easy it is to install software, you can either use the precompiled binary packages, or compile the from source code via the ports collection. So, I wanted it to be easily accessible from anywhere, which means assigning it a domain name. Since my phone company gives me a dynamic IP, I went with DNS Exit, since they provide services specifically for that market. DNS Exit uses a Perl script to keep track of your IP changes, so I installed Perl before anything else and setup the script to run at boot time and check for changes every 10 minutes.

At this point, /etc/rc.conf looked like this:


The third line turns on inetd, which is a sort of super daemon that takes care of telnet, ftp, ssh, etc... Edit /etc/inetd.conf and uncomment whatever services you want it to handle. Having FTP enabled is super handy, since every computer ever has an FTP client. Telnet allows me to login from any computer anywhere, because, like FTP, it's included on every computing device ever, and it's the primary way I access the server from home. The SSH service works like telnet, but encrypts username/passwords and session data. It's highly useful if you'll be logging in to your server from an unsecured connection like public wifi or at a hotel, but you'll need to run sshd at least once manually to generate the cryptographic keys, since starting it from inetd doesn't do that for some reason. Ntpd keeps the clock synchronized with Make sure your BIOS clock is set to UTC or this won't work right.

Software RAID

So, like I mentioned, my board didn't have a RAID card. No biggie, FreeBSD supports software RAID. First thing I do is add

options        geom_mirror

to the kernel configuration file and build a new kernel. You can also load it as a module.

 Now, I have three discs, FreeBSD is installed on a 24GB partition on a USB disc, da0, and I have two identical Hitachi Ultrastar 1TB discs that I want to use for my mirrored volume. Creating the mirror, gm0, is as easy as

# gmirror label -v gm0 /dev/ada0 /dev/ada1

Now that I have a mirror, I need to setup a partition table. I chose to use the entire disc to create a single MBR style FreeBSD partition.

# gpart create -s MBR mirror/gm0
# gpart add -t freebsd -a 4k mirror/gm0

Now I just need to add some FreeBSD "slices" to my gigantic partition. I'm using a 24GB partition for the operating system, a 2GB swap partition, and a 905GB (disc manufacturers have a really weird definition of a terabyte) partition for /usr/home

# gpart create -s BSD mirror/gm0s1
# gpart add -t freebsd-ufs  -a 4k -s 24g mirror/gm0s1
# gpart add -t freebsd-swap -a 4k -s 2g mirror/gm0s1
# gpart add -t freebsd-ufs  -a 4k -s 905g mirror/gm0s1

Now I just need to add the bootcode, set the partition as active, and format everything. (Note: the swap partition doesn't need to be formatted.)

# gpart bootcode -b /boot/mbr mirror/gm0
# gpart set -a active -i 1 mirror/gm0
# gpart bootcode -b /boot/boot mirror/gm0s1
# newfs -U /dev/mirror/gm0s1a
# newfs -U /dev/mirror/gm0s1d

At this point I had to reboot, the startup in single-user mode so I could disable journalling on the main filesystem, since dump fails when they are enabled.

# tunefs -n disable /

Now I can use dump and restore to migrate the OS from the USB disc to the mirrored volume. This part takes a while. Note: make sure you're using csh when you do this.

# mount /dev/mirror/gm0s1a /mnt
# dump -C16 -b64 -0aL -f - / | (cd /mnt && restore -rf -)

Now the only thing left is to replace all of the references to /dev/da0 in /mnt/etc/fstab with /dev/mirror/gm0 and reboot. It doesn't matter which of the mirrored drives the BIOS is setup the boot from, since they contain identical data.

Powered by FreeBSD
Valid HTML 4.01
Site Map
©MMIX-MMXIV Planet Fox