Today I spent a few hours to build Ubuntu ISO image to install ubuntu server in a headless box.

headless box](/uploads/ir800-1.jpg)

Putting it together

Download Ubuntu server distribution ISO image

Ubuntu server ISO images are available from ubuntu download site.
I used ubuntu server 15.04.

Save ISO image to a linux box, which you have sudo or root access

Because you need to mount ISO image to extract the content and modified it.. e.g. /scratch/ubuntu-15.04-server-amd64.iso

Mount ISO image and make a copy to modify

Next is to mount ISO image using loop mount so that we can access the files inside ISO image. Since ISO image mount is typically read only, we need to make a copy from ISO mounting directory. Please use either root or sudo to do the following commands.

[root@sg-centos-hv1 scratch]# make a directoty to as mount point for ISO image mount
[root@sg-centos-hv1 scratch]# mkdir /mnt/iso
[root@sg-centos-hv1 scratch]# loop mount ISO image
[root@sg-centos-hv1 scratch]# mount -o loop /scratch/ubuntu-15.04-server-amd64.iso  /mnt/iso
[root@sg-centos-hv1 scratch]# ls /mnt/iso
boot  dists  doc  EFI  install  isolinux  md5sum.txt  pics  pool  preseed  README.diskdefines  ubuntu

[root@sg-centos-hv1 scratch]# make a directory to get a copy of ISO content
[root@sg-centos-hv1 scratch]# mkdir /opt/ubuntuiso
[root@sg-centos-hv1 scratch]# cp -rT /mnt/iso/* /opt/ubuntuiso
 

Modify SYSLINUX boot config and Linux boot kernel config

Ubuntu ISO image uses [syslinux] (http://www.syslinux.org/) as bootloader. By default, it uses VGA as graphic output. We need disable graphic and make it goes to serial port/console ttyS0 by modifying files:

  • isolinux/isolinux.cfg
  • isolinux/menu.cfg
  • isolinux/txt.cfg
[root@sg-centos-hv1 scratch]# cat /opt/ubuntuiso/isolinux/isolinux.cfg
# D-I config version 2.0
serial 0 115200
include menu.cfg
prompt 0
timeout 3

[root@sg-centos-hv1 scratch]# cat /opt/ubuntuiso/isolinux/menu.cfg
menu hshift 13
menu width 49
menu margin 8

menu title Installer boot menu
include txt.cfg
menu begin advanced
        menu title Advanced options
        label mainmenu
                menu label ^Back..
                menu exit
        include adtxt.cfg
menu end
label help
        menu label ^Help
        text help
   Display help screens; type 'menu' at boot prompt to return to this menu
        endtext
        config prompt.cfg

[root@sg-centos-hv1 scratch]# cat /opt/ubuntuiso/isolinux/txt.cfg
default install
label install
  menu label ^Install Ubuntu Server
  kernel /install/vmlinuz
  append  file=/cdrom/preseed/ubuntu-server.seed text console=ttyS0,115200 initrd=/install/initrd.gz quiet --
[root@sg-centos-hv1 scratch]#

Remake ISO image using mkisofs

[root@sg-centos-hv1 scratch]# mkisofs -D -r -V "SERIALPORT_UBUNTU" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /scratch/ubuntu1504-server-amd64-serial.iso /opt/ubuntuiso

Boot ISO image in headless box to install

Burn ISO image into CD, and boot ISO image in a headless box through CDROM, connect serial/console port with speed 115200, wow!

](/uploads/ubuntu-iso-server-serial/install-screen.jpg)

Following the usual installation steps to complete installation.

After installation is complete, boots!

](/uploads/ubuntu-iso-server-serial/boot-screen.jpg)

Conclusion

Ubuntu server can be installed in a headless box, which has even less 2GB disk space.