Create USB installer from the command line?

Posted by j-g-faustus on Ask Ubuntu See other posts from Ask Ubuntu or by j-g-faustus
Published on 2011-01-13T01:30:25Z Indexed on 2011/01/13 9:58 UTC
Read the original article Hit count: 343

I'm trying to create a bootable USB image to install Ubuntu on a new computer.

I have done this before following the "create USB drive" instructions for Ubuntu desktop, but I don't have an Ubuntu desktop available.

How can I do the same using only the command line?

Things I've tried:

  • Create bootable USB on Mac OS X following the ubuntu.com "create USB drive" instructions for Mac: Doesn't boot.
  • usb-creator: According to apt-cache search usb-creator and Wikipedia usb-creator only exists as a graphical tool.
  • "Create manually" instructions at help.ubuntu.com: None of the files and directories described (e.g. casper, filesystem.manifest, menu.lst) exist in the ISO image, and I don't know what has replaced them.
  • unetbootin scripting: Requires X server (graphics support) to run, even when fully scripted. (The command sudo unetbootin lang=en method=diskimage isofile=~/ubuntu-10.10-server-amd64.iso installtype=USB targetdrive=/dev/sdg1 autoinstall=yes gives an error message unetbootin: cannot connect to X server.)

Update

Also tried GRUB fiddling: Merging information from

I was able to get halfway there - it booted from USB, displayed the grub menu and started the installation, but installation did not complete.

For reference, this is the closest I got:

sudo su
  # mount USB pen
mount /dev/sd[X]1 /media/usb
  # install GRUB
grub-install --force --no-floppy --root-directory=/media/usb /dev/sd[X]
  # copy ISO image to USB
cp ~/ubuntu-10.10-server-amd64.iso /media/usb
  # mount ISO image, copy existing grub.cfg
mount ~/ubuntu-10.10-server-amd64.iso /media/iso/ -o loop
cp /media/iso/boot/grub/grub.cfg /media/usb/boot/grub/

I then edited /media/usb/boot/grub.cfg to add an .iso loopback, example grub entry:

menuentry "Install Ubuntu Server" {
  set gfxpayload=keep
  loopback loop /ubuntu-10.10-server-amd64.iso  
  linux (loop)/install/vmlinuz  file=(loop)/preseed/ubuntu-server.seed iso-scan/filename=/ubuntu-10.10-server-amd64.iso quiet --
  initrd (loop)/install/initrd.gz
}

When booting from USB, this would give me the Grub boot menu and start the installer, but the installer gave up after a couple of screens complaining that it couldn't find the CD-ROM drive. (Naturally, as the box I'm installing on doesn't have an optical drive.)

I resolved this particular issue by giving up and doing the "create USB drive" routine using the Ubuntu Live desktop CD (on a computer that does have an optical drive), then the USB install works.

But I expect that there is some way to do this from the command line of an Ubuntu system without X server and without an optical drive, so the question still stands.

Does anyone know how?

© Ask Ubuntu or respective owner

Related posts about installation

Related posts about ubuntu-server