doc/create_live_usb.md
2014-06-02 12:01:06 +02:00

4.4 KiB

Create a YunoHost Live ISO

Tested on Debian Wheezy (should work on Ubuntu as well).
Original tutorial here: http://willhaley.com/blog/create-a-custom-debian-live-environment/

Warning: I have highlighted all the places you should be in the chroot environment.

  1. Install applications we need to build the environment.
sudo apt-get install debootstrap syslinux squashfs-tools genisoimage memtest86+ rsync
  1. Setup the base Debian environment. I am using wheezy for my distribution and i386 for the architecture. Please do change your mirror if you are not in the Netherlands or know of a mirror close to you.
mkdir live_boot && cd live_boot
sudo debootstrap --arch=i386 --variant=minbase wheezy chroot http://ftp.nl.debian.org/debian/
  1. A couple of important steps before we chroot.
sudo mount -o bind /dev chroot/dev && sudo cp /etc/resolv.conf chroot/etc/resolv.conf
  1. Chroot to our Debian environment.
sudo chroot chroot
  1. chroot Set a few required variables and system settings in our Debian environment.
mount none -t proc /proc && 
mount none -t sysfs /sys && 
mount none -t devpts /dev/pts && 
export HOME=/root && 
export LC_ALL=C && 
apt-get install dialog dbus --yes && 
dbus-uuidgen > /var/lib/dbus/machine-id && 
apt-get update
  1. chroot Set the root password to yunohost
passwd root
  1. chroot Install the required packages, replace the kernel version if needed.
apt-get install --no-install-recommends \
linux-image-3.2.0-4-486 live-boot \
net-tools wireless-tools wpagui tcpdump wget openssh-client \
xserver-xorg-core xserver-xorg xinit xterm \
pciutils usbutils gparted ntfsprogs hfsprogs rsync dosfstools syslinux partclone nano pv \
chromium-browser libnss3-tools openbox git ca-certificates openssl
  1. chroot NetworkManager can break your network configuration in the chroot environment. You can install it afterward, and CTRL-C during the installation
apt-get --no-install-recommends install network-manager
  1. chroot Install YunoHost
git clone https://github.com/YunoHost/install_script /tmp/yunohost_install
cd /tmp/yunohost_install && ./autoinstall_yunohostv2
  1. chroot Set parameters in order to launch everything right
echo "127.0.0.1 yunohost.org" >> /etc/hosts
echo "chromium --user-data-dir=/root/.config/chromium --app=https://yunohost.org/yunohost/admin/" >> /etc/xdg/openbox/autostart
certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n YunoHostCA  -i /etc/yunohost/certs/yunohost.org/ca.pem
certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n YunoHostCrt -i /etc/yunohost/certs/yunohost.org/crt.pem
  1. chroot Edit /etc/inittab to login automatically
nano /etc/inittab
# Replace the following line
1:2345:respawn:/sbin/getty 38400 tty1
# by this one
1:2345:respawn:/bin/login -f root tty1 </dev/tty1 >/dev/tty1 2>&1
  1. chroot Clean up our Debian environment before leaving.
rm -f /var/lib/dbus/machine-id && 
apt-get clean && 
rm -rf /tmp/* && 
rm /etc/resolv.conf && 
umount -lf /proc && 
umount -lf /sys && 
umount -lf /dev/pts
# Then exit
exit
  1. Unmount dev from the chroot
sudo umount -lf chroot/dev
  1. Make directories that will be copied to our bootable medium.
mkdir -p image/{live,isolinux}
  1. Compress the chroot environment into a Squash filesystem.
sudo mksquashfs chroot image/live/filesystem.squashfs -e boot
  1. Prepare our USB/CD bootloader.
cp chroot/boot/vmlinuz-3.2.0-4-486 image/live/vmlinuz1 && 
cp chroot/boot/initrd.img-3.2.0-4-486 image/live/initrd1
  1. Create image/isolinux/isolinux.cfg menu for the bootloader.
UI menu.c32

prompt 0
menu title YunoHost Live

timeout 300

label YunoHost Live
menu label ^YunoHost Live
menu default
kernel /live/vmlinuz1
append initrd=/live/initrd1 boot=live

Build the .iso

Copy files necessary for the ISO to boot and then create the ISO

cp /usr/lib/syslinux/isolinux.bin image/isolinux/ && 
cp /usr/lib/syslinux/menu.c32 image/isolinux/
cd image && genisoimage -rational-rock -volid "YunoHost Live" -cache-inodes -joliet -full-iso9660-filenames -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -output ../yunohost-live.iso . && cd ..

Great success ! Now you can burn the .iso or use Unetbootin to copy it on a USB key.