USB GRUB2 ISO installer

Preparation

  1. A bootable USB drive
  2. A Linux system or a Linux live CD
  3. Linux ISO image (netinst or businesscard)

Disk Partition and Formatting

$ sudo fdisk /dev/sdx
Command (m for help): d Selected partition 1 Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-30871551, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-30871551, default 30871551): Using default value 30871551 Command (m for help): a Partition number (1-4): 1 Command (m for help): p Disk /dev/sdd: 15.8 GB, 15806234624 bytes 255 heads, 63 sectors/track, 1921 cylinders, total 30871552 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: 0x3a42665b Device Boot Start End Blocks Id System /dev/sdd1 * 2048 30871551 15434752 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.

Install GRUB2 to USB drive

Replacing /dev/sdx with your actual USB device

$ sudo mkfs.ext2 /dev/sdx1 $ sudo mkdir /mnt/USB $ sudo mount /dev/sdx1 /mnt/USB $ sudo grub-install --force --no-floppy --root-directory=/mnt/USB /dev/sdx
Installation finished. No error reported.

Download ISO image

Download Debian ISO image from 台中縣教育局 or official

$ cd /mnt/USB/ $ sudo mkdir img
Put the iso image in /mnt/USB/img

Configure GRUB2

Download initrd.gz and vmlinuz i386 amd64

$ cd /mnt/USB/boot $ sudo mkdir i386 amd64 $ cd amd64; ##or cd i386;
Put the initrd.gz and vmlinuz in /mnt/USB/boot/amd64 or /mnt/USB/boot/i386.
$ sudo emacs /mnt/USB/boot/grub/grub.cfg
set timeout=10 set default=0 set isodir='/img' menuentry "Install Kubuntu 12.10 amd64" { set isofile="/img/kubuntu-12.10-desktop-amd64.iso" loopback loop $isofile linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile splash -- initrd (loop)/casper/initrd.lz } menuentry "Install Debian amd64 netinst" { loopback loop $isodir/debian-6.0.6-amd64-netinst.iso linux /boot/amd64/vmlinuz desktop=lxde -- initrd /boot/amd64/initrd.gz } menuentry "Install Debian i386 netinst" { loopback loop $isodir/debian-6.0.6-i386-netinst.iso linux /boot/i386/vmlinuz desktop=lxde -- initrd /boot/i386/initrd.gz } menuentry "Grub2 HDD" { set root=(hd1) chainloader +1 } menuentry "Restart" { reboot } menuentry "Shut Down" { halt }
$ cd ; sudo umount /mnt/USB

References

  1. Install GRUB2 on USB from Ubuntu Linux
  2. 使用 USB stick 來安裝 Debian GNU/Linux 5.0 (Lenny) rc1
  3. MultiBootUSB
  4. Automatic installation of Debian Squeeze from a USB flash drive