Skip to content

Instantly share code, notes, and snippets.

@arashpath
Last active January 12, 2022 22:36
Show Gist options
  • Save arashpath/fadbe665509d2da8912b6ab770962488 to your computer and use it in GitHub Desktop.
Save arashpath/fadbe665509d2da8912b6ab770962488 to your computer and use it in GitHub Desktop.
Installing Arch Linux on USB
! urxvt
URxvt*geometry: 115x40
!URxvt*font: xft:Liberation Mono:pixelsize=14:antialias=false:hinting=true
URxvt*font: xft:Inconsolata:pixelsize=17:antialias=true:hinting=true
URxvt*boldFont: xft:Inconsolata:bold:pixelsize=17:antialias=false:hinting=true
!URxvt*boldFont: xft:Liberation Mono:bold:pixelsize=14:antialias=false:hinting=true
URxvt*depth: 24
URxvt*borderless: 1
URxvt*scrollBar: false
URxvt*saveLines: 2000
URxvt.transparent: true
URxvt*.shading: 10
! Meta modifier for keybindings
!URxvt.modifier: super
!! perl extensions
URxvt.perl-ext: default,url-select,clipboard
! url-select (part of urxvt-perls package)
URxvt.keysym.M-u: perl:url-select:select_next
URxvt.url-select.autocopy: true
URxvt.url-select.button: 2
URxvt.url-select.launcher: chromium
URxvt.url-select.underline: true
! Nastavuje kopirovani
URxvt.keysym.Shift-Control-V: perl:clipboard:paste
URxvt.keysym.Shift-Control-C: perl:clipboard:copy
! disable the stupid ctrl+shift 'feature'
URxvt.iso14755: false
URxvt.iso14755_52: false
!urxvt color scheme:
URxvt*background: #2B2B2B
URxvt*foreground: #DEDEDE
URxvt*colorUL: #86a2b0
! black
URxvt*color0 : #2E3436
URxvt*color8 : #555753
! red
URxvt*color1 : #CC0000
URxvt*color9 : #EF2929
! green
URxvt*color2 : #4E9A06
URxvt*color10 : #8AE234
! yellow
URxvt*color3 : #C4A000
URxvt*color11 : #FCE94F
! blue
URxvt*color4 : #3465A4
URxvt*color12 : #729FCF
! magenta
URxvt*color5 : #75507B
URxvt*color13 : #AD7FA8
! cyan
URxvt*color6 : #06989A
URxvt*color14 : #34E2E2
! white
URxvt*color7 : #D3D7CF
URxvt*color15 : #EEEEEC

Installing Arch on USB

Installing arch on a USB Drive, Simple Scriptable installation procedure.

Prerequisites

Steps

  • Create VM without hdd and boot from latest Arch ISO
  • Attache USB Drive check drive name using lsblk, usually /dev/sda
  • Preparing for Installation
    • Check Internet Connection ping archlinux.org
    • Set root passwd passwd and enable ssh systemctl start sshd
    • Enable fastest Mirror
      sudo pacman -Sy --noconfirm --needed reflector pacman-contrib
      
      sudo reflector -l 100 -f 50 --sort rate --threads 5 --verbose \
      --save /tmp/mirrorlist.new && \
      rankmirrors -n 0 /tmp/mirrorlist.new > /tmp/mirrorlist && \
      sudo cp /tmp/mirrorlist /etc/pacman.d
      
      cat /etc/pacman.d/mirrorlist
      sudo pacman -Syy
      

Installation Media

  • Downloading the latest ISO.
    # Download latest iso from https://www.archlinux.org/download/ ------------- #
    ArchMirror="http://mirror.cse.iitk.ac.in/archlinux/iso/latest"
    wget -c "$ArchMirror/md5sums.txt"
    sed -i '/archlinux-bootstrap/d' md5sums.txt
    read md5sum archiso <<<$(cat md5sums.txt)
    wget -c "$ArchMirror/$archiso"
    md5sum -c md5sums.txt
    # -------------------------------------------------------------------------- #
    
  • Making USB Installation media (not req. if using iso in VM)
    • dd bs=4M if=/path/archlinux.iso of=/dev/sdX status=progress && sync

Installation

  • Create a Virtual Box with out hard disk and attache USB and ISO.
  • Boot from Arch installation media.

# check avilable disks and enable networking
#lsblk
#ip link
#ip link set <name> up
# set root passwd and enable ssh
#passwd
#systemctl start sshd

# Mounting USB

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands createrawvmdk -filename "D:\VMs\Vbox\ArchUSB\archUSB.vmdk"

#!/bin/bash
# Installation --------------------------------------------------------------- #
disk="/dev/sda" # specify the usb drive using
mnt="/mnt/drive" # temporary mount point
adminUser="admin"
adminPassword="admin@123"
# Preparing the USB Drive ---------------------------------------------------- #
# Zero Fill Boot sector and create partition tables
dd if=/dev/zero of="$disk" bs=512 seek=0 count=20480 status=progress # zero fill
sgdisk -z "$disk" # zap anything existing
sgdisk -o "$disk" # new GPT partition with protective MBR
# BIOS Boot Drive for old PC
sgdisk -n 1:0:+10M "$disk" # Partition 1 - everything but the last 200MB
sgdisk -t 1:ef02 "$disk" # Set partition type to Linux
sgdisk -c 1:"BIOS" "$disk" # Set Part name BIOS
# EFI Boot Drive for New PC
sgdisk -n 2:0:+500M "$disk" # create partition 2 - last 200MB
sgdisk -t 2:ef00 "$disk" # Set partition type to ESP
sgdisk -c 2:"UEFI" "$disk" # Set Part name UEFI
# ROOT and installation partition
sgdisk -n 3:0:0 "$disk" # Root partition
sgdisk -t 3:8304 "$disk" # Set partition type to linux x86_x64
sgdisk -c 3:"ArchLinux" "$disk" # Set Part name ArchLinux
# File Systems
mkfs.fat -F32 "$disk"2 # ESP
mkfs.ext4 -O "^has_journal" "$disk"3 # Primary Linux partition
mkdir -p $mnt
mount "$disk"3 $mnt
mkdir -p $mnt/boot
mount "$disk"2 $mnt/boot
# Installing arch base (~250MB, ~1GB) ---------------------------------------- #
pacstrap $mnt base
# Generate fstab Entries
genfstab -U -p $mnt > $mnt/etc/fstab
arch-chroot $mnt
echo "archusb" >> /etc/hostname
ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
sed -i '/^#en_US.UTF-8/s/^#//' /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
# Host Name Entries
echo "# Host Entries
127.0.0.1 localhost
::1 localhost
127.0.1.1 archusb.localdomain archusb" >> /etc/hosts
# Generating Instial RAM Disk
sed -i '/^HOOKS=/ {
s/block //
s/autodetect/block autodetect/p
}' /etc/mkinitcpio.conf
mkinitcpio -p linux
# Installing Grub boot loader (~6MB, ~30MB)
pacman -S --noconfirm --needed grub efibootmgr #os-prober
grub-install --target=i386-pc --boot-directory /boot /dev/sda
grub-install --target=x86_64-efi --efi-directory /boot \
--boot-directory /boot --removable
grub-mkconfig -o /boot/grub/grub.cfg
# Save disk wites
sed -i '/Storage=/s/^.*$/Storage=volatile/
/SystemMaxUse=/s/^.*$/SystemMaxUse=16M/' /etc/systemd/journald.conf
# Network Configuration (~3MB, ~10MB)
pacman -S --noconfirm --needed wpa_supplicant dialog ifplugd wpa_actiond
# Using Old dev names i.e. eth & wlan
ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
# enable network services
#systemctl enable netctl-auto@wlan0
cp /etc/netctl/examples/ethernet-dhcp /etc/netctl/eth0-dhcp
systemctl enable netctl-ifplugd@eth0
# Required (~15MB, ~80MB)
pacman -S --noconfirm --needed sudo openssh vim tmux git
systemctl enable sshd
# grml-zsh-config zsh-completions
# All Genric Video Drivers (~43MB, ~183MB)
pacman -S --noconfirm --needed xf86-video-ati xf86-video-intel \
xf86-video-nouveau xf86-video-vesa
# Laptop Touch Pad & Battery (~0MB, ~1MB)
pacman -S --noconfirm --needed xf86-input-synaptics acpi
#USER Configuration
# Zsh as in Arch installation iso (~2MB, ~7MB)
pacman -S --noconfirm --needed grml-zsh-config zsh-completions
#Change Root shell
#chsh -s /usr/bin/zsh
# Admin User with password less sudo and zsh
useradd -m $adminUser -s /usr/bin/zsh
echo "$adminUser":"$adminPassword" | chpasswd
echo "$adminUser ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$adminUser
chmod 0440 /etc/sudoers.d/$adminUser
# Exit
exit
umount $mnt/boot $mnt
reboot
#base-devel vim \
# wpa_supplicant dialog \
# grml-zsh-config zsh-completions \
# openssh sudo
#hwclock --systohc
# Default rule copied from ArchISO
# cat <<EOF > /etc/udev/rules.d/81-dhcpcd.rules
# ACTION=="add", SUBSYSTEM=="net", ENV{INTERFACE}=="en*|eth*", ENV{SYSTEMD_WANTS}="dhcpcd@$name.service"
# EOF
#pacman -S ansible vagrant virtualbox packer
# Network Driver
#pacman -S iw
# My Admin Tools
#pacman -S packer aws-cli ansible
# My Lab tools
#pacman -S vagrant virtualbox
# Permissions ~11MB
#pacman -S polkit
## All packages from ISO
#pacman -S $( curl https://git.archlinux.org/archiso.git/plain/configs/releng/packages.x86_64)
## recommended
#git clone https://github.com/arcmags/archlinux-usb
#!/bin/bash
# Gui
pacman -S i3 dmenu xorg-server xorg-apps xorg-xinit --noconfirm --needed
echo "#! /bin/bash
exec i3" > ~/.xinitrc
# terminal
pacman -S rxvt-unicode rxvt-unicode-terminfo
# Intalling Aura
pacman -S base-devel wget git # ~50 MB
# Python
pacman -S python
pacman -S htop iotop
pacman -S elinks ranger
pacman -S ttf-dejavu ttf-inconsolata
# Gui tools
pacman -S firefox gimp vlc code
#!/bin/bash
set -e
#set -x
# Download latest iso from https://www.archlinux.org/download/ ------------- #
ArchMirror="http://mirror.cse.iitk.ac.in/archlinux/iso/latest"
read sha1sum archiso <<<$(curl "$ArchMirror/sha1sums.txt" \
| sed -n '/archlinux-.*-x86_64.iso/p')
wget -c "$ArchMirror/$archiso"
echo "$sha1sum $archiso" > "$archiso"_sha1sums.txt
#sha1sum -c sha1sums.txt
# -------------------------------------------------------------------------- #
#git clone https://github.com/archlinux/arch-boxes.git
#
#cd arch-boxes
#
#cat <<EOF >local.json
#{
# "iso_url": "file://$isodir/$archiso",
# "iso_checksum_url": "file://$isodir/sha1sums.txt"
#}
#EOF
#packer build -only=virtualbox-iso -var-file=local.json vagrant.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment