Install Linux onto a headless server without a cdrom drive

11 01 2010

Recently I got hold of three Sun Fire 2270 – until I opened the boxes I didn’t realise that they had no cd/dvd drives, VGA cards or iLOM’s installed.  I suppose it makes sense in these space-saving, energy-conscious, cost-sensitive times, although it did mean I had some work to do to get CentOS installed.  In the end it involved network booting and redirection to the serial console.  Unusually documentation was sparse, so here my attempt…

1. Publish the Installation OS on the Source Server

As I was installing CentOS 5.4 I retrieved the iso file from the web.   The next step is to loop mount the iso, using a command something like this:

#mount -o loop centos5.iso /mnt/iso (remember to create this directory before mounting)

I choose to publish this iso via my Apache webserver so I created a symbolic link called ‘centos’ in the www root folder (you can also publish via FTP or NFS):

#cd /var/www/html
#ln -s /mnt/iso centos

This should now mean that the iso image is available via your web server (browse to http://<webserver>/centos and make sure or else the next step will fail).

If your using kickstart (and I suggest you do for convenience) copy your kickstart file to the webserver and check the url to it (eg; http://<webserver>/kickstart/ks.cfg)

2. Setup the Network Boot Environment

Now we’ve our source OS and kickstart file published, we need to tell our server to boot from the network and retrieve the installation information.  To do this I configured the netboot and dhcpd services on the same box as my webserver.  For DHCP I set up a static entry in my /etc/dhcpd.conf file (my network is – adjust as necessary):

default-lease-time                      30000;
max-lease-time                          30000;
option subnet-mask            ;
option domain-name-servers    ;
option domain-name                      "mydomain.local";
ddns-update-style                       none;</pre>
<pre>subnet netmask {
option subnet-mask;
option routers;
<pre>host x2270 {
hardware ethernet 00:aa:bb:cc:dd:ee;
filename "pxelinux.0";

This entry specifies the hardware address shown (taken from the sticker on the back of the x2270), it provisions a fixed address for it (, it sets a ‘next-server’ option ( – this is my netboot/web/dhcp server) as well as a ‘filename’ option (pxelinux.0 is the pxe bootstrap file we create on TFTP server next).

Next we need to set up our PXE boot server, this is the guy that allows the machine to be installed to boot from the network.  My preference is to use system-config-netboot tool, it’s very straight-forward to use and does pretty much everything we need.

Open system-config-netboot and choose Configure->Network Installation, then click Add to create a new installation source by setting the following fields:

Operating System Identifier – this is a unique name, in my case I just used CentOS32

Select Protocol for Installation – in this instance we’re using HTTP

Server IP Address – this is the IP of the HTTP server, in my instance

Location – this is the relative path to the installation directory ‘/centos’

After configured these setting click OK and close the ‘Configure Network Installations’ window.   At this stage we have the network installation configured we just need to get our server to use it.  To do this click ‘New’  and enter the following fields:

Hostname or IP Address – this is the ip or hostname of the machine to be installed (in my instance

Operating System – if all went well with the network installation setup this should drop down to CentOS32

Make sure everything else on this windows is unchecked or not selected.  We’ll do our serial settings and kickstart settings by hand (it appears there’s a bug that has the kickstart page looping because it inserts an additional ‘/’ character).  You can now click OK and close the application.

Our final step is to adjust the network boot environment to use our kickstart file and use the serial console (as we’ve no VGA card).  To that end we edit the file /tftpboot/linux-install/pxelinux.cfg/<hex-code>.  The hex-code filename comes from pxelinux and can be found using the command:


In my environment that’s the IP of the address of the machine to be installed.  This file lists the pxelinux boot environment for that host – we need to append ks=http://<webserver>/kickstart/ks.cfg for our machine to be installed using our kickstart and also console=ttyS0 so our machine will redirect output to the serial console.  So my /tftpboot/linux-install/0A000569 file looks like (disregard the line break after the kickstart setting):

default CentOS32
label CentOS32
kernel CentOS32/vmlinuz
append initrd=CentOS32/initrd.img  ramdisk_size=8419 console=ttyS0 method=
ip=dhcp ks=

3. Boot and Install Server

The Sun servers came with a RJ45 to Serial adapter, I connected this to a network cable and into the back of the new Sun x2270.  I stuck the other end in a USB serial adapter and then into another CentOS box.  This allowed me to use minicom to connect to the serial port (port settings are device=/dev/ttyUSB0 with 9600,8N1 and no flow control).  Next I hit the power switch and booted the new server – my servers were initially set to boot from the hard disk so I had to enter the BIOS (using Ctrl+E) and then set the boot device priority so that the network card was before the hard disk).  After setting this I rebooted and watched the installation progress nicely using the netboot server, HTTP source and kickstart file.  By the way I originally didn’t set console=ttyS0, so when anaconda kicks in it disappears from screen – this was key to these particular Sun boxes.

After the network installation has completed don’t forget to edit the boot device priority again or else the machine will netboot again.  Also once you’re done with network booting remove the next-server and filename options from DHCP – I’d also recommend switching off the netboot server so nothing else tries to boot from it (or abuse it).


Expand an existing Linux partition

13 10 2009

I’ve to do this from time to time – but never regularly enough to remember all the commands and the order in which to go about it.  This is just one way of doing it (and by the way this does not cover logical volume groups, just plain vanilla EXT2/3/4 partitions).  In this example I’ll extend the root partition / which just happens to be at /dev/sda2 on my box.

Whilst in the OS check free space on partition.

#df -h /

Now check the partition table using fdisk (this should let you know which disk device / is on, as well as the partition number it mounted at eg; /dev/sda2 or /dev/hdb5)

#fdisk -l

To change the partition size the disk needs to be unmounted, I think the easiest way of doing this is just booting to a Linux live CD/USB.  I keep a small non-GUI one handy.

Check the disk hasn’t moved ID by running fdisk again.  At this stage it is necessary to note the starting cylinder of the partition you want to expand – this is in the start column.

#fdisk -l

Now use fdisk to delete the relevant partition (yes I did say delete, don’t panic if we start the new partition on the same cylinder and resize the partition all data will be intact provided our new partition is larger than the original).

#fdisk /dev/sda

>d (ENTER)

>2 (ENTER)  …delete the second partition, ie; /dev/sda2

>n (ENTER) …create a new partition

>p (ENTER) …create a new primary partition

>2 (ENTER)  …the number of the new partition

>(ENTER) …the start cylinder of the new partition, it should default to the same cylinder id recorded earlier

><last_cylinder>(ENTER)  …the last cylinder of the new partition, the default is the end of the disk but you can specify a size, for example +40G for a 40GB partition

>w(ENTER)  …write the changes to the disk and exit

Now we’ve deleted and re-created our partition (only this time larger) all we have to do is run a file check on it and tell our partition it’s been resized.

Check and if necessary fix the new partition.

#e2fsck -f /dev/sda2

Resize the partition.

#resize2fs /dev/sda2

Hopefully if all has gone well up to this point we can restart the original OS and check disk free using the command.

#df -h /