Portable and persistent Ubuntu

Shell script para crear una distribución linux portable y persistente tipo Debian. Probado con Lubuntu 12.04 y Ubuntu 12.04 device=sdf iso_file=lubuntu-12.04-desktop-i386.iso echo "Creating a bootable USB stick." echo "ISO Image: $iso_file" echo "Device: /dev/$device" echo -n -e "\nAre you sure you want to continue? (y/n): " read confirm if [ "$confirm" != "y" ]; then echo "You have chosen to exit. Goodbye." exit 0 fi echo -e "\nVerifying that your USB drive does not have bad blocks" sudo badblocks "/dev/$device""2" echo -e "\nFormating /dev/$device""1 as FAT32" sudo mkfs.vfat -F 32 -c "/dev/$device""1" sudo dosfslabel /dev/$device1 UBUNTULIVE echo -e "\nCreating dir /media/USBDRIVE and mounting $iso_file" sudo mkdir -p /media/USBDRIVE sudo mount "/dev/$device""1" /media/USBDRIVE echo -e "\nInstalling GRUB to /media/USBDRIVE on /dev/$device" sudo grub-install --no-floppy --root-directory=/media/USBDRIVE /dev/$device echo -e "\nCreating directory /mnt/isoimage, mounting $iso_file and copying kernel and RAM disk to /media/USBDRIVE/boot/" sudo mkdir -p /mnt/isoimage sudo mount -o loop $iso_file /mnt/isoimage sudo cp /mnt/isoimage/casper/{vmlinuz,initrd.lz} /media/USBDRIVE/boot/ sudo umount /mnt/isoimage sudo rmdir /mnt/isoimage echo -e "\nCreate a persistent file system to store data and customizations" sudo dd if=/dev/zero of=/media/USBDRIVE/casper-rw bs=1M count=256 sudo mkfs.ext3 -F /media/USBDRIVE/casper-rw echo -e "\nWriting IOS image ($iso_file) to /dev/$device""2" sudo dd if=$iso_file of="/dev/$device""2" echo -e "\nCreating /media/USBDRIVE/boot/grub/grub.cfg" cat <>/tmp/grub.cfg set default=0 set timeout=5 menuentry "Distro" { search --set -f /boot/vmlinuz linux /boot/vmlinuz boot=casper persistent rw file=/preseed/distro.seed initrd /boot/initrd.lz } EOF sudo cp /tmp/grub.cfg /media/USBDRIVE/boot/grub/grub.cfg rm /tmp/grub.cfg echo -e "\nFinished!"
 * 1) !/bin/bash
 * 1) Format as FAT32
 * 1) Install GRUB on the FAT32 partition of your USB drive
 * 1) Copy the kernel and initial RAM disk from the ISO image to your GRUB directory
 * 1) Create a persistent file system to store data and customizations
 * 1) Write the ISO image to the hidden partition
 * 1) BEGIN /etc/grub.d/10_Linux ###
 * 1) END /etc/grub.d/10_Linux ###