-
-
Save MVoz/80a0d69a9ba3526ad49dec74d7072771 to your computer and use it in GitHub Desktop.
Customize ubuntu live image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first, get the iso from http://releases.ubuntu.com/ | |
# make working dir hierarchy in /tmp (you'll need enough ram for this) | |
sudo mkdir -p /tmp/custom/{_squash,_work,iso,newiso,newlive,project} | |
sudo mount -o loop ~/Downloads/ubuntu-15.10-desktop-amd64.iso /tmp/custom/iso | |
sudo mount -t squashfs /tmp/custom/iso/casper/filesystem.squashfs /tmp/custom/_squash | |
sudo mount -t overlay overlay -onoatime,lowerdir=/tmp/custom/_squash,upperdir=/tmp/custom/project,workdir=/tmp/custom/_work /tmp/custom/newlive | |
# customize the live fs with systemd-nspawn (a better chroot) | |
sudo systemd-nspawn --bind-ro=/etc/resolv.conf:/run/resolvconf/resolv.conf --setenv=RUNLEVEL=1 -D /tmp/custom/newlive | |
apt-get update | |
apt-get upgrade | |
apt-get install --no-install-recommends ... | |
... | |
apt-get purge ... | |
apt-get autoremove --purge | |
apt-get clean | |
<ctrl-d> | |
sudo rm /tmp/custom/newlive/root/.bash_history | |
sudo rm /tmp/custom/newlive/var/lib/dbus/machine-id | |
# prepare new image content | |
sudo rsync -av --exclude casper/filesystem.squashfs /tmp/custom/iso/ /tmp/custom/newiso/ | |
sudo mksquashfs /tmp/custom/newlive /tmp/custom/newiso/casper/filesystem.squashfs -noappend -b 1048576 -comp xz -Xdict-size 100% | |
printf $(sudo du -s --block-size=1 /tmp/custom/newlive | cut -f1) | sudo tee /tmp/custom/newiso/casper/filesystem.size | |
# remove leftovers | |
sudo umount /tmp/custom/_fs /tmp/custom/newlive /tmp/custom/iso | |
sudo rm -rf /tmp/custom/newiso | |
# /tmp/custom/project now has the delta of your changes, you could keep it for later reuse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VOLUME_NAME="Ubuntu KIKA" | |
(cd /tmp/custom/newiso && find . -type f -print0 | xargs -0 md5sum | grep -v "\./md5sum.txt" ) | sudo tee /tmp/custom/newiso/md5sum.txt | |
sudo genisoimage -r -cache-inodes -J -l \ | |
-b syslinux/isolinux.bin -c syslinux/boot.cat -no-emul-boot \ | |
-boot-load-size 4 -boot-info-table \ | |
-V "$VOLUME_NAME" \ | |
-o /tmp/custom-image.iso /tmp/custom/newiso/ | |
sudo isohybrid /tmp/custom-image.iso | |
# optionaly update syslinux/isolinux.bin and syslinux/*.c32 with newer from syslinux, might make it more compatible with isohybrid below | |
sudo dd if=/tmp/custom-image.iso of=/dev/sdb bs=4M status=progress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make persistent usb | |
sudo sfdisk /dev/sdb <<EOF | |
/dev/sdb1 : start= 2048, size= 6291456, type=b, bootable | |
/dev/sdb2 : start= 6293504, size= 8857664, type=83 | |
EOF | |
sudo mkfs.vfat -n kika-101 /dev/sdb1 | |
sudo mkfs.ext4 -L casper-rw -O ^has_journal /dev/sdb2 | |
sudo mount /dev/sdb1 /mnt | |
sudo rsync -av /tmp/custom/newiso/ /mnt | |
sudo syslinux -d syslinux /dev/sdb1 | |
(cd /tmp/custom/newiso && find . -type f -print0 | xargs -0 md5sum | grep -v "\./md5sum.txt" ) | sudo tee /tmp/custom/newiso/md5sum.txt | |
sudo umount /mnt | |
sudo dd if=/usr/lib/syslinux/bios/mbr.bin of=/dev/sdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias nspawn='sudo systemd-nspawn --bind-ro=/etc/resolv.conf:/run/resolvconf/resolv.conf \ | |
-D /tmp/custom/newlive \ | |
--setenv=RUNLEVEL=1 \ | |
--setenv=http_proxy=http://192.168.88.49:3142' | |
DISTRO=`nspawn lsb_release -sc` | |
nspawn add-apt-repository "deb http://archive.ubuntu.com/ubuntu $DISTRO universe multiverse" | |
nspawn add-apt-repository "deb http://security.ubuntu.com/ubuntu $DISTRO-security universe multiverse" | |
nspawn add-apt-repository "deb http://archive.ubuntu.com/ubuntu $DISTRO-updates universe multiverse" | |
nspawn apt-get update | |
nspawn apt-get install --no-install-recommends \ | |
git vim-nox python-pip python3-pip ipython3-notebook ipython-notebook haskell-platform clisp php5-cli firmware-b43-installer | |
nspawn apt-get remove --purge unity-webapps-common thunderbird 'libreoffice*' | |
nspawn apt-get autoremove --purge | |
nspawn apt-get clean | |
ROOT=/tmp/custom/newlive | |
sudo rm $ROOT/etc/skel/examples.desktop | |
sudo sed -i 's/us/us,mk/' $ROOT/etc/default/keyboard | |
sudo cp kika-wallpaper.png $ROOT/usr/share/backgrounds/warty-final-ubuntu.png | |
sudo cp KIKA $ROOT/etc/NetworkManager/system-connections/ | |
# lets rename these so it's the same for syslinux and isolinux (usb & cd) | |
sudo mv /tmp/custom/newiso/isolinux /tmp/custom/newiso/syslinux | |
sudo mv /tmp/custom/newiso/syslinux/isolinux.cfg /tmp/custom/newiso/syslinux/syslinux.cfg | |
sudo cp kika-logo-splash.png /tmp/custom/newiso/syslinux/splash.png | |
sudo sed -i '/^ui / d' /tmp/custom/newiso/syslinux/syslinux.cfg # disable gfxboot | |
sudo sed -i 's/quiet splash/quiet splash persistent/' /tmp/custom/newiso/syslinux/txt.cfg /tmp/custom/newiso/boot/grub/grub.cfg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qemu-system-x86_64 -enable-kvm -m 2048 -drive file=/tmp/custom-image.iso,media=cdrom,format=raw | |
qemu-system-x86_64 -enable-kvm -m 2048 -bios OVMF-pure-efi.fd -drive file=/tmp/custom-image.iso,media=disk,format=raw |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment