Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native version #63

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion autoinstall/start-autoinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
set -x
set -e

if [ -z "$OVMF_PATH" ]
then
OVMF_PATH=/usr/share/qemu/OVMF.fd
fi

# 25G -> https://bugs.launchpad.net/subiquity/+bug/1907128
qemu-img create -f qcow2 disk.img 50G
wget -c -O ubuntu.iso https://old-releases.ubuntu.com/releases/jammy/ubuntu-22.04.2-live-server-amd64.iso
Expand All @@ -15,4 +20,4 @@ trap 'kill $HTTP_SRV_PID' EXIT
# Make contestant-vm available
tar czvf contestant-vm.tar.gz --exclude autoinstall --exclude .git --exclude .github -C ../.. contestant-vm

qemu-system-x86_64 -display gtk -hda disk.img -cdrom ubuntu.iso -m 2048 -net nic -net user -cpu host -machine accel=kvm -smbios type=1,serial=ds='nocloud-net;s=http://10.0.2.2:8000/'
qemu-system-x86_64 -display gtk -hda disk.img -cdrom ubuntu.iso -m 2048 -net nic -net user -cpu host -machine accel=kvm -smbios type=1,serial=ds='nocloud-net;s=http://10.0.2.2:8000/' -bios "$OVMF_PATH"
7 changes: 4 additions & 3 deletions autoinstall/user-data
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ autoinstall:
dhcp4: yes
storage:
layout:
name: direct #lvm
name: lvm
identity:
hostname: ioi-0804
hostname: ioi-0809
username: ansible
# ansible DO CHANGE!
# Note: the real password will be ANSIBLE_PASSWORD
# ansible
password: $6$NH0tTrHw/4v3.Jbi$6NCVzJ45i3N4HFF1vJpPobpdkGhgBq0t56KAGzjm4/wg1saD8N7akmBMaLbSH.UmpIdmZV8TUaqN2/pDaSSS0.
ssh:
install-server: yes
Expand Down
47 changes: 3 additions & 44 deletions setup.d/40-boot-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,10 @@ set -e
sed -i '/GRUB_CMDLINE_LINUX_DEFAULT/ s/splash//' /etc/default/grub
update-grub2

echo "boot-setup: works, but disabled due to inconveniences"
echo "- snapshot can be found by Ubuntu's sidebar, which is annoying"
echo "- Rethink logic:"
echo " - is 15 sec enough?"
exit 0

VG="ubuntu-vg"
ORIGIN_LV="ubuntu-lv"
SNAPSHOT_LV="ubuntu-snapshot"

cat <<EOM >/etc/initramfs-tools/hooks/zerofree
#!/bin/sh
PREREQ=""
prereqs()
{
echo "\$PREREQ"
}

case \$1 in
prereqs)
prereqs
exit 0
;;
esac

. /usr/share/initramfs-tools/hook-functions

if [ ! -x "/sbin/zerofree" ]; then
exit 1
fi

copy_exec /sbin/zerofree /sbin
exit 0
EOM
chmod 755 /etc/initramfs-tools/hooks/zerofree

cat <<EOM >/etc/initramfs-tools/scripts/local-premount/prompt
#!/bin/sh
PREREQ="lvm"
Expand Down Expand Up @@ -119,23 +87,14 @@ if lvm lvs --noheadings -o lv_name "${VG}" 2>/dev/null | grep -qs "${SNAPSHOT_LV
# Perform rollback
rollback_snapshot
banner "Restoring OS and booting up"

create_snapshot
banner "Snapshot created!"
reboot -f
else
# No snapshot
banner "First boot after setting up! Will zerofree disk and create snapshot!"
banner "First boot after setting up! Will create snapshot!"

# Perform snapshot creation
if [ ! -x "/sbin/zerofree" ]; then
panic "zerofree executable not found"
fi

zerofree /dev/${VG}/${ORIGIN_LV}
create_snapshot
banner "Snapshot created! Will shut down now."

poweroff -f
reboot -f
fi
EOM
chmod 755 /etc/initramfs-tools/scripts/local-premount/prompt
Expand Down
71 changes: 71 additions & 0 deletions setup.d/60-disable-radio-modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

set -x
set -e

# On IOI 2023, Acer Aspire 3 notebooks are given to the contestants.
# These have an Intel i5-1135G7, a FullHD display, 8 GB of DDR4 RAM, 256 GB of NVMe SSD, ethernet port. But they also have a:
# - webcam
# - WiFi + Bluetooth card
# These are hardware components that are not needed for the contest, therefore we disable their drivers.

# YOU MIGHT NEED TO UPDATE THIS IF YOU WILL BE USING A DIFFERENT LAPTOP, OR IF THE OS CHANGES. Therefore, here is an explanation how this part of the configuration was created. Otherwise, it could have been quite magical why certain kernel modules have been disabled.

# It is important to note that it is good practice to use ethernet during a competition since it is more stable than WiFi. We will also use ethernet on IOI 2023.

# While we were trying out the notebooks, we have noticed that the WiFi + Bluetooth did not work due to problems with drivers on Linux. It is probably a feature in this case. I am sure that an update will eventually remove this "feature", therefore I am disabling the card's drivers altogether. (Check https://community.intel.com/t5/Wireless/AX101-Ubuntu-22-04-or-22-10-driver/td-p/1468063) I have tested, on Ubuntu 23.04 and I have updated the kernel to 6.4.0, and both WiFi and Bluetooth worked fine with it.
# Command `sudo dmesg` showed that there have been attempts on starting up WiFi and Bluetooth even on Ubuntu 22.04 with the current kernel (5.15.0).

# Disable webcam
# This is done in accordance with https://askubuntu.com/questions/166809/how-can-i-disable-my-webcam
echo "blacklist uvcvideo" >> /etc/modprobe.d/blacklist.conf

# To disable bluetooth, I disabled the bluetooth kernel module and everything else that depends on it (recursively). Probably disabling only one module would have been sufficient, I am not sure, I had problems if only the `bluetooth` module was disabled.

# So I ran the command `sudo lsmod | grep bluetooth`. I got:
# bluetooth XXXXXX XX btrtl,btintel,btbcm,bnep,btusb
# ecdh_generic XXXXX X bluetooth

# Therefore btrtl, btintel, btbcm, btusb depend on bluetooth, so I also wanted to disable them.
# Checking them one-by-one they didn't show any other modules.

# sudo lsmod | grep btrtl
# btrtl XXXXX X btusb
# bluetooth XXXXXX XX btrtl,btintel,btbcm,bnep,btusb

# sudo lsmod | grep btintel
# btintel XXXXX X btusb
# bluetooth XXXXXX XX btrtl,btintel,btbcm,bnep,btusb

# sudo lsmod | grep btbcm
# btbcm XXXXX X btusb
# bluetooth XXXXXX XX btrtl,btintel,btbcm,bnep,btusb

# sudo lsmod | grep bnep
# bnep XXXXX X
# bluetooth XXXXXX XX btrtl,btintel,btbcm,bnep,btusb

# sudo lsmod | grep btusb
# btusb XXXXX X
# btrtl XXXXX X btusb
# btbcm XXXXX X btusb
# btintel XXXXX X btusb
# bluetooth XXXXXX XX btrtl,btintel,btbcm,bnep,btusb

# I have also disabled the bluetooth service for good measure.

# Disable bluetooth
echo "blacklist btusb" >> /etc/modprobe.d/blacklist.conf
echo "blacklist btrtl" >> /etc/modprobe.d/blacklist.conf
echo "blacklist btbcm" >> /etc/modprobe.d/blacklist.conf
echo "blacklist btintel" >> /etc/modprobe.d/blacklist.conf
echo "blacklist bluetooth" >> /etc/modprobe.d/blacklist.conf
systemctl disable bluetooth.service

# From dmesg I got a hint that the WiFi card's kernel module is `iwlwifi`. Then I have went it with the exact same method as in bluetooth (described above).
# Disable wifi
echo "blacklist iwlwifi" >> /etc/modprobe.d/blacklist.conf
echo "blacklist iwlmvm" >> /etc/modprobe.d/blacklist.conf
echo "blacklist cfg80211" >> /etc/modprobe.d/blacklist.conf
echo "blacklist mac80211" >> /etc/modprobe.d/blacklist.conf
echo "blacklist libarc4" >> /etc/modprobe.d/blacklist.conf