RayZ0rr / LinuxBootstrap

Bootstrap scripts for linux (Arch) with used softwares list

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LinuxBootstrap

Bootstrap scripts for Arch linux with used softwares list.
This guide is meant to be used with the Arch installation guide on the Arch wiki.

Dependency

There is no strict dependencies. Only optional ones.

  • ( Optional ) The bootstrap script depends on LinuxBoot repo for bootloader and boot setup.
    ( mainly files in 'boot' folder. But a copy exists in this repo and will be used)
  • ( Optional ) Dotfiles repo for dotfiles for configurations and customizations.
  • ( Optional ) myNvim repo for neovim configurations and customizations.

If you don't need Dotfiles or myNvim setup, then change variables doDotfilesSetup and doNvimSetup in line numbers 31 and 32 respectively to "no" or just comment them out by placing # at the beginning.

Reminders:

  • Double check what is the drives name you want to install on, it might not be /dev/sda (use lsblk or fdisk -l).
  • You need to install the userspace utilities for the different filesystems(xfsprogs, btrfs-progs, dosfstools).

Partitioning

Check what drives are available with lsblk:

Usually sda or sdb is your usb drive with the Arch ISO. Probably the biggest drive will be your computers hard drive.

You can also find scripts with the most popular system configurations in the install-scripts directory, I don't recommend executing the scripts, the best way is to copy the commands one-by-one incase you need to change something inbetween the commands.

I think the easiest to use partitioner is cfdisk

# cfdisk /dev/sda

The partition layout:

|EFI system partition (FAT32) | Label=part_efi | /dev/sda1 | Suggested size is 512 MiB
Mountpoint:   /efi  
|EFI system partition (ext4) | Label=part_boot | /dev/sda2 | Suggested size is 1 GiB
Mountpoint:   /boot  

Optional Linux Swap | Label=Swap | /dev/sda4 | 2x or 1.5x times bigger than ram

btrfs root ('/') and home ('/home').

Btrfs device | partition | mountpoint |	  Label	  | Suggested size
/dev/sda3                               part_btrfs      30 GiB
/dev/sda3       @	    /
/dev/sda3       @home       /home
/dev/sda3       @var_cache  /var/log
/dev/sda3       @var_log    /var/cache
/dev/sda3       @snapshots  /.snapshots
/dev/sda3       @swap	    /swap_part

ext4 root ('/') and home ('/home').

ext4 device | partition | mountpoint |	  Label	  | Suggested size
/dev/sda      /dev/sda3     /		part_root       30 GiB
/dev/sda      /dev/sda4     /home       part_home   Remaining space

TIP : ssh into installation system

I recommend connecting both of your devices to the same network because it will be much easier to connect with ssh to the computer you are installing Arch on.
First check the ip address to connect to.

ip a

Then setup sshd.

passwd
systemctl enable sshd

Connect from other computer on same network with:

ssh root@<ip from 'ip a' command above>
Eg:
ssh root@192.168.122.175

Procedure ( before chroot)

Follow the official Arch Installation guide till till Chroot.

Some example steps.

Initial tests

# ls /sys/firmware/efi/efivars
# setfont sun12x22
# ping archlinux.org
# timedatectl set-ntp true
# timedatectl status

Set up disks

Use cfdisk /dev/sda and setup the partition as shown above or however you like.
Use lsblk to find out the device. It may not be /dev/sda.

Encrypting (Optional but recommended)

cryptsetup luksFormat /dev/sda3
# Same as :
cryptsetup --type luks2 --cipher aes-xts-plain64 --hash sha256 --iter-time 2000 --key-size 256 --pbkdf argon2id --use-urandom --verify-passphrase luksFormat /dev/sda3
# To use a keyfile instead of passphrase use:
# (Read on keyfiles : https://wiki.archlinux.org/title/Dm-crypt/Device_encryption#Keyfiles )
cryptsetup luksFormat /dev/sda3 /path/to/mykeyfile
# OR
# To add extra passphrase or keyfiles
cryptsetup luksAddKey /dev/sda3
cryptsetup luksAddKey /dev/sda3 /path/to/mykeyfile2

One way to generate keyfile is:

dd bs=512 count=4 if=/dev/random of=mykeyfile.bin iflag=fullblock
chmod 600 mykeyfile.bin

Read more on keyfiles here.
Then for btrfs

cryptsetup open /dev/sda3 Cbtrfs

or for separate root and home.

cryptsetup open /dev/sda3 Croot
cryptsetup open /dev/sda4 Chome

If using keyfile then use --key-file or -d flag followed by keyfile name. Example if you used above dd command to generate keyfile.

cryptsetup open /dev/sda3 Cbtrfs --key-file mykeyfile.bin

Use cryptsetup luksDump /dev/sda3 to see more information (keyslots start with number 0).

Formatting

  1. EFI system partition (esp) and Boot partition.
# mkfs.fat -F 32 -n part_efi /dev/sda1
# mkfs.ext4 -L part_boot /dev/sda2
  • If you are using btrfs without encryption.
# mkfs.btrfs -L part_btrfs /dev/sda3
  • If you are using btrfs encryption from above, then:
# mkfs.btrfs -L part_btrfs /dev/mapper/Cbtrfs
  • If you are using ext4 for root and home.
# mkfs.ext4 -L part_root /dev/sda3
# mkfs.ext4 -L part_home /dev/sda4
  • If you are using ext4 for root and home with encryption.
# mkfs.ext4 -L part_root /dev/mapper/Croot
# mkfs.ext4 -L part_home /dev/mapper/Chome
  1. If you have swap ( see here for sawpfile creation as opposed to swap partition ):
# mkswap -L part_swap /dev/sda5

For swapfile setup with btrfs read more here.

Mounting

First mount root and then others

    1. If you have btrfs partition for root and home
    # without encryption
    mount /dev/sda3 /mnt
    # or with encryption as above
    mount /dev/mapper/Cbtrfs /mnt
    

    Create subvolumes as necessary.

    btrfs sub cr /mnt/@
    btrfs sub cr /mnt/@home
    btrfs sub cr /mnt/@var_log
    btrfs sub cr /mnt/@var_cache
    btrfs sub cr /mnt/@snapshots
    btrfs sub cr /mnt/@swap
    umount /mnt
    
    # If using unencrypted replace '/dev/mapper/Cbtrfs' with approriate one. Eg :- '/dev/sda3' .
    mount -o noatime,discard=async,autodefrag,space_cache=v2,ssd,compress=zstd,subvol=@ /dev/mapper/Cbtrfs /mnt
    mkdir -p /mnt/{boot,efi,home,var/log,var/cache,.snapshots,root/btrfs-top-level,swap_part}
    mount -o noatime,discard=async,autodefrag,space_cache=v2,ssd,compress=zstd,subvol=@home /dev/mapper/Cbtrfs /mnt/home
    mount -o noatime,discard=async,autodefrag,space_cache=v2,ssd,compress=zstd,subvol=@var_log /dev/mapper/Cbtrfs /mnt/var/log
    mount -o noatime,discard=async,autodefrag,space_cache=v2,ssd,compress=zstd,subvol=@var_cache /dev/mapper/Cbtrfs /mnt/var/cache
    mount -o noatime,discard=async,autodefrag,space_cache=v2,ssd,compress=zstd,subvol=@snapshots /dev/mapper/Cbtrfs /mnt/.snapshots
    mount -o defaults,ssd,subvol=@swap /dev/mapper/Cbtrfs /mnt/swap_part
    mount -o noauto,noatime,defaults,ssd,subvol=/ /dev/mapper/Cbtrfs /mnt/root/btrfs-top-level
    
    1. If you have ext4 partitions for root and home
    # without encryption
    mount /dev/sda3 /mnt
    mkdir -p /mnt/{boot,efi,home}
    mount /dev/sda4 /mnt/home
    # or with encryption as above
    mount /dev/mapper/Croot /mnt
    mkdir -p /mnt/{boot,efi,home}
    mount /dev/mapper/Chome /mnt/home
    
  1. For EFI System Partition (esp) and Boot.

mount /dev/sda1 /mnt/efi
mount /dev/sda2 /mnt/boot
  1. If you have swap
swapon /dev/sda5

Initializing root

  • Change linux-lts to linux or any other supported kernels.
  • Add microcode (intel-ucode or amd-ucode) and graphics drivers as required.
  • Install bootloader of your choice (only grub and rEFInd supported for bootstrap). In the example below, refind is used as bootloader. nvidia-lts and intel-ucode are also added.
pacstrap /mnt base linux-lts linux-firmware git vim refind nvidia-lts intel-ucode
genfstab -U /mnt >> /mnt/etc/fstab
# See note below.
arch-chroot /mnt

NOTE! If you have created mykeyfile.bin like above for encryption with keyfile, then make sure to move it to somewhere for further access after arch-chroot. Example (replace 'Chome' with the name used for decrypting with cryptsetup open):

mkdir /mnt/etc/cryptsetup-keys.d
mv mykeyfile.bin /mnt/etc/cryptsetup-keys.d/Chome.key
arch-chroot /mnt

Optionally, if you are using btrfs, remove 'subvolid' entry from mount options in /etc/fstab.
To print result to stdout without changing the file

sed 's/subvolid.*,//' /etc/fstab

If okay, then write changes to file.

sed -i 's/subvolid.*,//' /etc/fstab

Procedure ( After chroot)

Clone bootstrap repository to /tmp/mySetup

mkdir tmp/mySetup
cd tmp/mySetup
git clone https://github.com/RayZ0rr/LinuxBootstrap
cd LinuxBootstrap/Arch

or in one line

mkdir tmp/mySetup && cd tmp/mySetup && git clone https://github.com/RayZ0rr/LinuxBootstrap && cd LinuxBootstrap/Arch

Optionally, edit the bootstrap script that will be used. Especially, the variables starting from line 31.

vim ./Arch_Bootstrap_[Auto|Manual].sh

Optionally, edit progs.csv if required and start bootstrapping. Use Auto or Manual script:

./Arch_Bootstrap_[Auto|Manual].sh
  • Check necessary logs at /tmp/bootstrapLogs or /home/<username>/bootstrapLogs.
  • Check /boot/grub/grub.cfg and /boot/grub/custom.cfg if GRUB is bootloader or /boot/refind_linux.conf if refind is bootloader, as necessary to make sure all entries are correct.
  • Check /etc/fstab to make sure everything is correct along with lsblk -f or blkid to verify stuff.
  • If there is more than one encrypted partition, check /etc/crypttab as necessary to make sure all entries are correct. Optionally, enter the keyfile path for third field for that particular partition to skip password check for home partition at boot (read more here).

alias la to ls -al for convenience.

alias la="ls -al"

If everything is ok, then exit and reboot:

exit
umount -R /mnt
reboot

Post-Installation Steps

You can check ~/bootstrapLogs folder to find logs from bootstrap script. Other than that do the following:
( _There's will be scipt in home directory named 'firstStart.sh', if dotfiles were setup, that does steps 1 to 4 below. Just run it by typing ./firstStart.sh and reopen terminal. Don't forget to remove the script as it is unneccassry)

  1. Open terminal (with 'windows key'+ enter key if not changed) and:
  • rename ~/.zshenv_hold to ~/.zshenv ( mv ~/.zshenv_hold ~/.zshenv )
  • Delete ~/.zshrc ( rm ~/.zshrc )
  • Close terminal and open again.
  1. Start clipmenu daemon to get it's features.
systemctl --user enable clipmenud
  1. Use fc-cache -fv to reload fonts.
  2. Optionally, run the below command to remove solo packages not explicitly installed and are not required by any other packages. MAKE SURE THEY ARE NOT REQUIRED !!
pacman -Qtdq | sudo pacman -Rns -
# OR
packorphan
  1. Optionally edit ~/.config/polybar/modulesGruvbox.ini and change [myCards] section if necessary.
  1. Optionally open neovim with nvim or nv in terminal to complete neovim setup.

Reference

About

Bootstrap scripts for linux (Arch) with used softwares list

License:GNU General Public License v3.0


Languages

Language:Shell 100.0%