You are not logged in.

#1 2011-11-07 22:15:46

altercation
Member
From: Seattle
Registered: 2011-05-15
Posts: 136
Website

"Arch By Hand" UEFI GPT SSD LUKS Install Script

Arch UEFI GPT LUKS (and non LUKS version) Automated Install Example Script, SSD friendly

Please note that if you're going to use this you're going to have to a) customize it to fit your needs and b) know what system config you need to do post install (rc.* etc). It's a jumping off point.

Want to put in a lot of effort just to get Arch Linux listed in your "bios" startup options? You're in the right post! Well, it's more than just that, of course. If you have an EFI machine, increasingly common, this might be of interest.

UEFI Startup Options

I got this working on my x220 tablet and thought I'd post it here. I imagine that as Archboot and the official installer rev we'll see them support this kind of thing as well, so BBS seemed like a good place to post it, but if there is an appropriate wiki location I could add it there as well.

This is pretty bare bones (otherwise you'd be using AIF or Archboot, natch) and should be customized for your own install purposes. Nonetheless, I suspect others may have been banging their heads on the low overhang of UEFI/GPT install and hope this helps them get up and running.

This is pretty much all in the wiki and BBS in various places, particularly the GRUB2 wiki entry. However the GPT partitioning (and learning more of sgdisk) were challenging enough that I felt it would be useful for others to see a working script.

I used the current-as-of-this-post Archboot iso (archlinux-2011.10-1-archboot.iso).

  1. Don't just dd the archlinux iso to a usb. Format the USB stick as an MBR FAT drive and dump the entire Archboot ISO contents to it. To be honest, I did this in an Ubuntu vmware image I had on my mac, though I'd like to include command line options for doing this. TODO!

  2. I also stuck the script (included herein) on the drive, but you could get it on the installation image at install time as well via scp or whatever you prefer.

  3. On my x220 I then set the UEFI "BIOS" (the UEFI setup) to boot *ONLY* from UEFI. Pretty important. You should probably also stack your USB drive to top of your startup list or manually select it at boot time.

  4. Boot from the USB stick. For my x220 I selected the second of the four efi grub options, x86_64.

  5. Once Archboot is up, immediately leave the installer (option 8)

  6. You may want to mount the usb drive to /src if you stuck this script on it. Archboot in UEFI mode doesn't seem to mount the usb drive properly (and the normal Archboot efi install will fail as well due to this). I think this is getting fixed in the next Archboot release, from what I've read on BBS.

    # mount /dev/sdb1 /src
  7. Run the script. For me this is

    # /src/myarch.sh

    (WARNING: will nuke everything on /dev/sda unless you've changed it).

There are probably things that could be done better/cleaner, feel free to point those out. This is really just a jumping off point.

UPDATE 15 NOV 2011: This now sources most packages locally to avoid kernel mismatch between install medium and install target.
UPDATE 16 NOV 2011: Script now unified the boot and efi partitions.
UPDATE 17 NOV 2011: Migrated code to github, including two versions (non-encrypted and LUKS-encrypted)
UPDATE 18 NOV 2011: Added encrypted swap
UPDATE 18 NOV 2011: Changed /boot/efi/grub to /boot/grub; removed extraneous /boot/efi directory entirely.
UPDATE 19 NOV 2011: Added a post-install script to handle user setup, etc. No reboot required.
UPDATE 20 NOV 2011: Post install section more complete, visudo automation added.

See code at: https://github.com/altercation/arch-by-hand

Last edited by altercation (2011-11-20 21:09:33)


Ethan Schoonover
Precision Colors - http://ethanschoonover.com/solarized

Offline

#2 2011-11-09 11:05:08

esc
Member
Registered: 2011-10-23
Posts: 8

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

I will try it out in a couple of weeks. (After my final exams) Thank you so much!

Offline

#3 2011-11-10 16:39:07

@op
Member
Registered: 2011-04-05
Posts: 49

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

Hi, I've got the same laptop and I'm stuck at running archboot in UEFI Only mode.
I've burned the iso onto disc, booted from usb-optical drive and I can't get further the grub menu. After selecting the second entry the screen turns black and nothing happens. Any ideas?

Offline

#4 2011-11-14 16:53:25

fiddlinmacx
Member
Registered: 2011-03-02
Posts: 89

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

Wow. It's nice to see this all in one place. I've got a UEFI-enabled Dell Latitude E6410 that I'm trying to get running using GPT and UEFI (just because I can ;-)
I've followed all the instructions, and am still getting a "No bootable devices" message.
I've entered \EFI\grub\grub.efi in the "BIOS" setup (which should be the equivalent of the efibootmgr line)

Offline

#5 2011-11-14 17:33:10

fiddlinmacx
Member
Registered: 2011-03-02
Posts: 89

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

Also, maybe you should generalize the script a bit to accomodate i386 machines instead of just x86_64
+ any 'modprobe' lines using the Arch net-install iso will fail because the kernel of the installer doesn't match that in the chroot environment.

Offline

#6 2011-11-14 18:52:52

altercation
Member
From: Seattle
Registered: 2011-05-15
Posts: 136
Website

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

@op wrote:

Hi, I've got the same laptop and I'm stuck at running archboot in UEFI Only mode.
I've burned the iso onto disc, booted from usb-optical drive and I can't get further the grub menu. After selecting the second entry the screen turns black and nothing happens. Any ideas?

I didn't use a disc, I used a usb stick, fwiw, but it shouldn't make a difference as long as you can see the efi directory on the disc root. Are you sure that BIOS is set to boot UEFI first? If so, my guess is that it is actually working fine. There can be a 30 second to 1 minute pause during UEFI boot off archboot ISO in my experience (pretty sure it's udev related). Note that my UEFI install boots lightning quick, this is only an issue booting off archboot ISO.

Have you tried waiting a couple minutes after the grub selection? See if it's just udev timing out.


Ethan Schoonover
Precision Colors - http://ethanschoonover.com/solarized

Offline

#7 2011-11-14 18:54:24

altercation
Member
From: Seattle
Registered: 2011-05-15
Posts: 136
Website

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

fiddlinmacx wrote:

Wow. It's nice to see this all in one place. I've got a UEFI-enabled Dell Latitude E6410 that I'm trying to get running using GPT and UEFI (just because I can ;-)
I've followed all the instructions, and am still getting a "No bootable devices" message.
I've entered \EFI\grub\grub.efi in the "BIOS" setup (which should be the equivalent of the efibootmgr line)

I would be hesitant to assume any equivalencies when it comes to EFI. I haven't looked deeply into efibootmgr, but I would try to use it before setting anything directly in the EFI BIOS config.


Ethan Schoonover
Precision Colors - http://ethanschoonover.com/solarized

Offline

#8 2011-11-14 18:56:49

altercation
Member
From: Seattle
Registered: 2011-05-15
Posts: 136
Website

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

fiddlinmacx wrote:

Also, maybe you should generalize the script a bit to accomodate i386 machines instead of just x86_64
+ any 'modprobe' lines using the Arch net-install iso will fail because the kernel of the installer doesn't match that in the chroot environment.

I haven't tried using this with Arch net-install at all. If I remember correctly, the normal target drive in that case won't be /dev/sda either. I'd recommend using the archboot ISO for this if possible. Is there a reason you prefer the arch net-install ISO?


Ethan Schoonover
Precision Colors - http://ethanschoonover.com/solarized

Offline

#9 2011-11-14 20:35:39

fiddlinmacx
Member
Registered: 2011-03-02
Posts: 89

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

line 93, char 32 should not be there

resolve.conf ;-)

Offline

#10 2011-11-14 20:47:04

altercation
Member
From: Seattle
Registered: 2011-05-15
Posts: 136
Website

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

fiddlinmacx wrote:

line 93, char 32 should not be there

resolve.conf ;-)

nice catch, thanks. i thought about just githubbing this but figured no one would/should use it as is. still, might be worth while if it grows in order to do bug fixes.


Ethan Schoonover
Precision Colors - http://ethanschoonover.com/solarized

Offline

#11 2011-11-15 13:40:03

fiddlinmacx
Member
Registered: 2011-03-02
Posts: 89

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

altercation wrote:
fiddlinmacx wrote:

Also, maybe you should generalize the script a bit to accomodate i386 machines instead of just x86_64
+ any 'modprobe' lines using the Arch net-install iso will fail because the kernel of the installer doesn't match that in the chroot environment.

I haven't tried using this with Arch net-install at all. If I remember correctly, the normal target drive in that case won't be /dev/sda either. I'd recommend using the archboot ISO for this if possible. Is there a reason you prefer the arch net-install ISO?

I like the net-install because it gives an updated arch when it's done but, I guess, that's no different than updating after reboot. Also, when testing something like this, net-install causes you to have to download the install packages over and over. I'll download the archboot iso ;-)

Offline

#12 2011-11-15 13:41:24

fiddlinmacx
Member
Registered: 2011-03-02
Posts: 89

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

altercation wrote:
fiddlinmacx wrote:

line 93, char 32 should not be there

resolve.conf ;-)

nice catch, thanks. i thought about just githubbing this but figured no one would/should use it as is. still, might be worth while if it grows in order to do bug fixes.

The script is short enough that mod's can be made on the fly easily enough. I really like having it available in a blog post. It's accessible.

Offline

#13 2011-11-15 13:53:03

fiddlinmacx
Member
Registered: 2011-03-02
Posts: 89

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

Another thing ;-)
If pacman needs updating (and it almost certainly will) the script install of gptfdisk will fail.

Offline

#14 2011-11-15 14:01:30

fiddlinmacx
Member
Registered: 2011-03-02
Posts: 89

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

And, you know what, because your script doesn't just install the files from the iso, but actually updates pacman and installs all updated arch packages, you'll have the same problem with modprobe in the chroot environment. You have a different kernel on the iso than in the chroot. The modules needed to run 'efibootmgr' won't load.

Offline

#15 2011-11-15 14:44:13

fiddlinmacx
Member
Registered: 2011-03-02
Posts: 89

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

You could set up the disks, run /arch/setup having instructed the user to exit before the grub install and then complete the process.

Offline

#16 2011-11-15 15:49:00

fiddlinmacx
Member
Registered: 2011-03-02
Posts: 89

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

I've come up with this script (although it's not quite right either):

#!/bin/bash

# prereqs:
# --------------------
# mount /dev/sdb1 /src

set -o nounset
#set -o errexit

INSTALL_TARGET="/mnt"
HR="--------------------------------------------------------------------------------"

# ------------------------------------------------------------------------
# Initialize
# ------------------------------------------------------------------------

# Warn
# ------------------------------------------------------------------------
timer=9
echo -n "This procedure will completely format /dev/sda. Please cancel with ctrl-c to cancel within $timer seconds..."
while [[ $timer -gt 0 ]]
do
	sleep 1
	let timer-=1
	echo -en "$timer seconds..."
done

echo "Starting"

# ------------------------------------------------------------------------
# Configure_Host
# ------------------------------------------------------------------------

echo -e "\nFormatting disk...\n$HR"

# disk prep
sgdisk -Z /dev/sda # zap all on disk
sgdisk -a 2048 -o /dev/sda # new gpt disk 2048 alignment

# create partitions
sgdisk -n 1:0:+250M /dev/sda # partition 1 (UEFI BOOT), default start block, 250MB
sgdisk -n 2:0:+2G /dev/sda # partition 2 (SWAP), default start block, 2G
sgdisk -n 3:0:+100M /dev/sda # partition3, (BOOT), boot partition
sgdisk -n 4:0:+10G /dev/sda # partition 4, (ARCH), default start, remaining space
sgdisk -n 5:0:0 /dev/sda # partition 5, (HOME)

# set partition types
sgdisk -t 1:ef00 /dev/sda
sgdisk -t 2:8200 /dev/sda
sgdisk -t 3:8300 /dev/sda
sgdisk -t 4:8300 /dev/sda
sgdisk -t 5:8300 /dev/sda

# label partitions
sgdisk -c 1:"UEFI BOOT" /dev/sda
sgdisk -c 2:"SWAP" /dev/sda
sgdisk -c 3:"BOOT" /dev/sda
sgdisk -c 4:"ARCH" /dev/sda
sgdisk -c 5:"HOME" /dev/sda

# make filesystems
echo -e "\nCreating Filesystems...\n$HR"
mkfs.vfat /dev/sda1
mkswap /dev/sda2
mkfs.ext2 /dev/sda3
mkfs.ext4 /dev/sda4
mkfs.ext4 /dev/sda5

# Run /arch/setup
# -----------------------------------------------------------------------
echo -n "Don't select Grub as your bootloader and exit setup before the Install Bootloader step"
/arch/setup

# unmount filesytems
umount /dev/sda1
swapoff /dev/sda2
umount /dev/sda3
umount /dev/sda5

# Get Network
# ------------------------------------------------------------------------
echo -n "Waiting for network address.."
#dhclient eth0
dhcpcd -p eth0
echo -n "Network address acquired."

# Update Pacman
# ------------------------------------------------------------------------
echo -e "\nUpdating pacman...\n$HR"
sed -i "s/^#S/S/" /etc/pacman.d/mirrorlist
pacman --noconfirm -Sy
pacman --noconfirm --needed -S pacman
pacman --noconfirm -S gptfdisk btrfs-progs-unstable

# ------------------------------------------------------------------------
# Prepare to chroot to target
# ------------------------------------------------------------------------

mv ${INSTALL_TARGET}/etc/resolv.conf ${INSTALL_TARGET}/etc/resolv.conf.orig
cp /etc/resolv.conf ${INSTALL_TARGET}/etc/resolv.conf
sed -i "s/^#S/S/" ${INSTALL_TARGET}/etc/pacman.d/mirrorlist
mount -t proc proc ${INSTALL_TARGET}/proc
mount -t sysfs sys ${INSTALL_TARGET}/sys
mount -o bind /dev ${INSTALL_TARGET}/dev
echo -e "${HR}\nINSTALL BASE COMPLETE\n${HR}"

# ------------------------------------------------------------------------
# Write Files
# ------------------------------------------------------------------------

# install_efi (to be run *after* chroot /install)
# ------------------------------------------------------------------------
touch ${INSTALL_TARGET}/install_efi
chmod a+x ${INSTALL_TARGET}/install_efi
cat > ${INSTALL_TARGET}/install_efi <<EFIEOF
mount /boot
mount /boot/efi
modprobe efivars
modprobe dm-mod

pacman --noconfirm -Sy
pacman --noconfirm --needed -S pacman
pacman --noconfirm -R grub
pacman --noconfirm -S grub2-efi-i386
grub_efi_i386-install --root-directory=/boot/efi --boot-directory=/boot/efi/efi --bootloader-id=grub --no-floppy --recheck
efibootmgr --create --gpt --disk /dev/sda --part 1 --write-signature --label "ARCH LINUX" --loader "\\EFI\\grub\\grub.efi"
grub-mkconfig -o /boot/efi/efi/grub/grub.cfg

exit
EFIEOF


# ------------------------------------------------------------------------
# Install EFI
# ------------------------------------------------------------------------
chroot /install /install_efi
rm /install/install_efi

Offline

#17 2011-11-15 19:11:56

altercation
Member
From: Seattle
Registered: 2011-05-15
Posts: 136
Website

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

fiddlinmacx wrote:

And, you know what, because your script doesn't just install the files from the iso, but actually updates pacman and installs all updated arch packages, you'll have the same problem with modprobe in the chroot environment. You have a different kernel on the iso than in the chroot. The modules needed to run 'efibootmgr' won't load.

The thing is, I don't have any problem, it works a treat here. The point of using Archboot iso is to use the correct kernel at boot time so that modprobing efivars works. Perhaps I'm misunderstanding what you're trying to do.

Regarding net install, if you look at the script the result is identical to a normal Arch net-install. I'm not using any of the on disk packages, it's all pulled down from the repositories live, just like a net install.

Also, maybe edit your messages instead of posting so many sequentially, it's easier to reply to.

Last edited by altercation (2011-11-15 19:14:39)


Ethan Schoonover
Precision Colors - http://ethanschoonover.com/solarized

Offline

#18 2011-11-15 19:46:49

spoked
Member
Registered: 2011-09-03
Posts: 30

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

Today, I've been trying to reinstall my laptop to luks encrypt my root filesystem. I was previously able to install archboot (2011 R5) using UEFI + GPT partitioning. Now I'm using 2011 R6  and following along the lines of your script to go over the necessary steps. I'm having a problem doing the 'modprobe efivars' step also, and the error I am getting seems to be that it's look for the modules in /lib/modules/3.0-ARCH while the installed kernel is 3.1.1-ARCH. I have tried symbolic linking /lib/modules/3.1.1-ARCH to /lib/modules/3.0-ARCH but with efivars I am getting another error. The module header seems to specify that it is for 3.0 and not accepting it for 3.1.1

Is this the problem other people here seem to be having? Any clues how to fix this?

Offline

#19 2011-11-15 20:09:22

altercation
Member
From: Seattle
Registered: 2011-05-15
Posts: 136
Website

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

spoked wrote:

Today, I've been trying to reinstall my laptop to luks encrypt my root filesystem. I was previously able to install archboot (2011 R5) using UEFI + GPT partitioning. Now I'm using 2011 R6  and following along the lines of your script to go over the necessary steps. I'm having a problem doing the 'modprobe efivars' step also, and the error I am getting seems to be that it's look for the modules in /lib/modules/3.0-ARCH while the installed kernel is 3.1.1-ARCH. I have tried symbolic linking /lib/modules/3.1.1-ARCH to /lib/modules/3.0-ARCH but with efivars I am getting another error. The module header seems to specify that it is for 3.0 and not accepting it for 3.1.1

Is this the problem other people here seem to be having? Any clues how to fix this?

First, I'm pretty sure Archboot R5 is out of date and you want R6. Try that.

One note is that I can only modbrobe efivars after chrooting to the install root.


Ethan Schoonover
Precision Colors - http://ethanschoonover.com/solarized

Offline

#20 2011-11-15 20:17:54

spoked
Member
Registered: 2011-09-03
Posts: 30

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

I am using R6.

From what I've found, the installer is downloading linux-3.1.1 and linux-api-headers-3.0.1 from the core repo. linux-api-headers-3.0.1 has been flagged out of date a couple of days ago. https://www.archlinux.org/packages/core … i-headers/

Offline

#21 2011-11-15 20:19:22

altercation
Member
From: Seattle
Registered: 2011-05-15
Posts: 136
Website

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

spoked wrote:

I am using R6.

From what I've found, the installer is downloading linux-3.1.1 and linux-api-headers-3.0.1 from the core repo. linux-api-headers-3.0.1 has been flagged out of date a couple of days ago. https://www.archlinux.org/packages/core … i-headers/

Ah, yes, you noted that, sorry. I'll do a test here with the current 3.1.1 and see how things fare.

**EDIT**
Have you tried sourcing from testing instead of core?

Last edited by altercation (2011-11-15 20:21:44)


Ethan Schoonover
Precision Colors - http://ethanschoonover.com/solarized

Offline

#22 2011-11-15 20:36:29

altercation
Member
From: Seattle
Registered: 2011-05-15
Posts: 136
Website

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

Ok, I can reproduce here. Not only that, but I generate a boatload of GPGME errors during install. I suspect @spoked is on the right track in terms of the problem.

Last edited by altercation (2011-11-15 20:43:36)


Ethan Schoonover
Precision Colors - http://ethanschoonover.com/solarized

Offline

#23 2011-11-15 20:44:42

spoked
Member
Registered: 2011-09-03
Posts: 30

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

altercation wrote:
spoked wrote:

I am using R6.

From what I've found, the installer is downloading linux-3.1.1 and linux-api-headers-3.0.1 from the core repo. linux-api-headers-3.0.1 has been flagged out of date a couple of days ago. https://www.archlinux.org/packages/core … i-headers/

Ah, yes, you noted that, sorry. I'll do a test here with the current 3.1.1 and see how things fare.

**EDIT**
Have you tried sourcing from testing instead of core?

For the complete install, no. I have tried adding the testing repo once chrooted into the installed system. This changes nothing with kernel packages. I have searched the repos for linux-api-headers-3.1.1 and have found nothing yet.

Offline

#24 2011-11-15 21:00:23

altercation
Member
From: Seattle
Registered: 2011-05-15
Posts: 136
Website

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

spoked wrote:

I am using R6.
For the complete install, no. I have tried adding the testing repo once chrooted into the installed system. This changes nothing with kernel packages. I have searched the repos for linux-api-headers-3.1.1 and have found nothing yet.

I think that's the only relevant point to add testing, so it seems you've covered most of the bases. I see the 3.1.1 headers in the web view of packages list, but I'm not sure if that's polling a repo live or if it's an uncoupled listing. I assume it's polling the archlinux.org repo. I'm going to run through an install off that (throttled) repo and see how things go.

EDIT:
I'm thinking that I'll try to do a local install off of archboot to see how things fare.

Last edited by altercation (2011-11-16 00:05:51)


Ethan Schoonover
Precision Colors - http://ethanschoonover.com/solarized

Offline

#25 2011-11-16 00:59:40

altercation
Member
From: Seattle
Registered: 2011-05-15
Posts: 136
Website

Re: "Arch By Hand" UEFI GPT SSD LUKS Install Script

Success. The short solution to the current kernel version mismatch is just to install using the local file repository.

I'll work on modifying the script to handle this, but for now you can do it easily enough.

Run through the script but stop/exit before mounting the new partitions.

run /arch/setup, mount the swap and / root partitions (NOT the efi boot partition in /dev/sda1) and install from local file repository.

Don't install bootloader. Exit the install and start the script commands (manually is probably easiest) at the proc/sysfs/dev mounts.

I just reinstalled my system this way, no problems. I'll detail more in a bit.


Ethan Schoonover
Precision Colors - http://ethanschoonover.com/solarized

Offline

Board footer

Powered by FluxBB