瀏覽代碼

add experimental EFI support

Noah Vogt 2 年之前
父節點
當前提交
1d2e98c0fe
共有 2 個文件被更改,包括 60 次插入7 次删除
  1. 38 3
      arch.sh
  2. 22 4
      chroot.sh

+ 38 - 3
arch.sh

@@ -21,13 +21,45 @@ dialog --defaultno --title "Time Zone select" --yesno "Do you want use the defau
 
 dialog --no-cancel --inputbox "Enter swapsize in gb (only type in numbers)." 10 60 2>swapsize
 
+EFI=$(ls /sys/firmware/efi/efivars)
 SIZE=$(cat swapsize)
 DRIVE=$(cat drive)
 PVALUE=$(echo "${DRIVE}" | grep "^nvme" | sed 's/.*[0-9]/p/')
 
 timedatectl set-ntp true
 
-cat <<EOF | fdisk -W always /dev/"${DRIVE}"
+if [ "$EFI" = "yes" ]; then
+    SWAP_LETTER="2"
+    ROOT_LETTER="3"
+    kat <<EOF | fdisk -W always /dev/"${DRIVE}"
+o
+n
+p
+
+
++1024M
+t
+1
+n
+p
+
+
++${SIZE}G
+t
+2
+19
+n
+
+
+
+w
+EOF
+mkfs.fat -F32 /dev/"${DRIVE}${PVALUE}1"
+
+else
+    cat <<EOF | fdisk -W always /dev/"${DRIVE}"
+    SWAP_LETTER="1"
+    ROOT_LETTER="2"
 o
 n
 p
@@ -45,14 +77,17 @@ a
 2
 w
 EOF
+fi
+
 partprobe
 
 while true; do
-    cryptsetup luksFormat --type luks1 /dev/"${DRIVE}${PVALUE}2" && break
+    cryptsetup luksFormat --type luks1 /dev/"${DRIVE}${PVALUE}${ROOT_LETTER}" &&
+        break
 done
 
 while true; do
-    cryptsetup open /dev/"${DRIVE}${PVALUE}2" cryptroot && break
+    cryptsetup open /dev/"${DRIVE}${PVALUE}${ROOT_LETTER}" cryptroot && break
 done
 
 yes | mkfs.ext4 /dev/mapper/cryptroot

+ 22 - 4
chroot.sh

@@ -21,9 +21,21 @@ locale-gen
 pacman --noconfirm --needed -S networkmanager
 systemctl enable NetworkManager
 
+EFI=$(ls /sys/firmware/efi/efivars)
+
+if [ "$EFI" = "yes" ]; then
+    SWAP_LETTER="2"
+    ROOT_LETTER="3"
+else
+    SWAP_LETTER="1"
+    ROOT_LETTER="2"
+fi
+
+
 dd bs=512 count=4 if=/dev/urandom of=/crypto_keyfile.bin
 while true; do
-    cryptsetup luksAddKey /dev/"${DRIVE}${PVALUE}2" /crypto_keyfile.bin && break
+    cryptsetup luksAddKey /dev/"${DRIVE}${PVALUE}${ROOT_LETTER}" /crypto_keyfile.bin &&
+        break
 done
 chmod 000 /crypto_keyfile.bin
 
@@ -32,12 +44,18 @@ sed -i 's/block filesystems/block encrypt filesystems/' /etc/mkinitcpio.conf
 mkinitcpio -P
 
 pacman --noconfirm --needed -S grub
-sed -i "s/GRUB_CMDLINE_LINUX=\"\"/GRUB_CMDLINE_LINUX=\"cryptdevice=\/dev\/${DRIVE}${PVALUE}2:cryptroot\"/" /etc/default/grub
+sed -i "s/GRUB_CMDLINE_LINUX=\"\"/GRUB_CMDLINE_LINUX=\"cryptdevice=\/dev\/${DRIVE}${PVALUE}${ROOT_LETTER}:cryptroot\"/" /etc/default/grub
 sed -i 's/#GRUB_ENABLE_CRYPTODISK/GRUB_ENABLE_CRYPTODISK/' /etc/default/grub
 
-echo "swap /dev/${DRIVE}${PVALUE}1 /dev/urandom swap,cipher=aes-cbc-essiv:sha256,size=256" >> /etc/crypttab
+echo "swap /dev/${DRIVE}${PVALUE}${SWAP_LETTER} /dev/urandom swap,cipher=aes-cbc-essiv:sha256,size=256" >> /etc/crypttab
 
-grub-install --target=i386-pc /dev/"${DRIVE}" --recheck
+if [ "$EFI" = "yes" ]; then
+    pacman -S grub efibootmgr
+    mkdir /boot/efi
+    mount /dev/"${DRIVE}${PVALUE}1" /boot/efi
+    grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot/efi
+else
+    grub-install --target=i386-pc /dev/"${DRIVE}" --recheck
 grub-mkconfig -o /boot/grub/grub.cfg
 
 rm drive tzfinal.tmp