Skip to content

Commit f51652f

Browse files
committed
1 parent 1c89ca0 commit f51652f

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

bootstrap/roles/appliance-build.bootstrap/tasks/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
ansible.builtin.command: bash -c 'rm -rf /etc/apt/sources.list.d/*'
2020
changed_when: true
2121

22+
- name: Turn off all swap now
23+
become: yes
24+
command: swapoff -a
25+
changed_when: false
26+
2227
- name: Configure apt sources
2328
vars:
2429
mirror_url: "{{ lookup('env', 'DELPHIX_PACKAGE_MIRROR_MAIN') }}"

live-build/config/hooks/vm-artifacts/90-raw-disk-image.binary

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,12 @@ sgdisk "$ARTIFACT_NAME.img" --print
125125
# consumers can easily build the names of the individual partitions as
126126
# needed.
127127
#
128-
LOOPNAME=$(kpartx -asv "$ARTIFACT_NAME.img" |
129-
head -n1 |
130-
awk '{ print $3 }' |
131-
sed 's/^\(loop[0-9]\+\)p[0-9]\+$/\1/')
128+
# LOOPNAME=$(kpartx -asv "$ARTIFACT_NAME.img" |
129+
# head -n1 |
130+
# awk '{ print $3 }' |
131+
# sed 's/^\(loop[0-9]\+\)p[0-9]\+$/\1/')
132+
133+
LOOPNAME=$(losetup --find --partscan --show "$ARTIFACT_NAME.img")
132134

133135
#
134136
# We use a consistent naming scheme for the root filesystems that are
@@ -146,7 +148,7 @@ zpool create -d \
146148
-O compression=on \
147149
-R "$DIRECTORY" \
148150
-t "$FSNAME" \
149-
rpool "/dev/mapper/${LOOPNAME}p1"
151+
rpool "${LOOPNAME}p1"
150152

151153
zfs create \
152154
-o canmount=off \
@@ -293,7 +295,7 @@ mkdir -p "/var/crash"
293295
mount -t zfs "$FSNAME/crashdump" "/var/crash"
294296

295297
# Make the vfat partition
296-
mkfs.vfat -F32 /dev/mapper/${LOOPNAME}p2
298+
mkfs.vfat -F32 ${LOOPNAME}p2
297299

298300
#
299301
# Populate the root filesystem with the contents of the "binary" directory
@@ -345,16 +347,25 @@ for dir in /dev /proc /sys; do
345347
done
346348

347349
#
348-
# Mount /boot/efi and do grub and bootctl install
350+
# Mount ESP and bootctl install
349351
#
350-
EFI_DIR="/mnt/boot/efi"
351-
chroot "$DIRECTORY" mkdir -p $EFI_DIR
352-
chroot "$DIRECTORY" mount /dev/mapper/${LOOPNAME}p2 $EFI_DIR
352+
EFI_DIR=$(chroot "$DIRECTORY" mktemp -d -p "/var/tmp/" -t delphix_efi.XXXXXXX)
353+
chroot "$DIRECTORY" mount -o umask=077 ${LOOPNAME}p2 $EFI_DIR
354+
355+
ESP=$EFI_DIR
356+
BOOTLOADER_ID="${BOOTLOADER_ID:-systemd}"
357+
echo "[*] Installing systemd-boot to $ESP..."
358+
# 1. Create required directories
359+
chroot "$DIRECTORY" mkdir -p "$ESP/EFI/systemd" "$ESP/EFI/BOOT" "$ESP/loader/entries"
360+
361+
# 2. Copy systemd-boot binaries
362+
chroot "$DIRECTORY" cp /usr/lib/systemd/boot/efi/systemd-bootx64.efi "$ESP/EFI/$BOOTLOADER_ID/"
363+
chroot "$DIRECTORY" cp /usr/lib/systemd/boot/efi/systemd-bootx64.efi "$ESP/EFI/BOOT/BOOTX64.EFI"
353364

354365
# Copy the latest kernel into EFI boot directory
355366
chroot "$DIRECTORY" cp /boot/initrd.img $EFI_DIR
356367
chroot "$DIRECTORY" cp /boot/vmlinuz $EFI_DIR
357-
chroot "$DIRECTORY" bootctl --esp-path=$EFI_DIR install --no-variables
368+
# chroot "$DIRECTORY" bootctl --esp-path=$EFI_DIR install --no-variables
358369

359370
# Use GRUB_CMDLINE_LINUX_DEFAULT boot options
360371
source $DIRECTORY/etc/default/grub.d/override.cfg
@@ -385,6 +396,7 @@ auto-firmware yes
385396
EOF
386397

387398
chroot "$DIRECTORY" umount $EFI_DIR
399+
chroot "$DIRECTORY" rm -r $EFI_DIR
388400

389401
for dir in /dev /proc /sys; do
390402
retry 5 10 umount -R "${DIRECTORY}${dir}"
@@ -398,4 +410,5 @@ umount "$DIRECTORY/var/tmp"
398410
umount "/var/crash"
399411
retry 5 10 zfs umount "$FSNAME/ROOT/$FSNAME/root"
400412
retry 5 10 zpool export "$FSNAME"
401-
kpartx -d "$ARTIFACT_NAME.img"
413+
# kpartx -d "$ARTIFACT_NAME.img"
414+
losetup -d $LOOPNAME

0 commit comments

Comments
 (0)