1&1 offers a very inexpensive dedicated root server with generous bandwidth allotments. In Canada home broadband is common and inexpensive but server colocation with decent monthly transfer limits is still outrageously expensive.
There are other US hosting companies that offer features/prices close to 1&1 however the ones I investigated (as far as I could tell) all lacked an essential tool. The compelling feature of 1&1 for me was that they offered a remote recovery tool and serial console option, both of these tools are priceless for any remote admin work. A free FTP account for backup purposes is another nice addition though I will still rely on other means for my nightly backups. Other large hosting companies that I am aware of are RackSpace, ServerBeach and EV1 Servers - of course there are numerous smaller providers where more personalized service should be available.
The only problem with 1&1, for me, was that I wanted to run Debian GNU/Linux and the server package only mentions the availability of Fedora Core 2. Since I had access to a remote recovery tool I decided that customization of the install, including changing the operating system from Fedora to Debian, shouldn't be too difficult. This page documents the method I used to install Debian on my 1&1 Root Server.
From now on, anything in a
box like thisis a command that you can enter directly from your rescue system's command prompt.
With only a 40GB disk I wanted to make sure I leave myself maximum flexibility. As a result of this I chose to use LVM for all possible partitions and to leave most of the disk unallocated until such time as space is needed.
I wanted to be able to grow the filesystems without unmounting any partitions, I chose to use XFS since it allows growing filesystems without first unmounting them. Reiserfs would also have been an option and (possibly) some other filesystems.
I wanted to be able to reinstall the server at any time without having to think. This meant that the install should be quick, easy and automated. I haven't really bothered fully automating the install but it would take very little additional work to accomplish that.
After purchasing my 1&1 server it turned out that Debian GNU/Linux install was an option. In fact Debian 3.0, Debian 3.1, SuSE Linux 9.1 and Fedora Core 2 (with or without Plesk) can all be installed with the click of a mouse.
Using the 1&1 web GUI I reimaged my server with Debian 3.1, it worked and within 1 hour my server was running Debian. Still, the server as installed by 1&1 did not meet my partitioning goals so I decided to proceed with my custom install ideas.
As stated, I wished to use LVM wherever possible. As far as I know, grub still cannot boot Debian when /boot is on a logical volume so I had to create a small "regular" partition for /boot and the rest of the disk was used as one big physical volume for LVM.
The following command creates a 75MB partition at the beginning of the disk (for /boot) and creates a second parition of type LVM that consumes the remainder of the disk.
sfdisk /dev/hda -uM << EOF
,75,83
,,8e
EOF
Following partitioning you should reboot or you will have problems with the LVM utilities later in the install process. There might be a workaround but rebooting is the no-brainer solution.
The second disk partition must be labelled as physical volume for LVM to work. Also we create a volume group named system. Issue the following commands:
pvcreate /dev/hda2
vgcreate system /dev/hda2
Next we create a bunch of logical volumes, one for every filesystem that we need (other than /boot), we also format all of the filesystems in preparation for use:
lvcreate -L 512M -n swap system
mkswap /dev/system/swap
lvcreate -L 512M -n root system
mkfs.xfs /dev/system/root
mkfs.ext3 /dev/hda1
tune2fs -c 0 -i 0 /dev/hda1
lvcreate -L 512M -n usr system
mkfs.xfs /dev/system/usr
lvcreate -L 1G -n var system
mkfs.xfs /dev/system/var
lvcreate -L 512M -n tmp system
mkfs.xfs /dev/system/tmp
lvcreate -L 2G -n home system
mkfs.xfs /dev/system/home
Next we mount all of the partitions we're going to need for the install:
mkdir /target
mount /dev/system/root /target/
mkdir /target/{boot,usr,var,tmp,proc,dev,sys,home}
mount /dev/hda1 /target/boot
mount /dev/system/usr /target/usr
mount /dev/system/var /target/var
mount /dev/system/home /target/home
mount /dev/system/tmp /target/tmp
chmod 1777 /target/tmp
chmod 1777 /target/tmp/
swapon /dev/system/swap
To install Debian I used the debootstrap utility, this is by far the easiest method. Unfortunately, you will need to copy the debootstrap utility and associated files into your rescue system because they are not there by default. If you have an existing Debian system then this is easy; tar up the package, copy it to your rescue system (using scp) and then extract it into the root of the rescue system. If you do not have a Debian system from which to grab debootstrap then you will have to grab it from the Debian servers.
The debootstrap utility will automatically fetch, install and configure a minimal Debian system into whichever directory you choose. The command I used was (choose whichever Debian mirror is most appropriate):
debootstrap sarge /target http://ftp.us.debian.org/debian/
Now that we have a minimal Debian system on our hard drive there are a few housekeeping issues to take care of before it will boot.
Configure /etc/fstab so that the system will know how to boot:
echo proc /proc proc defaults 0 0 > /target/etc/fstab
echo /dev/mapper/system-root / xfs defaults 0 1 >> /target/etc/fstab
echo /dev/hda1 /boot ext3 defaults 0 2 >> /target/etc/fstab
echo /dev/mapper/system-home /home xfs defaults 0 2 >> /target/etc/fstab
echo /dev/mapper/system-tmp /tmp xfs nodev,nosuid 0 2 >> /target/etc/fstab
echo /dev/mapper/system-usr /usr xfs defaults 0 2 >> /target/etc/fstab
echo /dev/mapper/system-var /var xfs nodev,nosuid 0 2 >> /target/etc/fstab
echo /dev/mapper/system-swap none swap sw 0 0 >> /target/etc/fstab
Configure /etc/kernel-img.conf so that our bootloader is correctly configured later, when we install the kernel:
echo do_symlinks = yes > /target/etc/kernel-img.conf
echo relative_links = yes >> /target/etc/kernel-img.conf
echo do_bootloader = no >> /target/etc/kernel-img.conf
echo do_bootfloppy = no >> /target/etc/kernel-img.conf
echo do_initrd = yes >> /target/etc/kernel-img.conf
echo link_in_boot = no >> /target/etc/kernel-img.conf
echo postinst_hook = /sbin/update-grub >> /target/etc/kernel-img.conf
echo postrm_hook = /sbin/update-grub >> /target/etc/kernel-img.conf
Copy the /dev/mapper directory used by LVM into our new system so that the LVM utilities can find them when we need it (very soon):
cp -a /dev/mapper /target/dev
We now chroot into our new hard drive so that we can finalize configuration
chroot /target
/proc needs to be mounted within our chroot so that various utilities can function:
mount /proc
Configure apt, i.e. choose which Debian mirrors to use:
apt-setup
Make sure our install is up to date, remove some utilities we don't need, install some utilities that we do need:
apt-get update
apt-get dist-upgrade
apt-get remove --purge ppp pppoe pppconfig pppoeconf
apt-get install iproute kernel-image-2.6 lvm2 ssh vim xfsprogs
Make sure via-rhine module gets loaded on boot (for network card):
echo via-rhine >> /etc/modules
Configure networking. Routing at 1&1 looks rather strange and the DHCP server does not setup correct routing by default (I plan to change this to a completely static config, just haven't got around to it yet):
echo auto lo eth0 > /etc/network/interfaces
echo iface lo inet loopback >> /etc/network/interfaces
echo iface eth0 inet dhcp >> /etc/network/interfaces
echo up ip route add 10.255.255.1/32 dev eth0 >> /etc/network/interfaces
echo up ip route add default via 10.255.255.1 >> /etc/network/interfaces
Install bootloader:
apt-get install grub
cp /proc/mounts /etc/mtab
grub-install --root-directory=/boot /dev/hda
Install kernel:
apt-get install kernel-image-2.6.8-2-686
Configure kernel and grub for serial console:
echo serial --unit=0 --speed=57600 --word=8 --parity=no --stop=1 > /tmp/menu.lst
echo terminal serial >> /tmp/menu.lst
cat /boot/boot/grub/menu.lst >> /tmp/menu.lst
sed -e 's|^\(# kopt=.*\)$|\1 console=ttyS0,57600n8|' \
< /tmp/menu.lst > /boot/boot/grub/menu.lst
update-grub
Enable getty for serial console:
cp /etc/inittab{,-}
sed -e 's|^#T0:.*|T0:23:respawn:/sbin/getty -L ttyS0 57600 vt100|' \
< /etc/inittab- > /etc/inittab
rm /etc/inittab-
Configure your hostname (obviously substitute in your correct IP and hostname):
echo 127.0.0.1 localhost > /etc/hosts
echo 82.XX.XX.XX hostname.domainname hostname >> /etc/hosts
echo hostname.domainname > /etc/hostname
Run base-config for some Debian setup stuff (not really necessary):
base-config
Get rid of /dev/mapper copy (not really necessary):
rm -rf /dev/mapper
Unmount /proc:
umount /proc
Exit chroot, unmount partitions and reboot:
exit
umount /target/usr
umount /target/var
umount /target/boot
umount /target/home
umount /target/tmp
umount /target
reboot
Your computer will reboot into a shiny new Debian sarge system, all disk partitions will be on top of LVM (/boot exception) allowing you to grow any filesystem as required (use lvresize, then xfs_growfs). Here is how the mounted filesystems look (note I had installed quite a few extra packages already when I ran this df command):
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/system-root 508M 61M 447M 12% /
/dev/hda1 73M 11M 59M 16% /boot
/dev/mapper/system-tmp 508M 272K 508M 1% /tmp
/dev/mapper/system-usr 508M 169M 339M 34% /usr
/dev/mapper/system-var 1014M 59M 956M 6% /var
/dev/mapper/system-home 2.0G 21M 2.0G 1% /home
The rest is up to you. Obviously you'll want to install more than the base system (apache, postfix, etc.). Track the software that you have installed and you can then easily recreate your system (check out dpkg --get-selections and dpkg --set-selections). You may also want to keep all of your config files and data (at least the reasonably static stuff like web content) in a version control system (hosted elsewhere).
Notice that base-config and apt-setup were the only interactive commands used. Should you wish to fully automate this install procedure it would be quite trivial.
Big caveat:This document depends on 1&1 not changing too many things, if they do there's a good chance something will break.
Feel free to email me if you have any questions.