From 869320652ca0cbd0473d54b368d4722cb0c8da4e Mon Sep 17 00:00:00 2001 From: Marco Ochse Date: Sat, 9 Jul 2016 01:23:12 +0200 Subject: [PATCH] Reduce Installer Size to <50MB T-Pot ISO Creator will now create images based on the Ubuntu Network Installer (mini.iso). This results in a greatly reduced size for the T-Pot Installer with now being just about 49MB. T-Pot was only using the base install packages of the 700MB Ubuntu Server ISO and still had to download the latest packages anyway. The advantages are a) reduced download size for the Ubuntu Network Installer instead of the full image, b) the latest packages are already installed during the base installation and c) the resulting T-Pot ISO can be distributed easier. --- installer/install.sh | 20 ++++++- installer/rc.local.install | 2 - isolinux/txt.cfg | 8 ++- kickstart/ks.cfg | 41 ------------- makeiso.sh | 60 +++++++++++-------- preseed/tpot.seed | 119 ++++++++++++++++++++++++++++++------- 6 files changed, 158 insertions(+), 92 deletions(-) delete mode 100644 kickstart/ks.cfg diff --git a/installer/install.sh b/installer/install.sh index 07b5c5bc..e101eb97 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -150,9 +150,27 @@ tee -a /etc/ssh/ssh_config <&1 1>&2 2>&3 3>&-) sed -i 's#^myFLAVOR=.*#myFLAVOR="'$myFLAVOR'"#' $myINSTALLERPATH @@ -204,7 +205,7 @@ EOF fi done -# Let's get Ubuntu 14.04.4 as .iso +# Let's download Ubuntu Minimal ISO if [ ! -f $myUBUNTUISO ] then wget $myUBUNTULINK --progress=dot 2>&1 | awk '{print $7+0} fflush()' | dialog --backtitle "$myBACKTITLE" --title "[ Downloading Ubuntu ... ]" --gauge "" 5 70; @@ -215,31 +216,40 @@ fi # Let's loop mount it and copy all contents mkdir -p $myTMP $myTPOTDIR -losetup /dev/loop0 $myUBUNTUISO -mount /dev/loop0 $myTMP -cp -rT $myTMP $myTPOTDIR -chmod 777 -R $myTPOTDIR +mount -o loop $myUBUNTUISO $myTMP +rsync -a $myTMP/ $myTPOTDIR umount $myTMP -losetup -d /dev/loop0 + +# Let's modify initrd +gunzip $myTPOTDIR/initrd.gz +mkdir $myTPOTDIR/tmp +cd $myTPOTDIR/tmp +cpio --extract --make-directories --no-absolute-filenames < ../initrd +cd .. +rm initrd +cd .. # Let's add the files for the automated install -mkdir -p $myTPOTDIR/tpot -cp installer/* -R $myTPOTDIR/tpot/ -cp isolinux/* $myTPOTDIR/isolinux/ -cp kickstart/* $myTPOTDIR/tpot/ -cp preseed/* $myTPOTDIR/tpot/ -if [ -d images ]; - then - cp -R images $myTPOTDIR/tpot/images/ -fi -chmod 777 -R $myTPOTDIR +mkdir -p $myTPOTDIR/tmp/opt/tpot +cp installer/* -R $myTPOTDIR/tmp/opt/tpot/ +cp isolinux/* $myTPOTDIR/ +cp preseed/tpot.seed $myTPOTDIR/tmp/preseed.cfg + +# Let's create the new initrd +cd $myTPOTDIR/tmp +find . | cpio -H newc --create > ../initrd +cd .. +gzip initrd +rm -rf tmp +cd .. # Let's create the new .iso cd $myTPOTDIR -mkisofs -gui -D -r -V "T-Pot" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../$myTPOTISO ../$myTPOTDIR 2>&1 | awk '{print $1+0} fflush()' | cut -f1 -d"." | dialog --backtitle "$myBACKTITLE" --title "[ Building T-Pot .iso ... ]" --gauge "" 5 70 0 +mkisofs -gui -D -r -V "T-Pot" -cache-inodes -J -l -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../$myTPOTISO ../$myTPOTDIR 2>&1 | awk '{print $1+0} fflush()' | cut -f1 -d"." | dialog --backtitle "$myBACKTITLE" --title "[ Building T-Pot .iso ... ]" --gauge "" 5 70 0 echo 100 | dialog --backtitle "$myBACKTITLE" --title "[ Building T-Pot .iso ... Done! ]" --gauge "" 5 70 cd .. isohybrid $myTPOTISO +sha256sum $myTPOTISO > tpot.sha256 # Let's write the image while true; diff --git a/preseed/tpot.seed b/preseed/tpot.seed index 27e46448..fa517cde 100755 --- a/preseed/tpot.seed +++ b/preseed/tpot.seed @@ -1,46 +1,125 @@ -# T-Pot preseed file by mo -# Setting locale -#d-i debian-installer/language string en +############################################## +### T-Pot Preseed Configuration File by mo ### +############################################## + +#################### +### Locale Selection +#################### #d-i debian-installer/country string DE -#d-i debian-installer/locale string en_US.UTF-8 +d-i debian-installer/language string en +d-i debian-installer/locale string en_US.UTF-8 +d-i localechooser/preferred-locale string en_US.UTF-8 -# Keyboard selection -#d-i console-setup/ask_detect boolean false +###################### +### Keyboard Selection +###################### +#d-i console-setup/ask_detect boolean true #d-i keyboard-configuration/layoutcode string de +d-i console-setup/detected note -#Unmount active partitions -d-i preseed/early_command string umount /media || : +############################# +### Unmount Active Partitions +############################# +#d-i preseed/early_command string umount /media || : -# Network Configuration +######################### +### Network Configuration +######################### #d-i netcfg/choose_interface select auto #d-i netcfg/dhcp_timeout string 60 d-i netcfg/get_hostname string t-pot -# Source & Proxy +############### +### Disk Layout +############### +d-i partman/early_command string \ +debconf-set partman-auto/disk $(parted_devices | sort -k2nr | head -1 | cut -f1) + +d-i partman-auto/method string regular +d-i partman-lvm/device_remove_lvm boolean true +d-i partman-md/device_remove_md boolean true +d-i partman-auto/choose_recipe select atomic +d-i partman-auto/expert_recipe string \ + root :: \ + 8192 8888 8192 linux-swap \ + $primary{ } \ + method{ swap } format{ } \ + . \ + 40960 44444 -1 ext4 \ + $primary{ } $bootable{ } \ + method{ format } format{ } \ + use_filesystem{ } filesystem{ ext4 } \ + mountpoint{ / } \ + . +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 + +###################### +### User Configuration +###################### +d-i passwd/root-login boolean false +d-i passwd/make-user boolean true +d-i passwd/user-fullname string tsec +d-i passwd/username string tsec +d-i passwd/user-password-crypted password $1$jAw1TW8v$a2WFamxQJfpPYZmn4qJT71 +d-i user-setup/encrypt-home boolean false + +######################################## +### Country Mirror & Proxy Configuration +######################################## d-i mirror/country string manual d-i mirror/http/hostname string archive.ubuntu.com d-i mirror/http/directory string /ubuntu d-i mirror/http/proxy string -# Time -#d-i clock-setup/utc boolean true +########################### +### Skip Grub Configuration +########################### +#d-i grub-installer/confirm boolean true +#d-i grub-installer/only_debian boolean true +#d-i grub-installer/with_other_os boolean true +d-i grub-installer/skip boolean true +d-i lilo-installer/skip boolean true + +###################### +### Time Configuration +###################### #d-i time/zone string Europe/Berlin +d-i clock-setup/utc boolean true d-i time/zone string UTC d-i clock-setup/ntp boolean true +d-i clock-setup/ntp-server string ntp.ubuntu.com -# Package Groups +################## +### Package Groups +################## tasksel tasksel/first multiselect ubuntu-server -# Packages -d-i pkgsel/include string apt-transport-https ca-certificates curl dialog dstat ethtool genisoimage git htop iw libpam-google-authenticator lm-sensors ntp openssh-server syslinux pv python-pip vim wireless-tools wpasupplicant +######################## +### Package Installation +######################## +d-i pkgsel/include string aufs-tools apparmor apt-transport-https bash-completion ca-certificates cgroupfs-mount curl dialog dstat ethtool genisoimage git htop iptables iw libpam-google-authenticator libltdl7 lm-sensors ntp openssh-server syslinux pv python-pip vim wireless-tools wpasupplicant -# Update Policy +################# +### Update Policy +################# d-i pkgsel/update-policy select unattended-upgrades -# Post install +######################################### +### Post install (Grub & T-Pot Installer) +######################################### d-i preseed/late_command string \ -cp /cdrom/tpot/rc.local.install /target/etc/rc.local; \ -cp -r /cdrom/tpot/ /target/root/ +in-target apt-get -y install grub-pc; \ +in-target grub-install --force $(debconf-get partman-auto/disk); \ +in-target update-grub; \ +cp /opt/tpot/rc.local.install /target/etc/rc.local; \ +cp -r /opt/tpot/ /target/root/ -# Reboot +########## +### Reboot +########## +d-i nobootloader/confirmation_common note d-i finish-install/reboot_in_progress note +d-i cdrom-detect/eject boolean true