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 toapt-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 messageunetbootin: 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?
Have you tried with #
dd if=path/to/image.iso of=/dev/sd#
?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:
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.
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.
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
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 issdb
; use/dev/sdb
and so on.Creating a bootable Ubuntu USB flash drive from terminal
Mount the
ubuntu.iso
file.For this run the below commands in terminal,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,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,Go into the
/media/xxx
folder and rename theisolinux
directory tosyslinux
.Then go into the renamed syslinux folder and rename the fileisolinux.cfg
tosyslinux.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.
or
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)
Make it executeable
Now mount your iso to /iso and mount your usb device to /mnt
If you want very verbose messages at your console you can tail ~/.cache/usb-creator.log
Now run that usb-creator-cli script
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.