User Tools

Site Tools


Install OS on Linode

See Linode's setup instructions on how to get the basic Linux system created on your VPS. I currently prefer Debian, mainly because their package installer system apt-get resonates with me and their base package is relatively small with little “toy” overhead.


The purpose of this partitioning scheme is to keep the system parts separate from the locations where external users' data reside. The main contributions to potentially unbounded data growth are from the web server and its applications (e.g. wordpress) and the database, hence /var and /srv will be on a different partition from root. A web server doesn't have many users that directly login to the system, so a separate /home partition is not really necessary. Linod's Xen hosting are already a set of virtual drives, so no additional LVM is necessary. The Linode Manager allows to resize those disk images, so sizes can be adjusted if the initial partitioning turns out to be too tight.

directory device size image name
/ /dev/xvda 1GB rootImage holds /bin, /usr, /etc, /lib, system directories
swap /dev/xvdb 512MB use Linode's swap image
/tmp /dev/xvdc 1GB varTmp
/var /dev/xvdd >5GB varImage storage for apache and mysql
/srv varImage will be a symlink from /var/srv
/home /dev/xvde 1GB varHome user home directories

I chose to create a separate ~1GB partition for /home, it's mainly for convenience to keep my own data and scripts alive while I rebuild a linode.

Create Configuration Profile

Production system

On the Linode Dashboard, create a new Configuration Profile by clicking on “Deploy a Linux Distribution”: pick your distribution of choice, I prefer Debian 32bit on a VPS. Under “Deployment Disk Size”, start with 1024MB (we'll have separate partitions for the high-volume directories). After entering a *strong* password, click “deploy” to generate the profile.

Once it shows up as ready in the Dashboard, click on it to edit it, starting with giving it a less generic name, e.g. “Debian LAMP server”. Under “Block Device Assignments”, start associating the /dev/xvda etc. devices with the disk images you've created in the Partitioning section. Note that this assignment, once the OS is booted, only makes the disk images visible as devices. We'll still have to actually mount the partitions once the system is booted up.

Recovery and Maintenance Profile

Linode also offers a minimalist kernel setup for recovery or maintenance access to our production system. We'll need this kernel later prepare and populate the additional disk images for /var and /home. From the Dashboard, click on “Create a new Configuration Profile”, give it a name like “Finnix Maintenance” and select the “Recovery - Finnix” kernel. In the Block Device Assignment section, associate the same devices to the disk images as you did above for the production system. For the first unassociated device, associate it with the Finnix kernel ISO/LiveCD, e.g. /dev/xvdf. Make sure you also select the device with the Finnix kernel as the Root Device to boot from.

This screenshot captures how I set up my recovery profile, it corresponds to the partitioning scheme I chose above:

device assignments for recovery profile

Base OS Configuration

First boot

From the Dashboard, select and boot the production system (*not* to the Maintenance kernel yet). See also Linode's Getting Started.

SSH fingerprint

To connect to your system the first time, use the Lish Ajax Console from the node's Remote Access tab. Once logged in, it's a good idea to first display the new system's ssh public key fingerprint:

ssh-keygen -l -f /etc/ssh/

Now use ssh (Linux) or putty (Windows) to connect to your node; use the above fingerprint to verify and cache the key.

On the first session, do a couple of important housekeeping tasks:

update the distribution
apt-get update
apt-get upgrade --show-upgraded

If a new kernel was installed as part of the upgrade, reboot and reconnect via ssh.

new host name
echo "geek" > /etc/hostname
hostname -F /etc/hostname

Also edit the static host resolution file /etc/hosts :        localhost.local              localhost             geek

Either use the reconfigure script:

dpkg-reconfigure tzdata

or create a link from the desired timezone data file under ''/usr/share/zoneinfo', e.g.:

ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

Installs sudo and visudo:

apt-get install sudo
set defaults

Select default editor, e.g. vi (I really don't like nano)

sudo update-alternatives --config editor

Attach additional disk images/partitions

The following steps assume the partition association from the above Partitioning section. Since some of the production system's directories (e.g. /home and /var) already have content, it's necessary to copy their content while booted into the recovery/maintenance OS that we created above.

From the Linode Dashboard, shutdown the production system and select and boot the Finnix Maintenance profile. To connect to the Finnix system, you will need the Lish console from the Linode Remote Access tab.

Mount the partitions

Mount the production system's root partition to /mnt:

mount /dev/xvda /mnt

Create mount points for the additional partitions and mount those:

mkdir -p /new/{var,home}
mount /dev/xvdd /new/var
mount /dev/xvde /new/home

Note that I won't bother to mount and copy the /tmp directory (but we'll create an fstab for it of course).

Move the data

Start with copying the production system's /home and /var directory (we'll delete the source data later):

cp -a /mnt/home/* /new/home/
cp -a /mnt/var/* /new/var/

Update fstab

Next, update the file system configuration how to mount the home and var partitions:

vi /mnt/etc/fstab

Add 3 new entries to /mnt/etc/fstab:

/dev/xvdc       /tmp            ext3    defaults        0       0
/dev/xvdd       /var            ext3    defaults        0       0
/dev/xvde       /home           ext3    defaults        0       0

Cleanup and reboot

With the content moved, it's time to remove the stuff in the /home, /tmp and /var directories. But do not delete the directories themselves, they are the needed mount points. Be careful you do specify the /* at the end of each directory to only delete its contents:

rm -Rf /mnt/home/*
rm -Rf /mnt/tmp/*
rm -Rf /mnt/var/*

Unmount the additional filesystems and reboot:

umount /new/home
umount /new/var
umount /mnt
shutdown -h now


Non-root user

create non-root user: add to sudoers with visudo

SSH login

linode-install-os.txt · Last modified: 2014/11/01 14:14 (external edit)