Add EFI support

This commit is contained in:
Fierelier 2022-08-15 08:31:02 +02:00
parent 03737e992c
commit 26600b2aa5
8 changed files with 56 additions and 93 deletions

View File

@ -4,13 +4,12 @@ Devuan Linux for Windows users
<a href="assets/screenshot.png" target="_blank"><img src="assets/screenshot.png" width="360" title="Screenshot"></a>
# TO-DO
- EFI support
- More complex setup
# How to "build"
## Prerequisites
- You need to use Devuan or windvn
- `apt install debootstrap isolinux syslinux-common squashfs-tools xorriso`
- `apt install debootstrap grub-common grub-pc-bin grub-efi-ia32-bin grub-efi-amd64-bin mtools squashfs-tools xorriso`
---
1. **Get into the windvn environment:**
```

View File

@ -1,2 +1,2 @@
#!/bin/bash
export WDVN_PACKAGES="$WDVN_PACKAGES grub2"
export WDVN_PACKAGES="$WDVN_PACKAGES grub2 grub-efi-ia32-bin grub-efi-amd64-bin"

View File

@ -39,46 +39,40 @@ while true; do
(
set -e
dpkg-reconfigure keyboard-configuration
service keyboard-setup.sh restart
udevadm trigger --subsystem-match=input --action=change
service keyboard-setup.sh restart
lsblk
read -p "Device (ALL DATA WILL BE ERASED): " DEVICE
# Create partitions
echo "Creating partitions ..."
(
echo o
echo n
echo e
echo
echo
echo +256M
echo t
echo swap
echo n
echo p
echo
echo
echo
echo t
echo
echo linux
echo w
echo
echo
) | fdisk "$DEVICE"
wipefs --all "$DEVICE"
sgdisk -n 1::+1M -c 1:"BIOS boot partition" -t 1:ef02 "$DEVICE"
sgdisk -n 2::+250M -c 2:"EFI System" -t 2:ef00 "$DEVICE"
sgdisk -n 3::-0 -c 3:"Linux filesystem" -t 3:8300 "$DEVICE"
sgdisk --hybrid=1:2:3 "$DEVICE"
PART_EFI="$(echo "${DEVICE}"*2)"
PART_DATA="$(echo "${DEVICE}"*3)"
# Format partitions
echo "Formatting partitions ..."
mkswap "${DEVICE}1"
swapon "${DEVICE}1"
mkfs.ext4 "${DEVICE}2"
mkfs.fat -F32 "$PART_EFI"
mkfs.ext4 "$PART_DATA"
# Mount target partition
echo "Mounting partitions ..."
mkdir -p "/media/install"
mount "${DEVICE}2" "/media/install"
mount "$PART_DATA" "/media/install"
mkdir -p "/media/install/efi"
mount "$PART_EFI" "/media/install/efi"
# Creating swap
echo "Creating swap ..."
fallocate -l 512M "/media/install/swap"
chmod 600 "/media/install/swap"
mkswap "/media/install/swap"
swapon "/media/install/swap"
# Add files
echo "Adding files ..."
@ -86,8 +80,8 @@ while true; do
# Write fstab
echo "Writing fstab ..."
echo "UUID=$(blkid -o value -s UUID "${DEVICE}1") none swap sw 0 0" >"/media/install/etc/fstab"
echo "UUID=$(blkid -o value -s UUID "${DEVICE}2") / ext4 errors=remount-ro 0 1" >>"/media/install/etc/fstab"
echo "UUID=$(blkid -o value -s UUID "$PART_DATA") / ext4 errors=remount-ro 0 1" >>"/media/install/etc/fstab"
echo "/swap none swap sw 0 0" >>"/media/install/etc/fstab"
# Remove live-specific packages
echo "Removing live-specific packages ..."
@ -97,13 +91,17 @@ while true; do
# Install GRUB
echo "Installing grub ..."
#echo "GRUB_DISABLE_OS_PROBER=true" >>"/media/install/etc/default/grub"
wdvn-chroot "/media/install" grub-install --boot-directory="/boot" --modules=part_msdos "$DEVICE"
wdvn-chroot "/media/install" grub-install --target=i386-efi --uefi-secure-boot --efi-directory="/efi" --boot-directory="/boot" "$DEVICE"
wdvn-chroot "/media/install" grub-install --target=x86_64-efi --uefi-secure-boot --efi-directory="/efi" --boot-directory="/boot" "$DEVICE"
wdvn-chroot "/media/install" grub-install --target=i386-pc --boot-directory="/boot" "$DEVICE"
wdvn-chroot "/media/install" update-grub
#sed -i 's/GRUB_DISABLE_OS_PROBER=true/# GRUB_DISABLE_OS_PROBER=true/' "/media/install/etc/default/grub"
# Unmount
echo "Unmounting ..."
swapoff "/media/install/swap"
umount -l "/media/install/efi"
rmdir "/media/install/efi"
umount -l "/media/install"
rmdir "/media/install"
@ -112,6 +110,8 @@ while true; do
)
if [ "$?" != "0" ]; then
echo ERROR. Cleaning up...
swapoff "/media/install/swap"
umount -l "/media/install/efi"
umount -l "/media/install"
echo An error occured.
read

View File

@ -1,4 +1,4 @@
#!/bin/bash
export WDVN_PACKAGES="$WDVN_PACKAGES squashfs-tools"
export WDVN_REMOVE="$WDVN_REMOVE squashfs-tools"
export WDVN_PACKAGES="$WDVN_PACKAGES gdisk dosfstools squashfs-tools"
export WDVN_REMOVE="$WDVN_REMOVE dosfstools squashfs-tools"
cp "$1/bin/login" "$1/bin/login.oobe"

View File

@ -11,9 +11,9 @@ while true; do
if [ "$CHOICE" == "1" ]; then
dpkg-reconfigure keyboard-configuration
service keyboard-setup.sh restart
udevadm trigger --subsystem-match=input --action=change
apt -y install console-setup locales tzdata
service keyboard-setup.sh restart
apt -y install locales tzdata
dpkg-reconfigure locales
dpkg-reconfigure tzdata
groupadd -f sudo

View File

@ -8,6 +8,7 @@ apt -y upgrade
apt -y install $WDVN_PACKAGES_INTERACTIVE
export DEBIAN_FRONTEND="noninteractive"
apt -y install $WDVN_PACKAGES
update-rc.d keyboard-setup.sh defaults
apt -y install --download-only $WDVN_PACKAGES_DL
unset DEBIAN_FRONTEND
apt -y autoclean

View File

@ -1,5 +1,4 @@
#!/bin/bash
set -e
update-rc.d keyboard-setup.sh
apt -y update
apt -y upgrade

View File

@ -10,16 +10,6 @@ if [ -d "$IMAGE" ]; then
fi
EXIT=0
if [ ! -d "/usr/lib/ISOLINUX" ]; then
echo "ERROR: /usr/lib/ISOLINUX not found. Run 'apt install isolinux'."
EXIT=1
fi
if [ ! -d "/usr/lib/syslinux" ]; then
echo "ERROR: /usr/lib/syslinux not found. Run 'apt install syslinux-common'."
EXIT=1
fi
if [ ! -d "$CHROOT/lib/live/boot" ]; then
echo "ERROR: /lib/live/boot not found within chroot. On your chroot, run 'apt install live-boot'."
EXIT=1
@ -32,7 +22,7 @@ fi
if ! command -v mksquashfs &> /dev/null
then
echo "ERROR: xorriso not found. Run 'apt install squashfs-tools'."
echo "ERROR: mksquashfs not found. Run 'apt install squashfs-tools'."
EXIT=1
fi
@ -42,6 +32,11 @@ then
EXIT=1
fi
if ! command -v grub-mkrescue &> /dev/null
then
echo "ERROR: grub-mkrescue not found. Run 'apt install grub-common'."
EXIT=1
fi
if [ -f "$2" ]; then
echo "ERROR: $2 already exists."
@ -54,55 +49,24 @@ fi
mkdir -p "$IMAGE"
mkdir -p "$IMAGE/live"
mkdir -p "$IMAGE/isolinux"
mkdir -p "$IMAGE/boot/grub"
cp -fv "$CHROOT/boot"/vmlinuz-* "$IMAGE/live/vmlinuz"
cp -fv "$CHROOT/boot"/initrd.img-* "$IMAGE/live/initrd.img"
mksquashfs "$CHROOT" "$IMAGE/live/filesystem.squashfs"
#mksquashfs -comp zstd -Xcompression-level 22 "$CHROOT" "$IMAGE/live/filesystem.squashfs"
echo "UI menu.c32
echo "GRUB_TERMINAL=console
MENU TITLE $WDVN_NAME $WDVN_ARCH $WDVN_VER $WDVN_DATE live
TIMEOUT 600
menuentry '$WDVN_NAME $WDVN_ARCH $WDVN_VER $WDVN_DATE live' --class gnu-linux --id linux {
insmod all_video
echo "Loading Linux ..."
linux /live/vmlinuz boot=live noautologin quiet
echo "Loading initrd ..."
initrd /live/initrd.img
}
" > "$IMAGE/boot/grub/grub.cfg"
LABEL linux
MENU LABEL Linux
KERNEL /live/vmlinuz
APPEND initrd=/live/initrd.img boot=live noautologin quiet
grub-mkrescue -o "$2" "$IMAGE"
LABEL linux-nomodeset
MENU LABEL Linux (nomodeset)
KERNEL /live/vmlinuz
APPEND initrd=/live/initrd.img boot=live noautologin quiet nomodeset
LABEL linux-debug
MENU LABEL Linux (nomodeset, not quiet)
KERNEL /live/vmlinuz
APPEND initrd=/live/initrd.img boot=live noautologin nomodeset
" > "$IMAGE/isolinux/isolinux.cfg"
cp /usr/lib/ISOLINUX/isolinux.bin "$IMAGE/isolinux/"
cp /usr/lib/syslinux/modules/bios/* "$IMAGE/isolinux/"
xorriso \
-as mkisofs \
-iso-level 3 \
-full-iso9660-filenames \
-volid "$DISC_NAME" \
-output "$2" \
-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
-eltorito-boot \
isolinux/isolinux.bin \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
--eltorito-catalog isolinux/isolinux.cat \
"$IMAGE"
# -eltorito-alt-boot \
# -e /EFI/boot/efiboot.img \
# -no-emul-boot \
# -isohybrid-gpt-basdat \
# -append_partition 2 0xef EFI/boot/efiboot.img \
rm -r "$IMAGE"
rm -r "$IMAGE"