Thursday 19 January 2012

Create Bootable MINT LMDE USB stick - on Linux

The problem:

I want to install from LMDE (linuxmint-201109-xfce-dvd-64bit.iso) onto a machine with no CD drive.
The iso is in iso9660 format, booted by isolinux.

First attempt, with usb stick appearing as /dev/sdX

$ SRC=linuxmint-201109-xfce-dvd-64bit.iso
$ dd if=$SRC of=/dev/sdX bs=4M

Transferred to target machine, it won't boot. Claims not to be a bootable disk.

The solution: Install syslinux on the stick.

See SysLinux HowTo but it didn't work for me when I followed the instructions in the order given.

This worked:

You are going to need a USB stick of 2GB or more.
Plug it in. Check dmesg to see which device is allocated to it.
Make sure you use the correct device name. I've indicated mine as /dev/sdX. Yours might be /dev/sdb, or something else.

Download the iso file. I refer to its location as $SRC below.
e.g SRC=/tmp/linuxmint-201109-xfce-dvd-64bit.iso

I ran all of the following as root. BE CAREFUL

Mount the iso e.g.

$ ISO=/tmp/iso
$ mkdir $ISO
$ mount -o loop $SRC $ISO
$ ls $ISO
casper/ isolinux/

Download the syslinux tarball and unpack it.
I got syslinux-4.05/
cd into there

format the stick with 1 vfat partition and make it bootable.
I used fdisk. Use whichever partition program you like
I ended up with:

$ fdisk -l /dev/sdX

Disk /dev/sdX : 4005 MB 4005527552 bytes
124 heads, 62 sectors/track, 1017 cylinders
Units = cylinders of 7688 * 512 = 3936256 bytes
Disk identifier: 0x000529cf

Device Boot Start End Blocks Id System
/dev/sdX1 * 1 1017 3909317 b W95 FAT32

copy the syslinux boot sector to it
(the second line sets the bootable flag again)

$ dd conv=notrunc bs=440 count=1 if=mbr/mbr.bin of=/dev/sdX
$ parted /dev/sdX set 1 boot on

format the usb stick (the label MINTLMDE is optional)

$ mkfs.vfat -v -n MINTLMDE /dev/sdX1

initialise the active partition on the stick for syslinux

$ ./linux/syslinux -i /dev/sdX1

mount the usb stick and copy the iso contents to it.

$ USB=/tmp/usb
$ mkdir $USB
$ mount /dev/sdX1 $USB
$ cp -a $ISO/* $USB

Copy essential syslinux files

$ cp -a com32/menu/vesamenu.c32 $USB
$ cp -a core/ldlinux.sys $USB

Copy the isolinux configuration, renaming it for syslinux

$ cp -a $USB/isolinux/isolinux.cfg $USB/syslinux.cfg


Finish up

sync
umount $ISO
umount $USB


Unplug the USB stick, plug it into the target system, reboot - good luck.