Skip to content

Instantly share code, notes, and snippets.

@pastleo
Last active June 19, 2021 10:16
Show Gist options
  • Save pastleo/b95cfa7160d5ecc5380fbebbde5d5d13 to your computer and use it in GitHub Desktop.
Save pastleo/b95cfa7160d5ecc5380fbebbde5d5d13 to your computer and use it in GitHub Desktop.
create archlinux installation media
#!/bin/bash
set -e
# https://wiki.archlinux.org/index.php/USB_flash_installation_medium#Using_manual_formatting
# https://unix.stackexchange.com/questions/38164/create-partition-aligned-using-parted/49274#49274
# https://wiki.archlinux.org/index.php/Parted
# https://wiki.archlinux.org/index.php/Syslinux#Manual_install
# Preparation:
# download iso from https://www.archlinux.org/download/
# pacman -S parted syslinux mtools
# mkdir -p ./iso
# mount -o loop archlinux-2020.07.01-x86_64.iso ./iso
# change the following if needed
PART_LABEL=ARCH_202007
ISO_FILE=archlinux-2020.07.01-x86_64.iso
if ! [ -b "$1" ]; then
echo "$1 is not a block device"
exit 255
fi
echo "USB: $1"
echo parted -s -a optimal $1 mktable msdos mkpart primary fat32 0% 100% set 1 boot on
parted -s -a optimal $1 mktable msdos mkpart primary fat32 0% 100% set 1 boot on
echo mkfs.fat -F32 "$1"1
mkfs.fat -F32 "$1"1
echo fatlabel "$1"1 $PART_LABEL
fatlabel "$1"1 $PART_LABEL
echo mkdir -p ."$1"1
mkdir -p ."$1"1
echo mount "$1"1 ."$1"1/
mount "$1"1 ."$1"1/
echo cp -a iso/* ."$1"1/
cp -a iso/* ."$1"1/
echo cp $ISO_FILE ."$1"1/
cp $ISO_FILE ."$1"1/
echo "(sync)" umount ."$1"1/
umount ."$1"1/
echo syslinux --directory /arch/boot/syslinux --install "$1"1
syslinux --directory /arch/boot/syslinux --install "$1"1
echo dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/bios/mbr.bin of="$1"
dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/bios/mbr.bin of="$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment