Minimal Ubuntu 8.04 Server Install

Want to support HowtoForge? Become a subscriber!
 
Submitted by maxbash (Contact Author) (Forums) on Fri, 2008-09-12 15:41. :: Ubuntu

Minimal Ubuntu 8.04 Server Install

I find myself removing packages that I don't need, especially if the packages belong to processes that are using processor resources. There is a way to start from the ground up, you can have a minimal system and just add what you need. This has the added benefit of extra security, your system doesn't have services running that you don't use. You won't use a Ubuntu Server CD, but the Desktop Live CD.

 

1 Partition and Format drives

The tutorial is targeted for Sysadmins and more experienced users, so you probably know how you want to configure your storage. You could create a software RAID, my RAID 10 tutorial can guide you how to set up a RAID array in a Live CD environment.

Create your partitions, this example has a 50MB boot partition, a xfs formated root partition, and a 2GB swap partition.

sudo su
cfdisk /dev/sda
mkfs.ext3 /dev/sda1
mkfs.xfs /dev/sda2
mkswap /dev/sda3

 

2 Use debootstrap to create a minimal system

Mount file system and install debootstrap:

mkdir /min
mount /dev/sda2 /min
mkdir /min/boot
mount /dev/sda1 /min/boot

apt-get install debootstrap

By default debootstrap will download about 100 MB from ubuntu.com. Change the url on the third line to the best mirror you have access to.

nano /usr/share/debootstrap/scripts/hardy

case $ARCH in
amd64|i386|sparc)
default_mirror http://mirror.xmission.com/ubuntu

Use debootstrap to create the minimal install:

debootstrap hardy /min

 

3 Configure your install

A few settings not configured in the install can just be copied from the Live CD environment:

cp /etc/hosts /min/etc/
cp /etc/network/interfaces /min/etc/network/
cp /etc/bash_completion /min/etc/
cp /etc/bash.bashrc /min/etc/

Set up mount folders for your optical drive:

mkdir -p /min/media/cdrom0
ln -s cdrom0 /min/media/cdrom

Configure your file system table:

nano /min/etc/fstab

proc            /proc           proc    defaults                   0       0
/dev/sda2	/               xfs    relatime                   0       1
/dev/sda1	/boot           ext3    relatime                   0       1
/dev/sda3	none            swap    sw                         0       0
/dev/cdrom      /media/cdrom0   udf,iso9660 user,noauto,exec,utf8  0       0

 

4 Chroot into your minimum install to prepare it for booting.

Set up and enter your chroot enviroment:

mount --bind /dev /min/dev
mount -t proc proc /min/proc
mount -t sysfs sysfs /min/sys
chroot /min

Install tools for your file system, unless you're only using ext2 or ext3.
Say yes at the verification prompts:

apt-get install xfsprogs

Set your timezone, match the zoneinfo directory to your location:

cp /usr/share/zoneinfo/America/Denver /etc/localtime

Install your favorite config editor.

apt-get install nano

Update your sources.list to have all the packages and updates from your favorite mirror.

nano /etc/apt/sources.list

deb http://mirror.xmission.com/ubuntu hardy main restricted universe multiverse
deb http://mirror.xmission.com/ubuntu hardy-updates main restricted universe multiverse
deb http://mirror.xmission.com/ubuntu hardy-security main restricted universe multiverse

Update your system.
You can ignore the locale warning.

apt-get update
apt-get dist-upgrade

Set root password and set up a user:

passwd
adduser maxbash

Set up sudo for your user:

addgroup admin
adduser maxbash admin
echo "%admin ALL=(ALL) ALL" >> /etc/sudoers

 

4 Make the minimal system bootable

Install the kernel and boot loader:

apt-get install linux-image-server grub
mkdir /boot/grub
update-grub

Make sure all of the needed kernel modules are installed in the inital ramdisk.

update-initramfs -u

Exit your chroot:

exit

Install grub to the MBR:

grub-install --root-directory=/min --no-floppy --recheck /dev/sda

Reboot into your new system.


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Sun, 2009-07-19 04:28.
How can I run this on a machine with 128 MB of RAM?  The minimum requirements to run an Ubuntu Live CD are greater for RAM.  I tried figuring out how to get the Live CD to drop me to a shell instead but couldn't find anything.
Submitted by Wonnmeister (not registered) on Thu, 2009-01-22 19:57.

You rock!  This tutorial worked perfectly for me.  I even learned a few things by looking up some of the commands that I didn't know before.  Awesome job brother!

j.

Submitted by kaizoku (not registered) on Mon, 2008-11-03 10:47.
Does this work with intrepid? Also can this be done over ssh, as I do not have access to server locally.
Submitted by cosming (not registered) on Sun, 2008-10-05 11:10.

Nice job, I tested in vbox and worked "out of the box".

Thank you

Submitted by Anonymous (not registered) on Mon, 2008-09-22 22:51.
I can't get my nic to work. Ifconfig -a shows an eth0 and lsmod shows the e1000 driver. Dmesg shows no errors with the nic. /etc/network/interfaces is setup correctly but ifconfig doesn't show eth0 (only with the '-a' added). Any idea how this can be fixed?
Submitted by maxbash (registered user) on Sat, 2008-10-04 04:40.

I find Ubuntu 8.04 Live CD a little flaky with static IPs, sometimes I have to check the box to activate and deactivate the interface in the network control panel a couple times to have it come up. Once I really had to tinker with it from the console to get it to work.

Submitted by tlockney (registered user) on Mon, 2008-09-15 06:38.
I know this tutorial isn't exactly targeted at beginners, but for clarities sake you might explicitly make it apparent that the first step is to boot with the LiveCD.
Submitted by Anonymous (not registered) on Fri, 2008-09-12 19:13.

This sounds interesting. I'm looking for a minimal server install and plan to use openvz to run all my services under it. My only question is how does this compare to ubuntu jeos?

http://www.ubuntu.com/products/whatisubuntu/serveredition/jeos

Does this method provide fewer services and/or a smaller footprint?

Submitted by maxbash (registered user) on Sun, 2008-09-14 07:00.

I haven't tried Jeos, but my understanding is that it designed for making virtual machine appliances, or rather for the VM guest.

Submitted by Anonymous (not registered) on Thu, 2008-09-18 02:48.
I am not a novice, but I have never done a Linux OS install from source either. I would like to get a minimal install like this working, but I do not know what packages to install to get my NIC working.