From Iseborn Wiki
Jump to: navigation, search

I decided to use my old TV PC, a tiny Packard Bell imax mini N3600, as a server on my home network. Its CPU is only an Atom, but I mainly want to use it to better test out my web site stuff before deployment, so I basically just need a LAMP stack and an FTP server on it (for now). If it gets a bit slow, I'll just consider it a simulation of heavy Internet traffic :)

Ubuntu/Server/Installation and set-up

Continual tasks

Rebooting the server

To reboot the server immediately:

sudo reboot

Shutting down the server

To shut down (power off) the server immediatley:

sudo shutdown -P now

Without the -P option, the system is brought down to single-user mode (as root).

Check for system notifications

I'll find a way to make the server send an email when something needs to be done with it, but for now, just log on using ssh or PuTTY once in a while to see if ypu are told tht there are outstanding updates or if the system needs rebooting.

Freeing up space on /boot

When /boot is filling up, it is usually due to all the kernel updates stacking up.

To list all installed kernel versions:

dpkg -l linux-image-\* | grep ^ii

One command to show all kernels and headers that can be removed, excluding the currently running kernel:

kernelver=$(uname -r | sed -r 's/-[a-z]+//')
dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve $kernelver

Note that I said the currently running kernel, i.e. not necessarily the latest kernel. So when you have updated the kernel, and then rebooted and tested the new version, you can run the command below to remove all the old ones. If you have problems with the latest kernel, reboot with the latest that worked before running the command.

Command to remove all kernels and headers that can be removed, except for the currently running kernel:

sudo apt-get purge $(dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve "$(uname -r | sed -r 's/-[a-z]+//')")

How to access the server

While initially setting up the server, I had it connected to my stationary PC's monitor via HDMI. That way I could switch back and forth between displaying the stationary or the server. I could also use the monitor's split-screen function to display both at the same time. I also had a USB keyboard connected to it (no mouse though since Ubuntu Server does not have a GUI), and a network cable.

But that was just for the initial set-up. As soon as I get around to it, I will pull all cables from it (except for the power cord, obviously) and place it somewhere out of site. No monitor, no keyboard, no network cable (just WiFi). Instead I will use the PuTTY SSH client to open a terminal on it from my stationary PC.

Install PuTTY with:

sudo apt-get install putty

Start PuTTY by entering putty in a terminal window. Once started, you can right-click the PuTTY icon in the Launcher bar and select "Lock to Launcher" from the drop-down menu to make it easy to access.

All you need to connect to the server is to enter its IP address (in the "Host Name (or IP address)" field), and click "Open". I still recommend that you save the session (from the same dialog page) so you don't need to remember the IP address.




Each time you log on to the server, it will tell you if there are any updates to install. It may look something like this:

18 packages can be updated.
10 updates are security updates.

I think that I managed to set up the server to automatically install the security updates (though I'm uncertain of the actual mechanics of it), but other updates will not be dealt with automatically.

To install all updates at once, log on to the server with PuTTY, and give the following commands:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade  # Optional - Will install additional *major* updates/upgrades

NOTE: If I understand correctly, the information about available updates that is shown at log-in comes from a file that is only updated once a day. So if you log out and back in again after the update, you will get the same message even though the updates are now installed.

Adding FTP users

If you have a user account on the server, you can use that to log on to the FTP server. That is however not how you typically do it. You should add a dedicated FTP user for each path on the server that you want to expose for FTP use.

I failed to make my FTP users non-interactive (well, actually I did manage to make them non-interactive, but then they couldn't use FTP either), so until I have learned how to do it right, I will create FTP users as normal users, i.e. like this:

sudo adduser the_new_user_name

The typical reason for me to create an FTP user is when I add a new (test) web site on the server (see XXX). Such FTP users should always have the prefix "ftp_web_" in their name (for example ftp_web_eu). That way the /usr/local/sbin/adduser.local script (see XXX) will detect their creation and make necessary adjustments for web development usage.

Mounting a CD or DVD

The logical name (device name) for the optical drive on the server is /dev/cdrom.

I have chosen to mount all drives under /media on the server, so I'll use /media/cdrom as mount point for the optical drive.

If you haven't already done so, create the mount point directory:

sudo mkdir /media/cdrom
sudo chmod 777 /media/cdrom

To mount a CD or DVD, insert it into the drive, and then mount the drive with:

sudo mount -t iso9660 -r /dev/cdrom /media/cdrom

The -t iso9660 option tells mount that this is a CDROM.

The -r option tells mount to mount the drive as read-only. The only thing that happens if we skip it is that mount will first attempt to open the drive for read&write (which it cannot unless we insert a writable disc), and will give us a warning that it opens the drive as read-only instead. So, -r is just to get rid of that warning - the end result is the same.

That's it. Now you can access the CD/DVD as /media/cdrom.

When you are done with it, dismount it before removing the disc:

sudo umount /media/cdrom

Mounting a flash drive

First you need to know what the drive is called. Run this command:

sudo fdisk -l

The device you are looking for will be called something like /dev/sdd and the partition to mount will be similar to /dev/sdd1, so we will use the latter as example.

Then you create a mount point (just an empty directory). I typically use /media/usb for drives that I just add temporarily, so that directory always exists - but you just create whatever directory you want:

sudo mkdir /media/usb

Then you just mount the device like this (remember that this is just an example - you need to provide the correct partition name you got from the first step above):

sudo mount /dev/sdd1 /media/usb

That's it. When you want to remove the flash drive, run this first:

sudo umount /media/usb