piwik

dimecres, 3 de setembre del 2014

Create unattended Ubuntu CD

This need came when we wanted to add a new machine to our infrastructure but it wasn't able to perform network boot, so it couldn't get the standard ubuntu installation from TFTP server. So, to get started, we need to have an Ubuntu Server edition ISO or an Ubuntu alternate edition, note that it won't work with the stardard Ubuntu Desktop edition.

Now we mount Ubuntu Alternate iso to some directory. Copy it with rsync to somewhere where you can edit it, and give write permisions to some directories.

mount -o loop /home/josep/ubuntu-alternate-12.04.iso /mnt/ubuntu
rsync -av /mnt/ubuntu/ /tmp/ubuntu
chmod -R u+w /tmp/ubuntu/isolinux
chmod -R u+w /tmp/ubuntu/preseed 

Modify the files /isolinux/txt.cfg to point to the new preseed that we have


default install
label install
  menu label ^Install Ubuntu
  kernel /install/vmlinuz
  append  file=/cdrom/preseed/ubuntu-our-preseed.seed locale=en_GB.UTF-8 console-setup/ask_detect=false keyboard-configuration/layoutcode=es vga=788 initrd=/install/initrd.gz quiet --
label check
  menu label ^Check disc for defects
  kernel /install/vmlinuz
  append   MENU=/bin/cdrom-checker-menu vga=788 initrd=/install/initrd.gz quiet --
label memtest
  menu label Test ^memory
  kernel /install/mt86plus
label hd
  menu label ^Boot from first hard disk
  localboot 0x80


And now we add our preseed to /preseed/ubuntu-our-preseed.seed



# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string en_GB.UTF-8
d-i debian-installer/country string ES
d-i localechooser/supported-locales en_US.UTF-8, en_GB.UTF-8, es_ES.UTF-8
# The values can also be preseeded individually for greater flexibility.
#d-i debian-installer/language string en
#d-i debian-installer/country string NL
#d-i debian-installer/locale string en_GB.UTF-8
# Optionally specify additional locales to be generated.
#d-i localechooser/supported-locales en_US.UTF-8, nl_NL.UTF-8
#
# Keyboard ======================
#
#d-i keyboard-configuration/modelcode skip
# New config
# Disable automatic (interactive) keymap detection.
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string es
#
#
# Network installation
#
# Any hostname and domain names assigned from dhcp take precedence over
# values set here. However, setting the values still prevents the questions
# from being shown, even if values come from dhcp.
d-i netcfg/choose_interface select auto
d-i netcfg/get_nameservers string 192.168.60.9
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string ic3.local
# If non-free firmware is needed for the network or other hardware, you can
# configure the installer to always try to load it, without prompting. Or
# change to false to disable asking.
d-i hw-detect/load_firmware boolean true
#
# Time ==========================
#
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true
# You may set this to any valid setting for $TZ; see the contents of
# /usr/share/zoneinfo/ for valid values.
d-i time/zone string Europe/Madrid
# Controls whether to use NTP to set the clock during the install
d-i clock-setup/ntp boolean true
# NTP server to use. The default is almost always fine here.
d-i clock-setup/ntp-server string 1.es.pool.ntp.org
#
# MIRROR ==========================
#
# If you select ftp, the mirror/country string does not need to be set.
#d-i mirror/protocol string ftp
d-i mirror/country string Spain
d-i mirror/http/hostname string es.archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
.
.
.
. 


At this point we just need to recreate de ISO image:



mkisofs -r -V "auto-ubuntu-minimalvm" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /home/josep/ubuntu-our-refurbished-image.iso /tmp/ubuntu



Cap comentari:

Publica un comentari a l'entrada