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.
dd
flash were good (i.e., use the checksums)? – HalosGhost Apr 22 '14 at 05:02gdisk
and yourman
pages! – mikeserv Apr 22 '14 at 05:20