Home > boot > Create USB installer to install Ubuntu from the command line?

Create USB installer to install Ubuntu from the command line?

January 13Hits:1
Advertisement

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 the 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?

Answers

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.

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

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.

Creating a bootable Ubuntu USB flash drive from terminal

  • Mount the ubuntu.iso file.For this run the below commands in terminal,
    sudo mkdir /media/iso
    sudo mount -o loop /path/to/ubuntu.iso /media/iso
    
    
  • Then copy all the files from /media/iso to your mounted usb flash drive folder in /media.

    Insert your usb flash drive.

    It will automatically mounted,whenever you insert it.Your usb partition must be mounted inside /media.Let us assume your usb drive mounted inside /media/xxxx folder.Then run the below command,

    cp -a /media/iso/. /media/xxx
    
    

    Run lsblk command to know the usb device partition.

  • Then paste the ldlinux.sys file inside your USB flash drive partition(In my case /dev/sdd1) to make the usb bootable .For this run the below commands,
    sudo apt-get install syslinux mtools
    syslinux -s /dev/sdd1
    
    
  • Go into the /media/xxx folder and rename the isolinux directory to syslinux.Then go into the renamed syslinux folder and rename the file isolinux.cfg to syslinux.cfg.
       mv /media/xxx/isolinux /media/xxx/syslinux
       mv /media/xxx/syslinux/isolinux.cfg /media/xxx/syslinux/syslinux.cfg
    
    
  • Reboot your pc and change the boot-order in bios to USB.Now your ubuntu usb flash drive will booted up and you can install it.

This method will works for any linux distributions,not only ubuntu.

I solved this particular problem by using the Ubuntu Live desktop CD.

By booting the Live CD on a computer with an optical drive, I could use the Ubuntu desktop instructions to create the USB pen installer without touching the existing installation.

You can hack usb-creator to do this.

You should already have a single vfat partition as partition 1 on the usb device (the erase disk step of usb-creator-gtk does this) and it should be marked bootable.

Next, we will get usb-creator python code to assist us.

$ sudo apt-get install usb-creator

or

$ bzr branch lp:usb-creator

create a file with this content and name it usb-creator-cli, if you use bzr in the last step, place this file in the usb-creator directory (root of bzr branch)

#!/usr/bin/env python
from __future__ import print_function
from usbcreator.misc import sane_path, setup_gettext, setup_logging, text_type

from usbcreator.install import install

sane_path()
setup_logging()
setup_gettext()

#/dev/sdb1 should be mounted on /mnt
#iso should be mounted to /iso
dev = '/dev/sdb1'
source = '/iso'
target = '/mnt'
ugh = install(source, target, False, device=dev)
ugh.success = print
ugh.failure = print
ugh.progress = print
ugh.progress_message = print
ugh.progress_pulse = print
ugh.progress_pulse_stop = print
ugh.retry = print
ugh.run()

Make it executeable

$ chmod +x usb-creator-cli

Now mount your iso to /iso and mount your usb device to /mnt

$ sudo mkdir /iso ; sudo mount ubuntu-server-12.10-amd64.iso /iso
$ sudo mount /dev/sdb1 /mnt

If you want very verbose messages at your console you can tail ~/.cache/usb-creator.log

$ tail -f ~/.cache/usb-creator.log &

Now run that usb-creator-cli script

$ sudo ./usb-creator-cli

And watch all the messages scroll by.

When you return to the prompt, don't forget to unmount /mnt before you yank your usb storage device.

You can install a command line (CLI) Ubuntu using the Alternate Install or Mini iso (which should fit on your 512mb stick)

Then install Crunchbang using the alternate method: http://crunchbanglinux.org/forums/topic/26/crunchbang-linux-81001-alternative-installation/

You could also try the Lite version of CrunchBang, which is less than 512mb.

You could use Unetbootin to prepare the USB stick.

Related Articles

  • Create USB installer to install Ubuntu from the command line?January 13

    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 on

  • Install ubuntu with the command lineJune 25

    I want to install Ubuntu without using Ubiquity. I want to install it through the command line only. Not looking for Ubuntu Server install. Just help on how I can install it through the command line. I know in Arch Linux you can use pacstrap base to

  • Installing Ubuntu manually from command line (without installer)January 22

    Some Linux distributions is lack of installation script, like Gentoo or Arch. Everything can be done by hand (partitioning disk, making filesystems, installing, etc). The questions is: Is it possible to install Ubuntu in that way? I'm making some tes

  • Can I instal Ubuntu from the command line?December 31

    I'm trying to install Ubuntu. I've done this a thousand times and usually it's fine. However, this time it has got the screen fonts all far too large. So I can't actually get the mouse to a lot of the buttons and options, making it impossible to inst

  • How to create bootable usb from pre-installed Ubuntu?September 4

    I am a new Ubuntu user. Whoever helped me assumes that I've actively downloaded Ubuntu and so have an ISO. But I got Ubuntu pre-installed, and want to create a bootable USB backup. No idea what to point the Startup Disk Creator to. (This seems to be

  • Can't see created disk partition when installing ubuntu

    Can't see created disk partition when installing ubuntuDecember 1

    I am trying install Ubuntu on dualboot with win10. I had a four disk partition - System, HP-Tools, HP-Recovery and C. I can't create disk partition when installing Ubuntu so I thought I will create new partition from Windows and then divide to disks

  • How to I install Glassfish on Ubuntu from the command line?September 15

    I have a Linux machine (Ubuntu) and I installed GlassFish and everything worked fine. The thing is, I was using Linux from the desktop UI and the installer featured a graphical wizard. I am wondering, if I create a Linux virtual machine on Amazon EC2

  • Minimal GIMP install to work from command lineJuly 31

    Ubuntu Jaunty (9.04) Server I need to do some server-side image scripting that apparently only GIMP is able to do. I'd hate to install X Window and GTK only for that. Is there a way to install GIMP without all that bloat, so it may work from command-

  • How do I install Chromium from the command line?February 3

    I have already tried using the Ubuntu Software Center, but it won't install the Chromium browser. How can I install it using the terminal? --------------Solutions------------- You can type in the terminal: sudo apt-get install chromium-browser Here's

  • How do I restart Linux (Ubuntu) from the command-line?December 9

    Because of my problem with mouse-clicks being ignored in Ubuntu, I want to restart from the command-line. (I have an open Terminal, and the keyboard is not ignored.) How do I restart a computer running Linux (or more specifically Ubuntu) from the com

  • How do I use multiple commands to install setx from the command line?February 23

    just wondering how I can install setx from the command line. I want it to be a silent install with a specified directory. I know that if I type /? after the .exe it will give me the various options, but how do I combine them? I want to user /c and /t

  • How can I install one language by command-line

    How can I install one language by command-lineJune 12

    I'm trying to have everything ready to install a new desktop with a few command line instructions. Unfortunately, to install the language packages, I couldn't find how to do it. I can run gnome-language-selector But it doesn't seems to be usable in c

  • Create self-extracting EXE from ZIP file in command line

    Create self-extracting EXE from ZIP file in command lineApril 4

    I have installed WinZip 9.0 SR1 in my system and I want to create a executable from a zip file in command line. I have tried with the following command line statement C:\Users\admin\Desktop>"C:\Program Files (x86)\WinZip 9.0 SR1\WZSEPE32.EXE"

  • what is the command to retrieve the installed application/packages via command line in windows?December 23

    Is there a command to retrieve the installed application/packages via command line in windows 2003. i.e to get the details of Add/remove programs via the command line same as 'rpm -qa ' in linux. Thanks, --------------Solutions------------- There's n

  • Install SSH server using command line commandsOctober 8

    There is a windows server with running HTTP and FTP server. I have access to the command line because I've run HTTP server under administrator account, however it's much more comfortable to run the command line directly through SSH. Is there any SSH

  • Created a Bootable USB Drive to Install Ubuntu.. What next?January 13

    I created a bootable Ubuntu USB drive (no CD drive on ultrabook) on Windows so I can install the OS. When I boot from the USB drive, I get a terminal with "grub." I have no idea how to even begin the installation of Ubuntu. Google has yielded no

  • Create ISO installation from current Ubuntu Server installationSeptember 28

    I have a kiosk running on Ubuntu server 14.04.3 and I would like to create an ISO file so when I want to create another kiosk all I will have to do is to install that ISO file and I'm done. To do that I tries to install remastersys but I just couldn'

  • Is it possible to create an installation disk of Ubuntu, from an already existing installation? February 17

    Possible Duplicate: Use existing Ubuntu partition as an installation image? I'm using Ubuntu 11.10, and wondering if it is possible to create an installation disk/image from my existing installation. I need to install it on my friend's PC. I'm just w

  • Do I need to create a partition to install Ubuntu inside Windows?May 26

    Do I need to create a partition when I install Ubuntu with the Windows Installer? The installation steps do not say anything about this. --------------Solutions------------- Installing Ubuntu with Wubi, the Windows installer, does not involve creatin

  • Make a live USB of your installed ubuntuJuly 2

    I wonder that whether there is a way of making my own installed ubuntu a live USB. The reason in fact is that I want to make my ubuntu to be used by anybody. After this guy used my ubuntu I do not want to see his garbage on my ubuntu. I want to see m

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 1.216 s.