Ubuntu Live USB

jul. 12, 2011·
Julio Batista Silva
Julio Batista Silva
· 4 min de lectura

Compré un case Vantec NexStar CX para usar un HDD de 2.5" como disco externo.

Como el HDD tiene bastante espacio y siempre necesito un Live CD de Linux para arreglar algo, decidí instalar Ubuntu al principio de ese HDD.

Este proceso es bastante sencillo en Ubuntu, que trae un “Disk Creator”, pero en Arch Linux tendría que descargar algo similar o hacerlo manualmente. Aquí muestro cómo hacerlo a mano.

  1. Descarga la imagen .iso en http://www.ubuntu.com/download

  2. Instala syslinux y ms-sys

    julio@julio-acer ~> sudo pacman -S syslinux mtools
    julio@julio-acer ~> yaourt ms-sys
    
  3. Conecta el HDD externo a un puerto USB y localiza el dispositivo con fdisk -l (/dev/sdc aquí)

    julio@julio-acer ~  $  sudo fdisk -l
      Disk /dev/sdc: 500.1 GB, 500107862016 bytes
      171 heads, 40 sectors/track, 142803 cylinders, total 976773168 sectors
      Units = sectors of 1 * 512 = 512 bytes
      Sector size (logical/physical): 512 bytes / 512 bytes
      I/O size (minimum/optimal): 512 bytes / 512 bytes
      Disk identifier: 0x000de160
    
         Device Boot      Start         End      Blocks   Id  System
      /dev/sdc1            2048     2099199     1048576    b  W95 FAT32
    
  4. Asegúrate de que el disco no tenga nada importante. Fórmatalo, crea una partición de al menos 1 GB y márcala como arrancable (bootable).

    julio@julio-acer ~> sudo fdisk /dev/sdc
    Command (m for help): d
    Selected partition 1
    
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4, default 1): 1
    First sector (2048-976773167, default 2048): 2048
    Last sector, +sectors or +size{K,M,G} (2048-976773167, default 976773167): +1G
    
    Command (m for help): t
    Selected partition 1
    Hex code (type L to list codes): c
    Changed system type of partition 1 to c (W95 FAT32 (LBA))
    
    Command (m for help): a
    Partition number (1-4): 1
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    
    WARNING: If you have created or modified any DOS 6.x
    partitions, please see the fdisk manual page for additional
    information.
    Syncing disks.
    
  5. Usa mkfs para crear un sistema de archivos FAT32:

    julio@julio-acer ~  $  sudo mkfs.vfat -F 32 /dev/sdc1
    
  6. Reescribe el MBR

    julio@julio-acer ~  $  sudo dd if=/dev/zero of=/dev/sdc bs=446 count=1
    1+0 records in
    1+0 records out
    446 bytes (446 B) copied, 0.00234799 s, 190 kB/s
    
    julio@julio-acer ~  $  sudo ms-sys -s /dev/sdc
    Public domain syslinux master boot record successfully written to /dev/sdc
    
  7. Monta el HDD externo

    julio@julio-acer ~  $  sudo mount /dev/sdc1 /media/pendrive/
    
  8. Instala GRUB en la primera partición

    julio@julio-acer ~  $  sudo grub-install - -no-floppy - -root-directory=/media/pendrive/ /dev/sdc
    
  9. Monta la imagen .iso

    julio@julio-acer ~  $  sudo mount -o loop ubuntu-11.04-desktop-i386.iso /media/iso/
    mount: warning: /media/iso/ seems to be mounted read-only.
    
  10. Copia el kernel y el initrd del .iso a la carpeta /boot

    julio@julio-acer ~> sudo cp /media/iso/casper/{vmlinuz,initrd.lz} /media/pendrive/boot/
    
  11. Reserva 512 MB para el archivo casper-rw, que almacenará todos los archivos y modificaciones realizadas en el sistema.

    julio@julio-acer ~>  sudo dd if=/dev/zero of=/media/pendrive/casper-rw bs=1M count=512
    512+0 records in
    512+0 records out
    536870912 bytes (537 MB) copied, 1.92945 s, 278 MB/s
    
    julio@julio-acer ~>  sudo mkfs.ext3 -F /media/pendrive/casper-rw
    mke2fs 1.41.14 (22-Dec-2010)
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    32768 inodes, 131072 blocks
    6553 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=134217728
    4 block groups
    32768 blocks per group, 32768 fragments per group
    8192 inodes per group
    Superblock backups stored on blocks:
            32768, 98304
    
    Writing inode tables: done
    Creating journal (4096 blocks): done
    Writing superblocks and filesystem accounting information: done
    
    This filesystem will be automatically checked every 38 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
    
  12. Crea una segunda partición para almacenar el .iso

    julio@julio-acer ~> sudo fdisk /dev/sdc
        Command (m for help): n
        Command action
           e   extended
           p   primary partition (1-4)
        p
        Partition number (1-4, default 2): 2
        First sector (2099200-976773167, default 2099200):
        Using default value 2099200
        Last sector, +sectors or +size{K,M,G} (2099200-976773167, default 976773167): +730M
    
        Command (m for help): w
        The partition table has been altered!
    
        Calling ioctl() to re-read partition table.
        Syncing disks.
    
  13. Copia los archivos del .iso a la segunda partición

    julio@julio-acer ~> sudo dd if=ubuntu-11.04-desktop-i386.iso of=/dev/sdc2
    1403484+0 records in
    1403484+0 records out
    718583808 bytes (719 MB) copied, 116.572 s, 6.2 MB/s
    
  14. Edita el menú de Grub

    julio@julio-acer .../pendrive/boot/grub> cat menu.lst
    default         0
    timeout         10
    
    title           Ubuntu (Live)
    root            (hd0,0)
    kernel          /boot/vmlinuz boot=casper file=/preseed/ubuntu.seed persistent
    initrd          /boot/initrd.lz
    
  15. Desmonta el disco, configura la BIOS para arrancar desde USB y prueba tu live USB.


Enlaces

Julio Batista Silva
Autores
Senior Cloud Developer
comments powered by Disqus