Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: uefi_fix
Fetching contributors…

Cannot retrieve contributors at this time

file 128 lines (104 sloc) 5.589 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
if [ -d /repo/core ]; then
    # you're not supposed to mix old core snapshot with current extra, but i don't see any problems for now, this goes faster.
    # we need extra for grub2
    TARGET_REPOSITORIES=(core 'file:///repo/$repo/$arch' extra 'ftp://mirrors.kernel.org/archlinux/$repo/os/$arch')
else
    MIRROR='ftp://mirrors.kernel.org/archlinux/$repo/os/$arch'
    TARGET_REPOSITORIES=(core $var_MIRRORLIST extra $var_MIRRORLIST)
fi

ssd_dev=$(fdisk -l 2>/dev/null | grep -F '160.0 GB' | cut -d' ' -f2 | sed 's/:$//')

RUNTIME_REPOSITORIES=
RUNTIME_PACKAGES='grub2-efi-x86_64 gptfdisk'
TARGET_GROUPS=base
TARGET_PACKAGES_EXCLUDE='reiserfsprogs grub'
TARGET_PACKAGES='openssh e2fsprogs cryptsetup lvm2 grub2-efi-x86_64 xfsprogs htop git vim zsh sudo'

# handy functions taken from arch-by-hand
SetValue () {
# EXAMPLE: SetValue VARIABLENAME '\"Quoted Value\"' /file/path
VALUENAME="$1" NEWVALUE="$2" FILEPATH="$3"
sed -i "s+^#\?\(${VALUENAME}\)=.*$+\1=${NEWVALUE}+" "${FILEPATH}"
}

CommentOutValue () {
VALUENAME="$1" FILEPATH="$2"
sed -i "s/^\(${VALUENAME}.*\)$/#\1/" "${FILEPATH}"
}

UncommentValue () {
VALUENAME="$1" FILEPATH="$2"
sed -i "s/^#\(${VALUENAME}.*\)$/\1/" "${FILEPATH}"
}

worker_intro () {
inform "Installing to $ssd_dev .. You have 10 seconds to press Ctrl-C"
sleep 10
}

worker_sysprep () {
mount -o remount,rw / &>/dev/null

if [[ "$(cat "/sys/class/dmi/id/sys_vendor")" == 'Apple Inc.' ]] || [[ "$(cat "/sys/class/dmi/id/sys_vendor")" == 'Apple Computer, Inc.' ]]; then
modprobe -r -q efivars || true
else
modprobe -q efivars
fi

modprobe -q dm-mod
pacman -Rsdd --noconfirm grub # avoid conflicts with grub2, note that grub is marked as dep for aif
}

worker_runtime_network () {
dhcpcd -k eth0 2>/dev/null
dhcpcd eth0
}

worker_configure_system () {
preconfigure_target
sed -i 's/^HOSTNAME="myhost"/HOSTNAME="dieter-t420s"/' $var_TARGET_DIR/etc/rc.conf
SetValue MODULES '\\"dm_mod dm_crypt aes_x86_64 ext2 ext4 vfat intel_agp drm i915\\"' $var_TARGET_DIR/etc/mkinitcpio.conf
SetValue HOOKS '\\"base udev pata scsi sata usb usbinput keymap consolefont encrypt lvm2 filesystems fsck\\"' $var_TARGET_DIR/etc/mkinitcpio.conf
SetValue KEYMAP 'dvorak' $var_TARGET_DIR/etc/rc.conf
postconfigure_target
}

process_disks () {
sgdisk -Z $ssd_dev # zap all on disk
sgdisk -a 2048 -o $ssd_dev # new gpt disk 2048 alignment

# create partitions
sgdisk -n 1:0:+200M $ssd_dev # partition 1 (UEFI SYS), default start block, 200MB
sgdisk -n 2:0:+200M $ssd_dev # partition 2 (BOOT), default start block, 200MB
sgdisk -n 3:0:0 $ssd_dev # partition 3, (LUKS), default start, remaining space

# set partition types
sgdisk -t 1:ef00 $ssd_dev
sgdisk -t 2:8300 $ssd_dev
sgdisk -t 3:8300 $ssd_dev

# label partitions
sgdisk -c 1:"UEFI System" $ssd_dev
sgdisk -c 2:"Boot" $ssd_dev
sgdisk -c 3:"LUKS" $ssd_dev
}

worker_install_bootloader () {
mkdir -p $var_TARGET_DIR/boot/efi/EFI || return 1
SetValue GRUB_CMDLINE_LINUX '\"root=/dev/mapper/cryptpool-root cryptdevice=/dev/sda3:sda3crypt:allow-discards ro add_efi_memmap i915.modeset=1 i915.i915_enable_rc6=1 i915.i915_enable_fbc=1 i915.lvds_downclock=1 pcie_aspm=force quiet\"' $var_TARGET_DIR/etc/default/grub
SetValue GRUB_TERMINAL_OUTPUT gfxterm $var_TARGET_DIR/etc/default/grub
SetValue GRUB_GFXMODE 960x600x32,auto $var_TARGET_DIR/etc/default/grub
SetValue GRUB_GFXPAYLOAD_LINUX keep $var_TARGET_DIR/etc/default/grub
target_special_fs on
chroot $var_TARGET_DIR grub-install --directory=/usr/lib/grub/x86_64-efi --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --boot-directory=/boot --recheck --debug &>$var_TARGET_DIR/boot/grub_uefi.log || return 1

cat << EFIBEOF > $var_TARGET_DIR/efibootmgr_run.sh
#!/bin/bash

for _bootnum in \$(efibootmgr | grep '^Boot[0-9]' | fgrep -i 'ARCH LINUX (GRUB2)' | cut -b5-8) ; do
efibootmgr --bootnum "\${_bootnum}" --delete-bootnum
done

## archiso boots by bios, so no efi vars set, so this line won't work. create the entry separately or wait for archiso efi support.
efibootmgr --verbose --create --gpt --disk $ssd_dev --part 1 --write-signature --label 'ARCH LINUX (GRUB2)' --loader '\\EFI\\arch_grub\\grubx64.efi'

EFIBEOF

chmod a+x $var_TARGET_DIR/efibootmgr_run.sh

if [[ "$(cat "/sys/class/dmi/id/sys_vendor")" != 'Apple Inc.' ]] && [[ "$(cat "/sys/class/dmi/id/sys_vendor")" != 'Apple Computer, Inc.' ]]; then
chroot $var_TARGET_DIR /bin/bash /efibootmgr_run.sh || echo "Probably booted in BIOS mode?"
fi

chroot $var_TARGET_DIR grub-mkconfig -o /boot/grub/grub.cfg || return 1
target_special_fs off
}

PARTITIONS="thismustbesetbutwontbeused"
GRUB_DEVICE=$ssd_dev
BLOCKDATA="${ssd_dev}1 raw no_label vfat;yes;/boot/efi;target;no_opts;no_label;-F32
${ssd_dev}2 raw no_label ext3;yes;/boot;target;no_opts;no_label;no_params
${ssd_dev}3 raw no_label dm_crypt;yes;no_mountpoint;target;no_opts;sda3crypt;-c__aes-xts-plain__-y__-s__512__
/dev/mapper/sda3crypt dm_crypt no_label lvm-pv;yes;no_mountpoint;target;no_opts;no_label;no_params
/dev/mapper/sda3crypt+ lvm-pv no_label lvm-vg;yes;no_mountpoint;target;no_opts;cryptpool;/dev/mapper/sda3crypt
/dev/mapper/cryptpool lvm-vg cryptpool lvm-lv;yes;no_mountpoint;target;no_opts;root;15G|lvm-lv;yes;no_mountpoint;target;no_opts;home;15G|lvm-lv;yes;no_mountpoint;target;no_opts;var;5G
/dev/mapper/cryptpool-root lvm-lv no_label ext4;yes;/;target;no_opts;no_label;no_params
/dev/mapper/cryptpool-home lvm-lv no_label ext4;yes;/home;target;no_opts;no_label;no_params
/dev/mapper/cryptpool-var lvm-lv no_label ext4;yes;/var;target;no_opts;no_label;no_params"
Something went wrong with that request. Please try again.