Usb portable
From WikiEducator
Probado con Lubuntu 12.04 y Ubuntu 12.04
Fuente original: [1]
Pasos a seguir:
1. Particionar el USB (mediante parted u otras soluciones): Partición 1: todo el tamaño del disco menos 700 MBytes. Partición 2: 700 MBytes para la ISO de la distribución en cuestión.
2. Descargamos el siguiente script, modificamos los parámetros device y iso_file y se ejecuta como root.
#!/bin/bash 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 -v "/dev/$device""2" # Format as FAT32 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 # Install GRUB on the FAT32 partition of your USB drive echo -e "\nInstalling GRUB to /media/USBDRIVE on /dev/$device" sudo grub-install --no-floppy --root-directory=/media/USBDRIVE /dev/$device ## Copy the kernel and initial RAM disk from the ISO image to your GRUB directory 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 # Create a persistent file system to store data and customizations 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 # Write the ISO image to the hidden partition 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 <<EOF >>/tmp/grub.cfg set default=0 set timeout=5 ### BEGIN /etc/grub.d/10_Linux ### menuentry "Distro" { search --set -f /boot/vmlinuz linux /boot/vmlinuz boot=casper persistent rw file=/preseed/distro.seed initrd /boot/initrd.lz } ### END /etc/grub.d/10_Linux ### EOF sudo cp /tmp/grub.cfg /media/USBDRIVE/boot/grub/grub.cfg rm /tmp/grub.cfg echo -e "\nFinished!"