Linode Library Home
Categories
Getting Started
Beginner's Guide
Using Linux
Linode Manager
Networking
LAMP Guides
LEMP Guides
Web Servers
Web Applications
Email Guides
High Availability
SSL Guides
Databases
Server Monitoring
Development
Communications
Advanced
Troubleshooting
How to Contribute
Sitemap
Linode Library RSS Feed
Linode Library Home :: Advanced Linode Guides :: Running a Custom Linux Distro on a Linode VPS
Print View Download PDF Download RST

Running a Custom Linux Distro on a Linode VPS

Author: Phil ParadisExternal Link
Published: August 18, 2009
Revised: March 19, 2010

If you'd like to run a Linux distro on your Linode that isn't available from our distros list, you may do so by following these instructions. This guide is handy for folks who prefer distros that aren't heavily used in the community, or for those interested in creating a highly customized Linux environment and porting it to their Linode VPS.

These instructions work with the Linode platform. If you don't have a Linode yet, sign up for a Linux VPS and get started today.

Install Your Distro Locally Link

Our example uses Sun xVM VirtualBoxExternal Link, a free virtualization suite, to install a Linux distribution locally. You could use another virtualization package (such as VMware or Parallels) to create your VM, or you could skip to "Set up Finnix and Copy your VM Image" if you already have a Linux VM that you'd like to run on your Linode.

We're using Mandriva Linux Free 2009.1 as the guest operating system in our example, but you could install virtually any distro you like. To get started, launch VirtualBox and click the "New" icon to begin creating a local VM. Start by giving it a name.

Naming a VM in VirtualBox.

Create a new virtual hard disk for the VM, and specify "fixed" for the type.

Specifying fixed type for a new hard disk in VirtualBox.

Specify a size for the new virtual hard disk. You'll want to create a hard disk just a bit larger than will be necessary to hold your installed Linux distro.

Specifying a virtual hard disk's size in VirtualBox.

After the virtual hard disk is created, click "Settings" in main VirtualBox window. On the "Storage" tab, check "Mount CD/DVD Drive" and specify the your Linux distro's install CD image as the ISO to mount.

Specifying an ISO to use as a virtual CD-ROM drive in VirtualBox.

Disable audio, as your VM will be functioning as a server.

Disabling audio for a VM in VirtualBox.

Specify "Bridge Adapter" for networking to allow your VM to be reached from anywhere on your local network. This is handy for testing network services running on it prior to pushing it up to your Linode.

Specifying bridged networking for a VM in VirtualBox.

Boot up the VM, and it should run the installer found on your distro's installation CD. When you get to the installer's section for disk partitioning, choose a single partition for "/" and create a small swap partition.

Specifying a single root partition for a Linux install in VirtualBox.

Select the packages you'd like installed on your server, excluding any graphical desktop suites or other graphical packages. You may wish to install an OpenSSH server as well for easy remote administration.

Specifying packages to be installed in a Linux install in VirtualBox.

If your installation routine configures a firewall, be sure to open the ports you'll need for services like SSH and HTTP (web server).

Specifying firewall ports to open in a Linux install in VirtualBox.

Many Linux distributions will install a desktop kernel by default. If you're going to keep this VM around for local testing, you may want to install a server kernel instead. This won't matter once your server's image is transferred to your Linode, as it will boot using a host-supplied kernel. In our case we executed the command "urpmi kernel-server-latest" to get a kernel more suited to server tasks installed. Please note that some kernels may require PAE to be enabled in VirtualBox.

Enabling PAE for the virtual CPU in VirtualBox.

If you installed a different kernel in your VM, reboot to use it. Install any additional packages you need and power down the VM. Next, you'll need to download the ISO image for Finnix, an useful bootable Linux environment. Set the virtual CD/DVD drive for your VM to boot the Finnix image.

Setting the CD-ROM drive to boot a Finnix ISO image in VirtualBox.

Set up Finnix and Copy your VM Image Link

Under the dashboard tab in the Linode Manager, click "Create a new Disk Image", making an ext3 image large enough to contain your VM's virtual hard disk.

Creating a new ext3 disk image in the Linode Manager.

Create a 256 MB swap image as well.

Creating a new swap disk image in the Linode Manager.

Under the Dashboard tab in the Linode Manager, click "Create new Configuration Profile" and specify the following values for Finnix:

Create a Finnix recovery profile in the Linode Manager.

Boot the Finnix profile in the Linode Manager, set the root password, and start sshd:

passwd root
/etc/init.d/ssh start

Boot into Finnix in the local VM and start the disk copy operation over ssh (replace 12.34.56.78 with your Linode's IP address):

dd if=/dev/hda1 | ssh 12.34.56.78 "dd of=/dev/xvdb"

After the copy operation has completed, you should see output resembling the following:

5076477+0 records in
5076477+0 records out
2599156224 bytes (2.6 GB) copied, 10116.1 s, 257 kB/s
5076476+2 records in
5076477+0 records out
2599156224 bytes (2.6 GB) copied, 10116.6 seconds, 257 kB/s

You may shut down your local VM now.

Configure Your New Linode Image Link

In the Linode Finnix console, mount the new disk image:

mount /mnt/xvdb
cd /mnt/xvdb
ls

The output of ls should resemble the following:

bin   dev  halt  initrd  lost+found  mnt  proc  sbin  tmp  var
boot  etc  home  lib     media       opt  root  sys   usr

Edit the fstab file in the mounted filesystem; root and swap should be /dev/xvda and /dev/xvdb.

File: /mnt/xvdb/etc/fstab

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/xvda       /               ext3    errors=remount-ro 0       1
/dev/xvdb       none            swap    sw              0       0
proc            /proc           proc    defaults        0       0

If your distro is not using upstartd, edit etc/inittab and comment out all gettys but one. Change the first getty to run on /dev/hvc0.

Section in file: /mnt/xvdb/etc/inittab

# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty hvc0
#2:2345:respawn:/sbin/mingetty tty2
#3:2345:respawn:/sbin/mingetty tty3
#4:2345:respawn:/sbin/mingetty tty4
#5:2345:respawn:/sbin/mingetty tty5
#6:2345:respawn:/sbin/mingetty tty6

Some distros may not have the file shown above. If you're running Ubuntu 9.10 (or a distro based on it), you'll need to examine the contents of etc/init instead. Open the file tty1.conf and change the getty entry to run on hvc0. Delete all other "tty[number].conf" files found in this directory.

If you're using upstartd, remove all tty files in /mnt/xvdb/etc/event.d except tty1. You'll also need to change its filename by issuing the command mv /mnt/xvdb/etc/event.d/tty1 /mnt/xvdb/etc/event.d/hvc0

Check that "/mnt/xvdb/dev" looks complete. If not, chroot to the mountpoint and MAKEDEV it. Syntax for MAKEDEV may vary slightly by distro.

chroot /mnt/xvdb /bin/bash
MAKEDEV /dev

If necessary, manually create xvd[a-h] device node entries.

cd dev
mknod xvda b 202 0
mknod xvdb b 202 16
mknod xvdc b 202 32
mknod xvdd b 202 48
mknod xvde b 202 64
mknod xvdf b 202 80
mknod xvdg b 202 96
mknod xvdh b 202 112

If /dev/hvc0 doesn't exist, you'll have to mknod it as well:

mknod hvc0 c 229 0

Exit the chroot:

exit

If your distro is using udev (most distros are these days), cd to /mnt/xvdb/etc/udev/rules.d (if you're using a distro based on Ubuntu 9.10, cd to "/mnt/xvdb/lib/udev/rules.d" instead) and open the file that creates the persistent network rules, usually 75-persistent-net-generator.rules. Modify this file so that it does not create persistent rules for eth*. In this case we simply removed eth* from the beginning of the kernel whitelist.

cd /mnt/xvdb/etc/udev/rules.d
nano 75-persistent-net-generator.rules

The relevant section in the file should resemble the following:

# device name whitelist
KERNEL!="ath*|wlan*[0-9]|msh*|ra*|sta*|ctc*|lcs*|hsi*", \
                GOTO="persistent_net_generator_end"

Remove any rules that were auto generated already (in this case, /mnt/xvdb/etc/udev/rules.d/70-persistent-net.rules).

rm /mnt/xvdb/etc/udev/rules.d/70-persistent-net.rules

If it exists, also remove the cd rules file:

rm /mnt/xvdb/etc/udev/rules.d/70-persistent-cd.rules

Create a profile for your new distribution.

Creating a custom Linux profile in the Linode Manager.

If you're using a distro based on Ubuntu 9.10 or Arch, you'll need to select kernel version 2.6.31.5 or later. Reboot into your new distribution from the dashboard. Congratulations, you've installed a custom Linux distro our your Linode!

License Link

This guide is licensed under a Creative Commons Attribution-No Derivative Works 3.0 United States LicenseExternal Link. Please feel free to redistribute unmodified copies of it as long as attribution is provided, preferably via a link to this page.

Comments

Comment poster gravatar. Submitted by Anonymous Visitor on Monday, June 21 2010 at 21:15:15 GMT

When you get the error "Kernel panic - not syncing: No init found. Try passing init= option to kernel.", it means you didn't set the initrd (see the sixth arrow in the "Finnix recovery" linode configuration profile screen above).

Comment poster gravatar. Submitted by Anonymous Visitor on Thursday, August 12 2010 at 01:45:27 GMT

If you are having trouble booting enable the IO-APIC option under Settings->System->Motherboard.

Got a comment?

BBCode formatting is allowed. Email addresses are confidential, and are only used for gravatars and sending document/comment updates if requested. Please refer to our privacy policy. All comments are moderated and may take some time to appear on this page.