13 December, 2009

Home server based on Ubuntu Server 9.10

I have just bougth a new HW to replace my pretty outdated home server and decided to install Ubuntu server on it. The hardware itself is a standard desktop PC, with and Athlon II X2 CPU and 4 Gigabytes of RAM. This amount of RAM is only needed because I plan to run Virtual Machines on the server, which is consuming a lot of memory. I have 3 SATA disks in the machine one with 250G and two each 1T. The 250G disk is ment for the system, while the 2 bigger disks will form the 2T data storage part.

The basic networking funcions like DHCP, DNS are provided by a Ericsson W25 3G router so this server is mainly to provide storage for the Windows and Linux computers at home. As a server running continuosly consumes a lot of power, this server can be remotely shut down and waken up, to run only when it is needed.

So here are the steps of the installation:

  1. Install Base System: Download the Ubuntu Server 9.10 64 bit version and do a standard installation. I have used a 20 G install partition and accepted the 10 G swap partition. When selecting the options, I went fo LAMP server, Open SSH, Samba server. I was thinking about installing the virtual machine host, but finaly decided to go for VMWare Server, which may be easier to use.
  2. Install WEBMin: To have an easy to use administration interface, install Webmin based on this guide: http://www.ubuntugeek.com/ubuntu-serverinstall-gui-and-webmin-in-ubuntu-810-intrepid-ibex-guide.html
  3. Create a Logical Volume for data: Now for the data disks we will use logical volume management (LVM2), later this will make it easier to add or remove hard disks, without having to backup all data. For this we need to add the module lvm2 with the following code:
    sudo apt-get lvm2
    After this on the Webmin interface press "refresh-modules", then goto the Hardware/Logical Volume Management and first create a Volume Group, by adding the first 1T hard disk, the go the the Physical disk part and add the second 1T hard disk. Now you have a Volume Group with 2 T space, now add a logical volume to it, ocupying all space. Before adding the physical disks to the volume group, you may need to create a single partition on the, ocupying all space. I have used the name "disks" to the Volume Group and "data" for the Logical Volume, this way, the created 2T volume can be accessed under /dev/disks/data.
  4. Format the data disk: Unfortunately webmin do not support exfs4 so we have to format the disk by ourselves, with the following command:
    mkfs.ext4 /dev/disks/data
    We do not want the disk checking to run on startup and we don't need to reserve any space on the volume, so we adjust it:
    tune2fs -r 0 -c 0 -i 0 /dev/disks/data
  5. Creating users: In my setup every user has teh same access rights on the data volume, and this is achieved, by putting everyone to the "users" group and adding write access for this group to all files. For this we need to create one account for each family member and add them to the users group, this can be easily done on the Webmin web interface.
  6. Mounting the new disk: First create a directory "/media/data" as root then add the following line to /etc/fstab:
    /dev/disks/data /media/data ext4 defaults 0 2
    Now check if the volume was really mounted.
    sudo mount -a
    If it mounts well, then let's create a subdirectory for storing user data:
    sudo mkdir /media/data/UserData
    sudo chown youraccount:users /media/data/UserData
    chmod 0775 /media/data/UserData
  7. Setting up Samba: Samba is neede to provide access to Windows computers. The default setups is already working after installation, what we need to do is to share the UserData directory and add users to Samba.
    The simplest way of adding users is to use WEBMin and in the Servers/Samba use the Convert unix users menu. The dafult settings are Ok, we just need to run the import.
    With shares we need to add one share for the data volume. There are two spacial aspects, in the access permissions for the share you should enable write access and in the file permission part you should chane both file and directory permission to 0775 to give other family member the possibility to write the files.
We are now done with the first part, what remains is to create a small web interface to check the disk usage and to be able to hibernate the system. I will write about that in a next post.

2 comments:

Anonymous said...

You made a 10 GB swap partition?! Why so large?

Lacó said...

Actually that was proposed by the installer and I had no problem with it.
For the main partition I prefer to keep it relatively small because I use to do complete partition backups and the 20G is better than 200G :-)