Making a Custom USB Bootable Ubuntu 12.04 ISO (precise pangolin)

Computers,Technology — Tags: , , , — Tim Nowaczyk on May 23rd, 2012

I had to make an ubuntu image that included some preseeding and preferred for it to boot from a usb thumb-drive. I didn’t find any guides that told how to do this, so had to piece together the info from a few different guides after a bit of trial-and-error. Here’s my result. You’ll need to install xorrisofs and syslinux.

/opt/make.sh

#!/bin/bash

# clean up
rm -rf /opt/cd-image

# mount iso
mount /opt/ubuntu-12.04-server-amd64.iso /media/cdrom

# rsync iso to /opt/cd-image
mkdir /opt/cd-image
rsync -av /media/cdrom/ /opt/cd-image

# patch
patch -d /opt/cd-image -p1 < /opt/diff

# copy preseed file
cp /opt/custom.seed /opt/cd-image/preseed

# create new iso
xorrisofs -r -isohybrid-mbr /usr/lib/syslinux/isohdpfx.bin -partition_offset 16 -V "Custom Ubuntu Install CD" -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /opt/custom.iso /opt/cd-image/

# "burn" iso to usb stick
dd if=/opt/custom.iso of=/dev/sdb bs=8M

/opt/diff

diff -Naur /mnt/isolinux/txt.cfg cd-image/isolinux/txt.cfg
--- /mnt/isolinux/txt.cfg 2012-04-24 10:31:49.000000000 -0400
+++ cd-image/isolinux/txt.cfg 2012-05-16 04:44:03.351902102 -0400
@@ -1,4 +1,8 @@
-default install
+default custom
+label custom
+ menu label ^Install Custom Server
+ kernel /install/vmlinuz
+ append file=/cdrom/preseed/custom-server.seed locale=en_US keymap=us vga=788 initrd=/install/initrd.gz quiet --
label install
menu label ^Install Ubuntu Server
kernel /install/vmlinuz

/opt/custom.seed (substitute for your own preseed file)

# Suggest LVM by default.
d-i partman-auto/init_automatically_partition string some_device_lvm
d-i partman-auto/init_automatically_partition seen false
# Always install the server kernel.
d-i base-installer/kernel/override-image string linux-server
# Install the Ubuntu Server seed.
tasksel tasksel/force-tasks string server
# Only install basic language packs. Let tasksel ask about tasks.
d-i pkgsel/language-pack-patterns string
# No language support packages.
d-i pkgsel/install-language-support boolean false
# Only ask the UTC question if there are other operating systems installed.
d-i clock-setup/utc-auto boolean true
# Verbose output and no boot splash screen.
d-i debian-installer/quiet boolean false
d-i debian-installer/splash boolean false
# Install the debconf oem-config frontend (if in OEM mode).
d-i oem-config-udeb/frontend string debconf
# Wait for two seconds in grub
d-i grub-installer/timeout string 2
# Add the network and tasks oem-config steps by default.
oem-config oem-config/steps multiselect language, timezone, keyboard, user, network, tasks
d-i debian-installer/locale string en_US.UTF-8
d-i keyboard-configuration/layoutcode string us
# causes netcfg to segfault
#d-i netcfg/enable boolean false
d-i netcfg/choose_interface select eth0
d-i netcfg/dhcp_timeout string 1
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Do not configure the network at this time
d-i time/zone string US/Eastern
d-i partman-auto/disk string /dev/sdb
d-i partman-auto/method string lvm
d-i partman-auto-lvm/guided_size string 97%
d-i partman-md/confirm boolean true
# doesn't seem to make the prompt go away
#d-i partman-lvm/confirm boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
# doesn't seem to make the prompt go away
#d-i partman/installation_medium_mounted note
d-i passwd/make-user boolean false
d-i passwd/root-login boolean true
tasksel tasksel/first multiselect openssh-server
d-i pkgsel/update-policy select none
# breaks grub installation for some reason
#d-i grub-installer/bootdev string /dev/sdb
d-i finish-install/reboot_in_progress note

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2013 Semantic Pillow | powered by WordPress with Barecity
womanly