Skip to content

Testing partitioning over old windows installation

Anton Hvornum edited this page Apr 16, 2021 · 2 revisions

Similarly to the other wiki articles for quickly testing things. This script should help you test installing over a windows installation.

Requirements

  1. Download and place the following Windows 10 ISO in your ~/Downloads catalog: https://www.microsoft.com/software-download/windows10
  2. Download and place the following virtio-driver ISO from fedora in your ~/Downloads catalog: https://github.com/virtio-win/virtio-win-pkg-scripts/blob/master/README.md

Once running, select amd64 -> win10 to load the disk driver. (I'm aware that you could use qemu to boot using IDE drives, but this will specifically test SCSI based drives).

#!/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'

	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 35G
fi

sudo qemu-system-x86_64 \
        -cpu host \
        -enable-kvm \
        -machine q35,accel=kvm \
        -device intel-iommu \
        -m 8192 \
        -nic none \
        -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 ~/Downloads/Win10_*.iso | head -n 1),media=cdrom,if=none,format=raw,cache=none,id=cdrom0 \
        -cdrom $(ls ~/Downloads/virtio-win*.iso | head -n 1)

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
Clone this wiki locally