Create USB installer to install Ubuntu from the command line?

Have you tried with # dd if=path/to/image.iso of=/dev/sd# ?


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.

This is a known bug with ubuntu server iso (desktop iso works just fine), but there is a fix to get the packages from the iso on the usb drive: once on the installer, Ctrl+Alt+f2 to open a tty and in the terminal:

mount -t vfat /dev/sdX1 /mnt
ln -sf /mnt/ubuntu-server.iso /dev/sr0

Then switch back to installer and retry to scan cd for packages. It should work.


Let us assume you have nothing but a prompt before you. If you have a GUI, you can open a terminal and do everything described here. Or you may use a tty.

WARNING:
To avoid potential damage, follow the instructions very very carefully.

  • Switch to a root prompt by typing sudo su

    Detect what device the usb is.

  • tail -f /var/log/syslog

You are now having a live view at syslog. Plug in your usb drive. You should see some messages on screen. Something like this.

May 27 00:35:07 Mahesh kernel: [ 5054.646585] usb 2-1.1: new high-speed USB device number 5 using ehci_hcd
May 27 00:35:07 Mahesh kernel: [ 5054.741437] scsi8 : usb-storage 2-1.1:1.0
May 27 00:35:07 Mahesh mtp-probe: checking bus 2, device 5: "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1"
May 27 00:35:07 Mahesh mtp-probe: bus: 2, device: 5 was not an MTP device
May 27 00:35:08 Mahesh kernel: [ 5055.739177] scsi 8:0:0:0: Direct-Access     JetFlash TS2GJFV30        8.07 PQ: 0 ANSI: 2
May 27 00:35:08 Mahesh kernel: [ 5055.740198] sd 8:0:0:0: Attached scsi generic sg3 type 0
May 27 00:35:08 Mahesh kernel: [ 5055.741593] sd 8:0:0:0: [sdc] 4005888 512-byte logical blocks: (2.05 GB/1.91 GiB)
May 27 00:35:08 Mahesh kernel: [ 5055.742214] sd 8:0:0:0: [sdc] Write Protect is off
May 27 00:35:08 Mahesh kernel: [ 5055.742218] sd 8:0:0:0: [sdc] Mode Sense: 03 00 00 00
May 27 00:35:08 Mahesh kernel: [ 5055.742712] sd 8:0:0:0: [sdc] No Caching mode page present
May 27 00:35:08 Mahesh kernel: [ 5055.742715] sd 8:0:0:0: [sdc] Assuming drive cache: write through
May 27 00:35:08 Mahesh kernel: [ 5055.745326] sd 8:0:0:0: [sdc] No Caching mode page present
May 27 00:35:08 Mahesh kernel: [ 5055.745329] sd 8:0:0:0: [sdc] Assuming drive cache: write through
May 27 00:35:08 Mahesh kernel: [ 5055.781564]  sdc: sdc1
May 27 00:35:08 Mahesh kernel: [ 5055.784191] sd 8:0:0:0: [sdc] No Caching mode page present
May 27 00:35:08 Mahesh kernel: [ 5055.784196] sd 8:0:0:0: [sdc] Assuming drive cache: write through
May 27 00:35:08 Mahesh kernel: [ 5055.784200] sd 8:0:0:0: [sdc] Attached SCSI removable disk

look at it, and find one thing in square brackets repeating? sdc in this case. Note it down on a piece of paper. Type Ctrl+C to get to the prompt.

Locate the iso file to burn onto usb.

If the iso file is at /path/to/iso/somecd.iso ; note this path on a piece of paper.

Write onto USB

Warning:

This will erase the entire USB disk. Backup before proceed.

  • dd if=/path/to/iso/somecd.iso of=/dev/sdc ibs=20M obs=20M

Replace /path/to/iso/somecd.iso with the actual path to your iso file.

Replace /dev/sdc with whatever you noted down earlier. If the repeating part is sdb ; use /dev/sdb and so on.

Warning:

Typing a drive letter wrong will result in permanent data loss on a different drive. Pay extra attention while issuing dd command.