Author Topic: Installing Arch Linux on a flash drive for mobo with EUFI BIOS  (Read 1814 times)

Offline Rotten Johnny

  • ROONed for life.
  • Administrator
  • Trade Count: (+31)
  • *****
  • Posts: 14,845
I've had to do this a few times on different machines and on each occasion I've had to rely on my google skills to identify and refer to a number of resources that helped me on the way.  This is written to help myself and others get it right first time and save what could otherwise be hours of frustration.  This guide assumes a basic level of Linux know-how and covers installing Arch Linux onto a target USB flash drive (/dev/sdX) using a source USB flash drive (/dev/sdY).  Furthermore, it details how to go about installing Arch on a EUFI machine without having to install a bootloader.

Firstly, download the Arch Linux ISO file and write it to a flash drive as follows (where sdY represents the flash drive):
Code: [Select]
dd bs=4M if=/path/to/archlinux.iso of=/dev/sdY && sync
Turn off compatibility mode and secure boot in the UEFI BIOS, connect network cable, and reboot target machine from flash drive. After the boot sequence is completed insert the target flash drive on which you wish to install Arch Linux and determine its device name:
Code: [Select]
lsblk
Partition the target flash drive with 512MB partition of type ef00 and the remainder as a regular Linux partition using gdisk:
Code: [Select]
gdisk /dev/sdX
If you need to wipe out existing partitions etc. on the target flash drive use expert mode (press x) and zap the gpt tables, mbr etc. (press z).  Then relaunch gdisk as above

Once in gdisk press n and follow the prompts to size the partition table and set its type +512MB ef00
When done with the first partition press n again and create a second (Linux) partition utilising the remaining space on the flash drive.
When done press w and confirm writing of the partition tables.

Format the partitions FAT32 and EXT4 respectively:
Code: [Select]
mkfs.fat -F32 /dev/sdX1
mkfs.ext4 /dev/sdX2

Now mount the Linux partition to /mnt and EFI System Partition to /mnt/boot
Code: [Select]
mount /dev/sdX2 /mnt
mkdir /mnt/boot
mount /dev/sdX1 /mnt/boot

Install the base system, generate an fstab (note the use of -U to utilise UUIDs for device identification) and load temp files to ram:
Code: [Select]
pacstrap /mnt base
genfstab -U -p /mnt >> /mnt/etc/fstab
nano /mnt/etc/fstab

Add the following to fstab:
Code: [Select]
tmpfs /var/log tmpfs defaults 0 0                 
tmpfs /var/tmp tmpfs defaults 0 0
tmpfs /tmp tmpfs defaults 0 0


chroot into and configure the base system
Code: [Select]
arch-chroot /mnt /bin/bash
hwclock --systohc --utc
echo myhostname > /etc/hostname

Add the same hostname to /etc/hosts and edit the file to place it in the correct location
127.0.0.1   localhost.localdomain   localhost   myhostname:
Code: [Select]
echo myhostname >> /etc/hosts
nano /etc/hosts

Set locale by uncommenting the locale you wish to use.  Typically either US or ZA
Code: [Select]
nano /etc/locale.gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
locale-gen

Create a symbolic link /etc/localtime to your subzone file /usr/share/zoneinfo/Zone/SubZone using this command:
Code: [Select]
ln -s /usr/share/zoneinfo/Africa/Johannesburg /etc/localtime
Setup Dynamic IP, firstly by ascertaining ethernet device name, then by copying a sample profile from /etc/netctl/examples to /etc/netctl and modifying it:
Code: [Select]
ip l
cd /etc/netctl
cp examples/ethernet-dhcp my_network
nano /etc/netctl/my_network
netctl enable my_network

Set the root password:
Code: [Select]
passwd
Install some essentials (only install intel-ucode if you're running Intel hardware):
Code: [Select]
pacman -S intel-ucode openssh mc
Enable root login (thanks scrarfussi):
Find the following line
#PermitRootLogin prohibit-password
Remove the # and change prohibit-password to yes
Code: [Select]
cd /etc/ssh/
cp sshd_config sshd_config.org
nano sshd_config

Now you have  a decision to make...use a bootloader or bypass it.  Bypassing makes for a faster boot and is great if your EUFI BIOS can boot an OS directly.

If you want to use a bootloader:
Install the UEFI bootloader.
Code: [Select]
pacman -S dosfstools
pacman -S gummiboot
gummiboot install

Determine device UUIDs and create a configuration file to add an entry for Arch Linux to the gummiboot manager:
Code: [Select]
blkid >> /boot/loader/entries/arch.conf
nano /boot/loader/entries/arch.conf

Remove UUID entries other than that pertaining to the flash drive and add the following (using your device UUID):
Code: [Select]
title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=UUID=b73ea863-5d7f-4d4d-b12e-51fef92cdb2f rw

If you don't want to use a bootloader:
exit chroot
Code: [Select]
exitList EFI boot entries in BIOS and flush cache
Code: [Select]
efibootmgr -v
sync
Use efibootmgr to delete all firmware boot entries
Code: [Select]
efibootmgr -b # -Bwhere # is the entry number you want to delete

Now what is needed is the ability to have the EFISTUB point to the UUID of the Linux partition on the flash drive you've just installed to in order to ensure that the correct device is referenced for booting regardless of what other drives are present on the machine.  In my case it was /dev/sdb2. Typing in a UUID from a terminal window seems like a stupid idea unless you're really accurate with your typing.

I got around that by capturing the UUIDs in a file, editing it to remove the crud, adding the efibootmgr line I needed and then running the resulting script.

Once the file was loaded in nano I added the efibootmgr line referencing the partition UUID for /dev/sdb2 (i.e. the root partition of my Arch install).  It reads as follows:

Capture UUIDs in a file for editing and execution
Code: [Select]
blkid > blkids.sh
nano blkids.sh
chmod +x blkids.sh
./blkids.sh

This what was added to the file:
Code: [Select]
efibootmgr -d /dev/sdb -p 1 -c -L "Arch" -l /vmlinuz-linux -u "root=UUID=addyouruuidhere rw initrd=/intel-ucode.img  initrd=/initramfs-linux.img"

Exit the target system, flush cache and reboot from the target flash drive (remember to remove the source USB flash drive during reboot sequence):
Code: [Select]
sync
exit
umount /mnt/boot
umount /mnt
sync
reboot

To come
- add NFS server
- add SAMBA server
- add LMS
« Last Edit: April 11, 2016, 05:34:44 PM by Rotten Johnny »
Audiophile: There is almost no other group that prides themselves more on wasting good money on utterly worthless ****, and then trying to furiously blow smoke up their own ass to justify it.

Free your mind...and your ass will follow.

Offline BWS

  • Administrator
  • Trade Count: (+1)
  • *****
  • Posts: 15,746
Re: Installing Arch Linux on a flash drive for mobo with EUFI BIOS
« Reply #1 on: August 05, 2014, 07:41:19 AM »
... and you call me NERD
In the word : Scent, is it the S or the C that is silent?

Offline scrarfussi

  • Trade Count: (+23)
  • AVForums Veteran
  • *****
  • Posts: 5,900
  • Quantum In Me Fuit
Re: Installing Arch Linux on a flash drive for mobo with EUFI BIOS
« Reply #2 on: August 05, 2014, 09:33:24 AM »
 :notworthy: :notworthy: :notworthy:

Arch makes me also want to be a nerd
i need another pc
suum cuique pulchrum est


"I refuse to prove that I exist,'" says God, "for proof denies faith, and without faith I am nothing."

Offline Rotten Johnny

  • ROONed for life.
  • Administrator
  • Trade Count: (+31)
  • *****
  • Posts: 14,845
Re: Installing Arch Linux on a flash drive for mobo with EUFI BIOS
« Reply #3 on: August 06, 2014, 06:33:59 AM »
... and you call me NERD
Absolutely.   :shh:
Audiophile: There is almost no other group that prides themselves more on wasting good money on utterly worthless ****, and then trying to furiously blow smoke up their own ass to justify it.

Free your mind...and your ass will follow.

Offline gavinbirss

  • Trade Count: (+1)
  • AVForums Veteran
  • *****
  • Posts: 1,160
Re: Installing Arch Linux on a flash drive for mobo with EUFI BIOS
« Reply #4 on: August 06, 2014, 09:04:46 AM »
@Johnny Rotten

Thanks,
Can I assume above applies to an MBR partition scheme?

My Mac Pro 6,1 allow boot mostly from GPT EFI without installing a 3rd party boot manager like refi/t/ind. Windows install/boot from MBR is supported but not Linux.

Formatting a drive with GPT Disk layout on Apple would have an 200MB Apple EFI partition as partition 0. With GPT layout 3 parittions would be needed?
as the Apple EFI partition is normally hidden after boot.

Offline Rotten Johnny

  • ROONed for life.
  • Administrator
  • Trade Count: (+31)
  • *****
  • Posts: 14,845
Re: Installing Arch Linux on a flash drive for mobo with EUFI BIOS
« Reply #5 on: August 06, 2014, 09:18:08 AM »
^^^ definitely not applicable to MBR booting. Sounds like you'd already have the equivalent of a EUFI boot partition so after doing the base install as shown here I guess you'd need to edit the boot manager's config file to add Arch as a boot option.
Audiophile: There is almost no other group that prides themselves more on wasting good money on utterly worthless ****, and then trying to furiously blow smoke up their own ass to justify it.

Free your mind...and your ass will follow.

Offline Rotten Johnny

  • ROONed for life.
  • Administrator
  • Trade Count: (+31)
  • *****
  • Posts: 14,845
Re: Installing Arch Linux on a flash drive for mobo with EUFI BIOS
« Reply #6 on: April 11, 2016, 05:36:31 PM »
updated to add EUFI boot without a bootloader
Audiophile: There is almost no other group that prides themselves more on wasting good money on utterly worthless ****, and then trying to furiously blow smoke up their own ass to justify it.

Free your mind...and your ass will follow.