Below are a set of quick instructions to build your own ISO.
Building the ISO
Step 1: Setup archiso
The best thing you can do, is follow the official documentation for archiso on Arch Linux Wiki.
But the gist is this:
# mkdir -p ./archiso
# cd ./archiso
# cp -r /usr/share/archiso/configs/releng/* ./
Step 2: Add packages to packages.x86_64
git
python
python-setuptools
Step 3: Clone the repo
While standing in the archiso folder, clone using:
# git clone https://github.com/Torxed/archinstall airootfs/root/archinstall-git
Step 4: Create a skel .zprofile for autolaunch
While standing in the archiso folder, create and add the following:
# cat <<\EOF >> ./airootfs/root/.zprofile
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && sh -c "cd /root/archinstall-git; git config --global pull.rebase false; git pull; cp examples/guided.py ./; python guided.py"
EOF
This will auto-run when the ISO boots.
It will perform four simple tasks every login on tty1:
- Enter the
archinstall-gitfolder git configandgit pulleach time- copy
guided.pyinto the root git folder due to how the import works in Python - Finally it will run the latest version of
guided.py
This makes it easy to test the latest version, by simply logging out and back in - and the four steps will get repeated.
No need to reboot or re-build.
Step 5: Build
Archiso has great information and the latest info. But in general, all you need to do (standing in the arciso folder), is to run:
# mkarchiso -v -w work/ -o out/ ./
And that should produce your ISO.
Build Script
- Requires:
archiso,gitandqemu
For a simple script that builds, boots and does all this automatically.
The following convenience script is provided. Simply run ./test.sh.
#!/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-setuptools" >> "${ARCHISO_FOLDER}/packages.x86_64"
cat <<\EOF >> "${ARCHISO_FOLDER}/airootfs/root/.zprofile"
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && sh -c "cd /root/archinstall-git; git config --global pull.rebase false; git pull; cp examples/guided.py ./; python guided.py"
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
Modify BRANCH to suit your needs.