Advertisement
Monarch73

Create Ubuntu Live CD ISO from scratch

Jul 15th, 2012
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.75 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # IF YOUR COPY/ PASTING THIS SCRIPT PLEASE USE THE "RAW" SECTION
  4. # OTHERWISE THIS SCRIPT WILL FAIL
  5. #
  6. apt-get install debootstrap syslinux squashfs-tools genisoimage openssh-server
  7. if [ ! -f chroot/chroot.sh ]; then
  8.     mkdir -p chroot
  9.     mkdir -p image/casper
  10.     mkdir -p image/isolinux
  11.     mkdir -p image/install
  12.     debootstrap precise chroot
  13. fi
  14. mount --bind /dev chroot/dev
  15. cp /etc/hosts chroot/etc/hosts
  16. sudo cp /etc/resolv.conf chroot/etc/resolv.conf
  17. sudo cp /etc/apt/sources.list chroot/etc/apt/sources.list
  18. mount --bind /dev chroot/dev
  19. cat > chroot/chroot.sh  <<EOT
  20.     #!/bin/sh
  21.     mount none -t proc /proc
  22.     mount none -t sysfs /sys
  23.     mount none -t devpts /dev/pts
  24.     export HOME=/root
  25.     export LC_ALL=C
  26.     apt-get update
  27.     apt-get install --yes --force-yes dbus
  28.     dbus-uuidgen > /var/lib/dbus/machine-id
  29.     dpkg-divert --local --rename --add /sbin/initctl
  30.     ln -s /bin/true /sbin/initctl
  31.     apt-get --yes --force-yes upgrade
  32.     apt-get install --yes --force-yes casper lupin-casper
  33.     apt-get install --yes --force-yes discover laptop-detect os-prober
  34.     apt-get install --yes --force-yes linux-generic
  35.     apt-get install --yes --force-yes man-db
  36.     echo "Customize your LiveCD now. Enter exit when done."
  37.     bash -i
  38.     rm /var/lib/dbus/machine-id
  39.     rm /sbin/initctl
  40.     dpkg-divert --rename --remove /sbin/initctl
  41.     apt-get clean
  42.     rm -rf /tmp/*
  43.     rm /etc/resolv.conf
  44.     umount -lf /proc
  45.     umount -lf /sys
  46.     umount -lf /dev/pts
  47. EOT
  48. chmod 755 chroot/chroot.sh
  49. chroot chroot "/chroot.sh"
  50. umount -lf chroot/dev
  51. cp -v chroot/boot/vmlinuz-* image/casper/vmlinuz
  52. cp -v chroot/boot/initrd* image/casper/initrd.lz
  53. cp -v /usr/lib/syslinux/isolinux.bin image/isolinux/
  54. cat > image/isolinux/isolinux.cfg <<EOT
  55. DEFAULT live
  56. LABEL live
  57. kernel /casper/vmlinuz
  58. append boot=casper persistent initrd=/casper/initrd.lz noprompt
  59. EOT
  60. chroot chroot dpkg-query -W --showformat='${Package} ${Version}\n' | tee image/casper/filesystem.manifest
  61. cp -v image/casper/filesystem.manifest image/casper/filesystem.manifest-desktop
  62. REMOVE='ubiquity ubiquity-frontend-gtk ubiquity-frontend-kde casper lupin-casper live-initramfs user-setup discover1 xresprobe os-prober libdebian-installer4'
  63. for i in $REMOVE
  64. do
  65.         sudo sed -i "/${i}/d" image/casper/filesystem.manifest-desktop
  66. done
  67. [ -a image/casper/filesystem.squashfs ] && rm image/casper/filesystem.squashfs
  68. mksquashfs chroot image/casper/filesystem.squashfs -e boot
  69. touch image/ubuntu
  70. mkdir image/.disk
  71. cd image/.disk
  72. touch base_installable
  73. echo "full_cd/single" > cd_type
  74. echo "Ubuntu Remix" > info
  75. echo "http//your-release-notes-url.com" > release_notes_url
  76. cd ../..
  77. cd image
  78. mkisofs -r -V "myBooty" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../ubuntu-remix.iso .
  79. cd ..
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement