Ubuntu Live‑USB

Juli 12, 2011·
Julio Batista Silva
Julio Batista Silva
· 4 Min Lesezeit

Ich habe mir ein Vantec NexStar CX‑Gehäuse gekauft, um eine 2,5"‑HDD als externe Festplatte zu nutzen.

Da die HDD viel Platz bietet und ich oft ein Linux Live‑System brauche, um etwas zu reparieren, installierte ich Ubuntu an den Anfang dieser HDD.

Unter Ubuntu ist das mit dem „Disk Creator“ recht einfach. In Arch Linux müsste ich ein ähnliches Tool installieren oder es manuell machen – hier der manuelle Weg.

  1. .iso‑Image von http://www.ubuntu.com/download herunterladen

  2. syslinux und ms-sys installieren

    julio@julio-acer ~> sudo pacman -S syslinux mtools
    julio@julio-acer ~> yaourt ms-sys
    
  3. Externe HDD per USB anschließen und das Gerät mit fdisk -l prüfen (hier /dev/sdc)

    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. Sicherstellen, dass die HDD nichts Wichtiges enthält. Formatieren, eine Partition von mind. 1 GB anlegen und als bootfähig markieren.

    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. FAT32‑Dateisystem anlegen:

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

    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. Externe HDD einhängen

    julio@julio-acer ~  $  sudo mount /dev/sdc1 /media/pendrive/
    
  8. GRUB auf die erste Partition installieren

    julio@julio-acer ~  $  sudo grub-install - -no-floppy - -root-directory=/media/pendrive/ /dev/sdc
    
  9. .iso einhängen

    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. Kernel und initrd aus dem .iso nach /boot kopieren

    julio@julio-acer ~> sudo cp /media/iso/casper/{vmlinuz,initrd.lz} /media/pendrive/boot/
    
  11. 512 MB für die Datei casper-rw reservieren, die alle Änderungen am System speichert.

    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. Zweite Partition erstellen, um die .iso zu speichern

    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. Dateien aus der .iso auf die zweite Partition kopieren

    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. Grub‑Menü bearbeiten

    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. Platte aushängen, BIOS auf USB‑Boot stellen und dein Live‑USB testen.


Julio Batista Silva
Autoren
Senior Cloud-Entwickler
comments powered by Disqus