My (Revised) Step-by-Step Process for Starting Arch Linux Live

In this post I talked about my process for setting up my Arch Linux live system. I still use a live distro (mostly because I don’t want to overwrite any files currently on the hard drive), but in the last few months I’ve made quite a few revisions to my startup process for Arch Linux live. I’ve moved to a newer version after I found that I could no longer install packages since they switched from xz format to zst format. I have this version installed to a USB drive, and I have another (128 GB) USB drive for my swap space that I will extend the RAMdisk into. I’ve also written a lot of scripts to automate the process. In this article I will share my revised process for starting Arch Linux live.

Step 1 of the process is to mount the persistent filesystem:


# mount /dev/sda2 /mnt

Next I run my startup script, which is stored on the persistent filesystem. This is a shell script that automates all the commands I used to do manually:


 1 #!/usr/bin/env bash
 2 # Run as root
 3 
 4 # mount /dev/sda2 /mnt
 5 # cd /mnt/Users/Public/Scripts
 6 # ./startup.sh
 7 echo "Setting console font"
 8 setfont /usr/share/kbd/consolefonts/ter-m28n.psf
 9 echo "Creating user michaelwarren"
10 useradd -ms /usr/bin/zsh michaelwarren
11 echo "Setting password for michaelwarren"
12 passwd -d michaelwarren
13 passwd michaelwarren << END > /dev/null
14 *******
15 *******
16 END
17 echo "Adding michaelwarren to /etc/sudoers"
18 echo "michaelwarren ALL=(root) ALL" >> /etc/sudoers
19 echo "Creating swap space"
20 if [[ $(fdisk -l /dev/sdc | grep "swap") != "" ]]
21 then
22         swapon /dev/sdc1
23 else
24         echo "Error: Swap device is not /dev/sdc1"
25         exit
26 fi
27 echo "Extending RAMdisk"
28 mount -o remount,size=8G /run/archiso/cowspace
29 echo "Connecting to the network"
30 dhclient
31 echo "Copying Vim files"
32 cp -R /mnt/Users/Public/.vim /home/michaelwarren
33 cp /mnt/Users/Public/.vim/_vimrc /home/michaelwarren
34 cp /mnt/Users/Public/.vim/trance.vim /usr/share/vim/vim82/colors
35 chown michaelwarren /home/michaelwarren/*
36 chgrp michaelwarren /home/michaelwarren/*
37 chown michaelwarren /home/michaelwarren/.vim/*
38 chgrp michaelwarren /home/michaelwarren/.vim/*
39 echo "Setting user to michaelwarren"
40 su michaelwarren
41 # sudo ./install-packages.sh

I’m not going to explain what all these commands do because I would just be repeating what I said in the previous post. You can refer to the link at the beginning of this article if you don’t understand anything here.

This script copies a bunch of Vimscript files to the home directory and to ~/.vim. These include the _vimrc file and several syntax files and colorscheme files. My _vimrc file looks like this:


 1 " Vim startup file
 2 
 3 set number
 4 set autoindent
 5 set nowrap
 6 set ruler
 7 
 8 syntax on
 9 
10 " Additional colors:
11 map + :so ~/.vim/syntax.vim<CR>
12 
13 so ~/.vim/peachpuff.vim

I use a modified version of the Peachpuff colorscheme because I want Vim to use yellow instead of brown (I can’t seem to get it to display yellow, even if I set the color to bold). My modified coloscheme file is just peachpuff.vim with all highlighting rules deleted except for the colors I want to change from the default:


 1 " Vim color file
 2 " Maintainer: David Ne\v{c}as (Yeti) <yeti@physics.muni.cz>
 3 " Last Change: 2003-04-23
 4 " URL: http://trific.ath.cx/Ftp/vim/colors/peachpuff.vim
 5 
 6 " This color scheme uses a peachpuff background (what you've expected when it's
 7 " called peachpuff?).
 8 "
 9 " Note: Only GUI colors differ from default, on terminal it's just `light'.
10 
11 " First remove all existing highlighting.
12 
13 let colors_name = "peachpuff"
14 
15 " Colors for syntax highlighting
16 hi Comment term=bold ctermfg=4 guifg=#406090
17 hi Constant term=underline ctermfg=1 guifg=#c00058
18 hi Special term=bold ctermfg=5 guifg=SlateBlue
19 hi Identifier term=underline ctermfg=6 guifg=DarkCyan
20 hi PreProc term=underline ctermfg=5 guifg=Magenta3
21 hi Type term=underline ctermfg=2 gui=bold guifg=SeaGreen
22 hi Ignore cterm=bold ctermfg=7 guifg=bg
23 hi Error term=reverse cterm=bold ctermfg=7 ctermbg=1 gui=bold guifg=White guibg=Red
24 hi Todo term=standout ctermfg=0 ctermbg=3 guifg=Blue guibg=Yellow

The next thing I do is install all my packages. This whole process is now automated as well. I use the following script:


 1 #!/usr/bin/env bash
 2 # Install packages in package database
 3 # Script should be run as superuser
 4 
 5 pacman -Sy
 6 cd /mnt/Users/Public/Scripts
 7 declare -i length=`wc -l packages.txt | cut -d " " -f 1`
 8 for ((i=1$i<=$length; i++))
 9 do
10         package=`sed -n "${i}p" packages.txt`
11         pacman -S $package << END
12 y
13 END
14 done
15 cd $OLDPWD

To run properly, this script needs a file called packages.txt, which is simply a list of package names. My current packages.txt file looks like this:


alsa-utils
bison
clang
clisp
cmatrix
cmus
cowsay
cpio
ctags
ed
emacs
figlet
finch
flex
gcc
gcc-fortran
gdb
geoip
glibc
gzip
htop
irssi
ltrace
lua
lynx
m4
make
mc
metasploit
nasm
ncurses
neofetch
php
proxychains
remind
ruby
screenfetch
snowball
strace
tcpdump
time
tmux
tree
w3m
wget
whois

I had a problem initially where some of the packages would mess up glibc and other packages wouldn’t work. I tried installing glibc but I got a file signature error, which suggested that I had the wrong PGP public key on file. However, I found that simply installing gcc first and then reinstalling glibc fixed this issue. Therefore I made sure that gcc appears before glibc in the file (which works out pretty well since the order in which they should be installed corresponds to their alphabetical order).

In any case, I now have a much easier time starting up my Arch Linux live distro and don’t have to manually go through a bunch of commands. I just boot up, mount my drive, and run my scripts, and I’m good.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s