1
Testing a specific disk layout
Anton Hvornum edited this page 2021-04-16 10:36:31 +02:00
One of the current issues is disk layout and cache issues. In order to test this some what reliably, the following script can be run.
It will create two partitions:
- /dev/sda1 -> fat32
- /dev/sda2 -> Encrypted -> ext4
It will also install a base linux on this setup (including bootloader). Nothing will be configured, just the binaries put in place for testing the partitioner.
#!/bin/bash
if [ -z "$1" ]
then
echo "Need to define a output folder for the archiso:"
echo "Example (build and run):"
echo " ./test.sh ./archiso true"
echo "Example (skip building and run ISO as given path):"
echo " ./test.sh ./archiso"
exit 1
fi
REPO="https://github.com/Torxed/archinstall.git"
ARCHISO_FOLDER=$1
REBUILD=$2
BRANCH="master"
if [ $REBUILD ]
then
echo "Making a clean build!"
`rm -rf "${ARCHISO_FOLDER}" 2>/dev/null` || (
echo "Could not delete protected folder:";
echo "-> ${ARCHISO_FOLDER}";
echo "Running as sudo.";
sudo rm -rf "${ARCHISO_FOLDER}"
)
mkdir -p "${ARCHISO_FOLDER}"
cp -r /usr/share/archiso/configs/releng/* "${ARCHISO_FOLDER}/"
git clone "${REPO}" "${ARCHISO_FOLDER}/airootfs/root/archinstall-git"
(cd "${ARCHISO_FOLDER}/airootfs/root/archinstall-git"; git checkout "${BRANCH}" )
echo "git" >> "${ARCHISO_FOLDER}/packages.x86_64"
echo "python" >> "${ARCHISO_FOLDER}/packages.x86_64"
echo "python-pip" >> "${ARCHISO_FOLDER}/packages.x86_64"
echo "python-setuptools" >> "${ARCHISO_FOLDER}/packages.x86_64"
cat <<\EOF >> "${ARCHISO_FOLDER}/airootfs/root/.zprofile"
if [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]]; then
cd /root/archinstall-git
pip uninstall archinstall -y >/dev/null 2>&1
git pull
python setup.py install >/dev/null 2>&1
cd /root
RED='\033[0;31m'
YEL='\033[1;33m'
NC='\033[0m'
umount -R /mnt
cryptsetup close /dev/mapper/luksloop
wipefs -a -f -i -q /dev/sda
parted -s /dev/sda mklabel gpt
parted -s /dev/sda mkpart primary fat32 1MiB 513MiB
parted -s /dev/sda name 1 EFI
parted -s /dev/sda set 1 boot on
parted -s /dev/sda set 1 esp on
parted -s /dev/sda mkpart primary 513MiB 100%
mkfs.fat -F32 /dev/sda1
echo -n "test" > /tmp/disk.pw
cryptsetup \
--batch-mode \
--verbose \
--type luks2 \
--pbkdf argon2i \
--hash sha512 \
--key-size 512 \
--iter-time 10 \
--key-file /tmp/disk.pw \
--use-urandom \
luksFormat /dev/sda2
cryptsetup open /dev/sda2 luksloop --key-file /tmp/disk.pw --type luks2
mkfs.ext4 /dev/mapper/luksloop
mount /dev/mapper/luksloop /mnt
mkdir -p /mnt/boot
mount /dev/sda1 /mnt/boot
pacstrap /mnt base linux efibootmgr
arch-chroot /mnt bootctl --no-variables --path=/boot install
lsblk -f -o+TYPE,SIZE
umount -R /mnt
cryptsetup close /dev/mapper/luksloop
echo ""
echo -e "${RED}Note:${NC} This is a release candidate! (Experimental release: v2.1.4)"
echo -e "Do not bother Arch Linux support staff about issues in this specific release candidate!"
echo -e "Instead, ${YEL}create an Issue ticket on the Upstream GithHub page for support:${NC}"
echo -e " https://github.com/archlinux/archinstall/issues"
echo ""
echo "Run 'python -m archinstall' when you are ready to test (configure your network first if needed)!"
fi
EOF
( cd "${ARCHISO_FOLDER}/"; sudo mkarchiso -v -w work/ -o out/ ./; )
fi
if [ ! -f "./test.qcow2" ];
then
qemu-img create -f qcow2 ./test.qcow2 15G
fi
sudo qemu-system-x86_64 \
-cpu host \
-enable-kvm \
-machine q35,accel=kvm \
-device intel-iommu \
-m 8192 \
-drive if=pflash,format=raw,readonly,file=/usr/share/ovmf/x64/OVMF_CODE.fd \
-drive if=pflash,format=raw,readonly,file=/usr/share/ovmf/x64/OVMF_VARS.fd \
-device virtio-scsi-pci,bus=pcie.0,id=scsi0 \
-device scsi-hd,drive=hdd0,bus=scsi0.0,id=scsi0.0,bootindex=2 \
-drive file=./test.qcow2,if=none,format=qcow2,discard=unmap,aio=native,cache=none,id=hdd0 \
-device virtio-scsi-pci,bus=pcie.0,id=scsi1 \
-device scsi-cd,drive=cdrom0,bus=scsi1.0,bootindex=1 \
-drive file=$(ls -t $ARCHISO_FOLDER/out/*.iso | head -n 1),media=cdrom,if=none,format=raw,cache=none,id=cdrom0
This will run against latest master and have a fixed partition setup on every login/re-login to the ISO.
This enables quick testing by hitting Ctrl-D in the shell of the ISO.