8

I created a bootable usb from which I was going to install Arch. I did this the following way:

sudo dd if=/path_to_arch_.iso of=/dev/sdX

But when I tried to boot from this usb flash, I failed. There was no error, it just couldn't boot from it. I downloaded iso file from the official arch linux website recently so it should be up to date. Previously I was able to install mint, elementary and ubuntu from usb flash successfully.

It preventing me booting the following way:

After selecting "boot from usb" I was shown a black screen for 1 second and brought back to the menu where I must choose a temporary boot device. When I did it again the story repeated.

What might be the cause?

Incerteza
  • 2,671
  • Sometimes Uefi or similar configurations fails to boot dd'ed flash. Try instead using tools that have support for uefi and bios, like liveusb-creator(it exists on fedora, archlinux aur repo, windows (https://fedorahosted.org/liveusb-creator/)). – IBr Apr 22 '14 at 04:26
  • @IBr, I need such a tool for linux (the one I can launch on linux). – Incerteza Apr 22 '14 at 04:27
  • @IBr, sudo aptitude install liveusb-creator doesn't work, it can't find it. – Incerteza Apr 22 '14 at 04:31
  • 2
    Can you please clarify a bit more. In what way were you prevented from booting the drive? Was it not an option in your boot menu? Was it there, but selecting it just led to a black screen? Etc. – HalosGhost Apr 22 '14 at 04:31
  • Compile from the source then on ubuntu. rpm packages and archlinux aur packages exists already. – IBr Apr 22 '14 at 04:50
  • @HalosGhost, after selecting "boot from usb" I was shown a black screen for 1 second and brought back to the menu where I must choose a temporary boot device. – Incerteza Apr 22 '14 at 05:00
  • @Alex, did you make sure to check that the download and the dd flash were good (i.e., use the checksums)? – HalosGhost Apr 22 '14 at 05:02
  • @IBr, I downloaded https://fedorahosted.org/releases/l/i/liveusb-creator/liveusb-creator-3.11.8.tar.gz. What do I do next? There are make file and setup.py in it, but what should I launch first? There is no "how-to" or any instruction in it. – Incerteza Apr 22 '14 at 05:03
  • 2
    Don't use liveusb creator. If you're trying to boot on UEFI all you need to do is format the disk correctly! Use gdisk and your man pages! – mikeserv Apr 22 '14 at 05:20
  • @mikeserv, which disk? I won't install arch linux alone, I want to install it along with my current ubuntu installation. – Incerteza Apr 22 '14 at 05:54
  • https://wiki.archlinux.org/index.php/USB_Flash_Installation_Media#Using_manual_formatting If you want it manually. http://ifireball.wordpress.com/2011/10/14/running-fedoras-liveusb-creator-on-ubuntu/ if you want to go liveusb-creator route. – IBr Apr 22 '14 at 06:44
  • Ok. I'm just gonna do an answer. It really is easy. Give me a few minutes... – mikeserv Apr 22 '14 at 07:40
  • Hey - just to be clear - if you already have a uefi system would you prefer just off of your hard disk? I mean you don't need the usb. I like to keep an extra-large efi system partition with rescue images on it. It's certainly easier. Anyway. I'll just go ahead with the usb thing, but, get back to me I guess. – mikeserv Apr 22 '14 at 08:13

3 Answers3

5

So I'm writing this as I do it myself. I just downloaded the latest arch iso and mounted it:

du archlinux-2014.04.01-dual.iso
535M    archlinux-2014.04.01-dual.iso

mkdir -p /mnt/iso
mount ./arch*iso $_
mount: /dev/loop0 is write-protected, mounting read-only

ls $_/arch
boot  x86_64  checksum.i686.md5    pkglist.i686.txt
i686  aitab   checksum.x86_64.md5  pkglist.x86_64.txt

You don't need most of that up there. Or, it's better to say you probably only need half of it. There are two images here - one each for 32 and 64-bit machines:

ls $_/x86_64
root-image.fs.sfs

du $_
230M    /mnt/iso/arch/x86_64

I'm willing to bet you've got a 64-bit machine if you're going with Arch and so the sfs image file in the above directory makes the bulk of what you'll need. Still, if it is a 32-bit machine just follow along but from here on out substitute the 686 files for the x86-64 I'll be targeting.

mkdir -p /mnt/img
mount /mnt/iso/EFI/archiso/efiboot.img $_
cd $_ ; ls
EFI  loader

cd EFI ; ls
archiso  boot  shellx64_v1.efi  shellx64_v2.efi

ls ./*/*
./archiso/archiso.img  ./archiso/vmlinuz.efi  
./boot/HashTool.efi  ./boot/bootx64.efi  ./boot/loader.efi

So the hybrid .iso image works by subverting the iso image standard and creating something like a fake partition or something. I don't really know too much about that but if you have a UEFI system the kernel and initramfs image you'll need are in the efiboot.img file. In fact, once you pull what you need out of here, you need little else than that other file I've already pointed out. So, now I'll get into gdisk and we'll prepare our target efi system partition. It's kind of a cake walk.

OK, I guess I don't have a thumb drive handy so I'm just going to do it like this:

fallocate --l $((650*1024*1024)) /tmp/bootimage
losetup -f --show -P $_
/dev/loop2

You don't want to use fallocate or losetup I'm just showing you that I am in the interest of full-disclosure. But, otherwise, what I am doing is what you need to do. For instance, because you likely wrote over some very early blocks on that disk, we need to clear them:

dd ibs=4M count=1 if=/dev/zero of=/dev/loop2

Now we get into gdisk. Substitute whatever /dev/... device file your usb disk is on for my /dev/loop2:

gdisk /dev/loop2
GPT fdisk (gdisk) version 0.8.10
Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present
Creating new GPT entries.Command (? for help): ?

When you open gdisk you'll see something like the above go ahead and hit the ? for the menu:

b       back up GPT data to a file
c       change a partition's name
d       delete a partition
i       show detailed information on a partition
l       list known partition types
n       add a new partition
o       create a new empty GUID partition table (GPT)
p       print the partition table
q       quit without saving changes
r       recovery and transformation options (experts only)
s       sort partitions
t       change a partition's type code
v       verify disk
w       write table to disk and exit
x       extra functionality (experts only)
?       print this menu
Command (? for help): o

We need a new empty partition table. That's o.

You'll need to agree here:

This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y

Next we need a partition. At the below prompts where you don't see the key entered it's because I just hit ENTER to agree to the default:

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-1331166, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-1331166, default = 1331166) or {+-}size{KMGTP}: 500M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef00

If you hit L at the last prompt above you'll get a list of all the available partition types but what you need is type ef00 for efi system partition. And you're almost done.

Have a look at your new partition with p then follow it up with w if you like the it looks to write out your pending changes:

Command (? for help): p
Disk /dev/loop2: 1331200 sectors, 650.0 MiB
Logical sector size: 512 bytes
Disk identifier (GUID): E5D5A761-6AFA-48C6-9BA5-CED0DA2F62CA
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1331166
Partitions will be aligned on 2048-sector boundaries
Total free space is 309180 sectors (151.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1024000   499.0 MiB   EF00  EFI System

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/loop2.
The operation has completed successfully.

I assume you have a bootloader but you might as well put one on your USB disk too, and this is really easy. In fact, I'll show you how to set it up with rEFInd which was actually a revival of an older project and written and maintained by the same guy who wrote gdisk.

Get the refind.bin.*.zip you'll find here and we'll unpack it to our disk then copy the arch image over and we're done.

Actually, we'll definitely need a filesystem first. Glad I'm actually doing this as I write it - missing that would have been a dealbreaker for sure.

mkfs.vfat -n ESP /dev/loop2
mkfs.fat 3.0.26 (2014-03-07)
Loop device does not match a floppy size, using default hd params

Again, ignore the stuff about loop and use your own device. -n names the partition. I like to use ESP.

Ok, so now for rEFInd:

mkdir /tmp/refind
unzip ~/Downloads/refind-bin-0.7.9.zip -d $_  
...
$_/ref*/install.sh --usedefault /dev/loop2
Not running as root; attempting to elevate privileges via sudo....
Installing rEFInd on Linux....
UnmountEsp = 1
Copied rEFInd binary files
Copying sample configuration file as refind.conf; edit this file to configure
rEFInd.
Installation has completed successfully.
Unmounting install dir

mkdir -p /mnt/bootdisk
mount /dev/loop2 $_

mkdir /mnt/bootdisk/EFI/arch_linux
cp /mnt/img/EFI/archiso/* -t $_
cp -R /mnt/iso/arch/*64* $_
cp -R /mnt/iso/arch/aitab $_
ls -lR $_
/mnt/bootdisk/EFI/arch_linux:
total 23328
drwxr-xr-x 2 root root     4096 Apr 22 02:09 x86_64
-rwxr-xr-x 1 root root      228 Apr 22 02:09 aitab
-rwxr-xr-x 1 root root 19882780 Apr 22 02:08 archiso.img
-rwxr-xr-x 1 root root       99 Apr 22 02:09 checksum.x86_64.md5
-rwxr-xr-x 1 root root     5142 Apr 22 02:09 pkglist.x86_64.txt
-rwxr-xr-x 1 root root  3979248 Apr 22 02:08 vmlinuz.efi

/mnt/bootdisk/EFI/arch_linux/x86_64:
total 234812
-rwxr-xr-x 1 root root 240447488 Apr 22 02:09 root-image.fs.sfs

That just about does it. You will need to setup rEFInd a little bit...

echo '"ArchISO" "archisolabel=ESP archisobasedir=/EFI/arch_linux \
    copytoram rootwait initrd=EFI\arch_linux\archiso.img"'\
    >$_/refind_linux.conf

That should give you a bootable system. Please look through the main refind.conf in ../BOOT - it's very well commented and pretty much documents itself. You'll also want to head over to rodsbooks.com and read the docs there.

One last note though. If you were to put the same stuff on your system's hard disk on the EFI system partition you'd always have access to the bootable arch live disc.

mikeserv
  • 58,310
  • thanks. note I already have unallocated space, I made it by gparted earlier. – Incerteza Apr 22 '14 at 08:49
  • @Alex - well, no guarantees then. I really don't like gparted personally. gdisk is easy - and it works all of the time, opposed to gparted... – mikeserv Apr 22 '14 at 09:04
  • 1
    The OP just wants to create an install disk: none of this is necessary... – jasonwryan Apr 22 '14 at 09:44
  • @jasonwryan That is an install disk. And, more to the point, a separate disk is not at all necessary anyway. Though I do in fact pointedly copy only what's necessary - not including rEFInd, that is. – mikeserv Apr 22 '14 at 09:53
  • @mikeserv The archiso just has to be dd'ed; tell me why any of this is either necessary or desirable. – jasonwryan Apr 22 '14 at 10:02
  • @jasonwryan - first, you get your whole disk. You don't have some ridiculous cd image taking up an 8gb usb disk. Also - you don't need a separate disk at all. You can install Arch Linux from Ubuntu. And it doesn't have to be ddd - that's ridiculous as well. You can cat the image over a device just as easily, but even that is unnecessary. What you get above is just a regular, workable, bootable efi system partition containing an Arch Linux sqsh root image. You also can put any other bootable system on it. It's easy. dding a 512mb image over a usb disk is what's nonsensical. – mikeserv Apr 22 '14 at 10:08
  • @jasonwryan - in fact - you don't even need a disk. You could flash your network card's oprom and netboot arch if you want. The arch linux install image is packaged the way it is because it's easy to package that way for the maintainers. You can refuse to learn anything about it, or, alternatively, you could check out the git page and do the opposite. – mikeserv Apr 22 '14 at 10:11
  • @mikeserv I guess our respective definitions of "ridiculous" and "nonsenical" are quite different... Thanks for the condescending remark about how I can "refuse to learn": it makes it easier for me to avoid interacting with you in future. – jasonwryan Apr 22 '14 at 10:33
  • @jasonwryan - yeah, I can thank you for the same. I come here to learn the mechanics of computer systems - to learn how things work, not boilerplate "just trash your partition table" answers - I can get that at the Arch Wiki. I have no use for proponents of such. I cannot understand how someone can look at a step-by-step tutorial that clearly demonstrates how to handle a boot disk and yet flatly refuse to acknowledge that it has any relevance to question about how to handle a boot disk. And if it was so uninteresting to you, why bother commenting at all? – mikeserv Apr 22 '14 at 10:45
  • @Mikeserv I didn't say anything about it not being relevant; I said it wasn't necessary. There is a difference. – jasonwryan Apr 22 '14 at 10:48
  • @jasonwryan - this is in fact only what's necessary. All of the rest - the 32-bit root, the BIOS compat stuff, grub (or is it gummi?), the iso filesystem itself - these are all unnecessary. – mikeserv Apr 22 '14 at 10:50
  • why not use usb-live-creator? I was able to install Ubuntu using a similar tool and I installed Ubuntu successfully from usb flash. – Incerteza Apr 24 '14 at 02:42
  • @Alex you can do as you like, of course, but those kinds of tools have two problems: 1. They are seldom updated as often as they should be , 2. They imply unnecessary dependency. All you need are the root image file, the kernel and the initramfs image, really. Too often, i think, people think things should be done a certain way because they have been done a certain way. What you get from most live discs is a compromise between functionality and compatibility. If you know your target's architecture and firmware type you dont have to compromise. – mikeserv Apr 24 '14 at 02:56
  • @Alex - and besides, the above operation is pretty close to exactly what youll need to do to install Arch Linux to a disk anyway, so its not as if you dont need to know how. During the installation process you wont simply be copying a pre-packaged disk image and will instead be installing packages, but you could, i guess. And as i said before, i like to keep those images in a folder on my efi system partition so i can boot to a live image at any time. To update your usb disk all you need to do is replace the .sfs file. – mikeserv Apr 24 '14 at 03:02
  • losetup -f --show -P $_ losetup: invalid option -- 'P' – Incerteza Apr 26 '14 at 13:17
  • Substitute whatever /dev/... device file your usb disk is - I didn't get it, what does it have to do with usb disk? – Incerteza Apr 26 '14 at 13:20
  • @Alex - you dont use losetup at all. You already have a device - /dev/sd? something. Do lsblk - note all the devices there - remove your usb disk - do lsblk again - and whatever device is now missing is the one you should be using. losetup just provided me a loop mount /dev to use instead of a usb. – mikeserv Apr 26 '14 at 14:41
  • @Alex - you dont use losetup at all. - but I did it already. I thought it had never to do with usb flash at all. – Incerteza Apr 26 '14 at 21:27
  • @Alex - losetup just creates a loop device - it's just an emulated disk. But you have an actual disk. As far as Ubuntu is concerned, this shouldn't affect the current system's disk at all - only the /dev/sd? device on which youve been working - which should be your usb. If youre unfamiliar with your system devices do man gdisk mount lsblk devtmpfs and read the manuals that come with your system to learn a little more. – mikeserv Apr 27 '14 at 00:24
  • The question is not what it does but what do I do now? Should I repeat the same but replace /dev/loop2 with my usb flash /dev/sd? ? – Incerteza Apr 27 '14 at 02:12
  • @Alex yeah. Definitely. Thats all you need to do. Be sure to use the usb and its cake. It wont touch any disk but what you specify. – mikeserv Apr 27 '14 at 03:25
  • Thanks. By the way, what's the difference between dd if=/dev/zero ..., dd if=/dev/null ... and rm -r? – Incerteza Apr 27 '14 at 03:53
  • @Alex rm -r is a command that means remove files recursively. /dev/zero is a system device file that will return endless zeroes - its a bottomless pit. /dev/null is the opposite - its always completely empty. dd is the disk dumper often called "disk destroyer" - it reads a file and dumps it into another. In most cases it can be replaced with cat but its handy when you want only so much of a file - such as with /dev/zero. – mikeserv Apr 27 '14 at 04:07
  • @Alex - so I guess it worked then? Remember - your USB is just a regular disk so you can put other partitions on it as you like now and still keep your arch live system. You can also put other installers in their own folders on your efi system partition and boot them as you please by selecting their kernels in rEFInd's boot menu. It will even work for Windows.I fixed the call to dd by the way. – mikeserv Apr 27 '14 at 18:15
  • Yes, but it started to boot well only when I enabled UEFI boot at bios. I think a simple dd would also work nice. However, installing it is not so easy because I'll have to remember each step (there'll be no internet browser during the installation) when I'll be installing it and there are lots of them, though. So this time I just made sure it booted well, then rebooted the system and came back to Ubuntu. – Incerteza Apr 27 '14 at 18:41
  • Yeah, that means youre not running EFI mode - and Ubuntu isnt installed that way either. Things tend to get a little more simple once you go whole-hog. dd-ing the iso should work, but whether or not your firmware will recognize an iso filesystem on a usb is kind of luck of the draw - especially if youve got a computer right about 2 or 3 years old. Things are much better today and earlier than that though. In any case - the above steps are very easily scriptable. If Arch is a little intimidating for you, maybe have a look at Manjaro. – mikeserv Apr 27 '14 at 18:46
  • @Alex There are a few different ways to do that. One could be installing it in a vm to a raw partition on your disk then booting to it by adding its kernel and initrd into your current bootloader config. You could also compile pacman and its dependencies in Ubuntu and just use them to install an Arch root. Or you could mount the archiso.sfs file we just copied to your usb an chroot into then do the install. Seriously - the list goes on. All require some savvy though. – mikeserv Apr 27 '14 at 18:50
  • You said You can install Arch Linux from Ubuntu. - could you explain how? – Incerteza Apr 27 '14 at 18:52
  • I suppose it's easier to install it the normal way. Thanks. – Incerteza Apr 27 '14 at 18:57
  • @Alex But about the installation steps - theyre included on the archiso disk itself in /root - theres a text file there called instructions or something. You can just less <instructions to peruse it as you please. Though it might more not less o the installer disk - i cant remember. – mikeserv Apr 27 '14 at 18:58
  • Would you mind taking a look here http://unix.stackexchange.com/questions/126841/how-to-make-an-unallocated-space-exist ? – Incerteza Apr 28 '14 at 05:16
  • one more thing: the installation screen is not the same as I saw in the many tutorials and it doesn't ask me whether I want to install x32 or x64. Why? – Incerteza Apr 28 '14 at 09:58
  • @Alex Because you only copied the 64-bit image. If you want the 32-bit you have to get the 686 files as i noted in the answer. – mikeserv Apr 28 '14 at 10:34
  • Nope, I need x64, that's fine. – Incerteza Apr 28 '14 at 10:36
  • the last question please: will be able to boot ubuntu after arch's installation and how can I make sure? should I run boot-repair while I'm on arch? – Incerteza Apr 28 '14 at 11:13
  • http://bbs.archbang.org/viewtopic.php?id=5487 the file aitab doesn't exist anymore, will your approach still work? – Incerteza Feb 02 '16 at 13:16
  • @アレックス - its called something else now. But yeah - it should. – mikeserv Feb 02 '16 at 13:20
4

The proper way to do so is (as described on the Arch Linux Wiki)

# dd bs=4M if=/path_to_arch_.iso of=/dev/sdX && sync

using GNU dd.

enedil
  • 1,674
  • I've written some of it. At least mine was not reliable. I deleted my comment anyway. In any case you definitely don't need both image files. And why use a non-compat filesystem like hybrid iso when you don't have to. I'd rather have a real partition table. – mikeserv Apr 22 '14 at 09:48
  • what's GNU dd? Didn't I use it? What's the difference with mine code? – Incerteza Apr 22 '14 at 13:57
  • You're using GNU dd. The difference is bs=4M and sync command. http://linux.die.net/man/2/sync – enedil Apr 22 '14 at 14:18
  • that didin't work for me either. maybe I should use a CD instead of usb flash? – Incerteza Apr 24 '14 at 02:39
  • You can try, trough the command has worked for me. – enedil Apr 24 '14 at 07:37
0

It took me a while to understand how to create a live-usb with arch linux. The solution is simple. I just wrote:

$ dd if=/adress/of/iso-file of=/adress/of/usb-stick/sda/not/sdaY/don't/write/the/partition/number

I worked a lot with gnome disk utility and gparted. It's okay to clear the partition table of the USB-Stick.

One interesting fact is important. If dd ends with just 100-400 files, then something went wrong. Sometimes it took more time but I abborted because I didn't want to wait so long. Then I did once until it's finished. I'm sure it took about 20 minutes that time and suddely dd shows up with about 10000 files correctly transmitted. I booted the stick and everything works fine. I didn't know about the amount of files and I think if you do it the way I did (as you can see I didn't use the bs=part) and wait about 30 minutes, everything should be fine.

An USB 3.0 stick really can help you.

VaTo
  • 3,101