Made a few changes to allow for both BIOS and EFI installations
This commit is contained in:
parent
9b91217a09
commit
ac608174fa
@ -4,18 +4,68 @@
|
|||||||
# BEGIN: Variables
|
# BEGIN: Variables
|
||||||
|
|
||||||
HOSTNAME="ExampleHostname"
|
HOSTNAME="ExampleHostname"
|
||||||
BOOT_METHOD="EFI"
|
BOOT_METHOD="BIOS"
|
||||||
DISK='/dev/sda'
|
DISK='/dev/sda'
|
||||||
EFI_PARTITION=${DISK}1
|
EFI_PARTITION=${DISK}1
|
||||||
SWAP_PARTITION=${DISK}2
|
SWAP_PARTITION=${DISK}2
|
||||||
ROOT_PARTITION=${DISK}3
|
ROOT_PARTITION=${DISK}3
|
||||||
|
|
||||||
|
## New Login creds for your new user and the root user
|
||||||
|
ROOT_PASSWORD="root"
|
||||||
|
NEW_USER="username"
|
||||||
|
NEW_PASSWORD="password"
|
||||||
|
|
||||||
TIMEZONE_INFO=America/Chicago
|
TIMEZONE_INFO=America/Chicago
|
||||||
LOCALE=en_US.UTF-8
|
LOCALE=en_US.UTF-8
|
||||||
|
|
||||||
## Commands to create disks un-interactively with fdisk
|
## Commands to create disks un-interactively with fdisk
|
||||||
## will clean up comments later with grep command
|
## will clean up comments later with grep command
|
||||||
FORMAT_DISK_COMMANDS="
|
FORMAT_DISK_COMMANDS_BIOS="
|
||||||
|
# Create MBR partition table
|
||||||
|
o
|
||||||
|
|
||||||
|
# Create bios header (area where boot information is stored at the beginning of the disk)
|
||||||
|
n
|
||||||
|
# Create Primary partition (which is technically the default anyway)
|
||||||
|
p
|
||||||
|
# Press Enter to select default partition number
|
||||||
|
|
||||||
|
# Press Enter to select default starting sector
|
||||||
|
|
||||||
|
# Allocate 10 MB at beginning of disk for BIOS table (you will do nothing with it)
|
||||||
|
+10MiB
|
||||||
|
|
||||||
|
# Create Swap Partition
|
||||||
|
n
|
||||||
|
# Create Primary partition (which is technically the default anyway)
|
||||||
|
p
|
||||||
|
# Press Enter to select default partition number
|
||||||
|
|
||||||
|
# Press Enter to select default starting sector
|
||||||
|
|
||||||
|
# Allocate 8GiB for swap partition
|
||||||
|
+8GiB
|
||||||
|
# Set the type to Linux Swap (82)
|
||||||
|
t
|
||||||
|
# Press Enter to select the last partition
|
||||||
|
|
||||||
|
# Set to type 82
|
||||||
|
82
|
||||||
|
|
||||||
|
# Create Root Partition
|
||||||
|
n
|
||||||
|
# Set as Primary (default)
|
||||||
|
p
|
||||||
|
# Press Enter to select default partition number
|
||||||
|
|
||||||
|
# Press Enter to select default starting sector
|
||||||
|
|
||||||
|
# Press Enter to allocate rest of disk to root partition
|
||||||
|
|
||||||
|
# Sync changes to disk
|
||||||
|
w
|
||||||
|
"
|
||||||
|
FORMAT_DISK_COMMANDS_EFI="
|
||||||
# Create GPT partition table
|
# Create GPT partition table
|
||||||
g
|
g
|
||||||
|
|
||||||
@ -62,6 +112,8 @@ n
|
|||||||
w
|
w
|
||||||
"
|
"
|
||||||
|
|
||||||
|
## Declaring a "named" variable allows me to access the correct commands without a conditional
|
||||||
|
declare -n FORMAT_DISK_COMMANDS="FORMAT_DISK_COMMANDS_${BOOT_METHOD}"
|
||||||
|
|
||||||
|
|
||||||
# END: Variables
|
# END: Variables
|
||||||
@ -78,7 +130,7 @@ fdisk $DISK <<< "$COMMANDS"
|
|||||||
|
|
||||||
### Format EFI Partition
|
### Format EFI Partition
|
||||||
#### The efi partition (mounted at /boot/efi) Needs to be formatted as fat32
|
#### The efi partition (mounted at /boot/efi) Needs to be formatted as fat32
|
||||||
mkfs.fat -F32 $EFI_PARTITION
|
[[ "$BOOT_METHOD" == "EFI" ]] && mkfs.fat -F32 $EFI_PARTITION
|
||||||
|
|
||||||
### Format SWAP partition
|
### Format SWAP partition
|
||||||
mkswap $SWAP_PARTITION
|
mkswap $SWAP_PARTITION
|
||||||
@ -92,7 +144,7 @@ mkfs.ext4 $ROOT_PARTITION
|
|||||||
### Mounting the root partition to begin setting up the partitions where they need to be
|
### Mounting the root partition to begin setting up the partitions where they need to be
|
||||||
mount $ROOT_PARTITION /mnt
|
mount $ROOT_PARTITION /mnt
|
||||||
### Calling the --mkdir flag for mount to create the necessary directories so that it can mount
|
### Calling the --mkdir flag for mount to create the necessary directories so that it can mount
|
||||||
mount $EFI_PARTITION --mkdir /mnt/boot/efi
|
[[ "$BOOT_METHOD" == "EFI" ]] && mount $EFI_PARTITION --mkdir /mnt/boot/efi
|
||||||
|
|
||||||
### Using pacstrap to install the necessities to be able to get a chroot env
|
### Using pacstrap to install the necessities to be able to get a chroot env
|
||||||
: "
|
: "
|
||||||
@ -120,16 +172,102 @@ Installing it here because it is not installed by default. An alternative is doa
|
|||||||
"
|
"
|
||||||
pacstrap /mnt base linux linux-headers linux-firmware sudo
|
pacstrap /mnt base linux linux-headers linux-firmware sudo
|
||||||
|
|
||||||
INSTALL_SYSTEM="
|
## Setting up fstab
|
||||||
# Updating the package manager cache
|
genfstab -U /mnt > /mnt/etc/fstab
|
||||||
pacman -Syy
|
|
||||||
|
|
||||||
|
INSTALL_SYSTEM="
|
||||||
# Setting the hostname of your machine
|
# Setting the hostname of your machine
|
||||||
echo '$HOSTNAME' > /etc/hostname
|
echo '$HOSTNAME' > /etc/hostname
|
||||||
|
|
||||||
# Setting timezone of the machine
|
# Setting timezone of the machine
|
||||||
ln -sf /usr/share/zoneinfo/$TIMEZONE_INFO /etc/localtime
|
ln -sf /usr/share/zoneinfo/$TIMEZONE_INFO /etc/localtime
|
||||||
|
|
||||||
|
# Setting LOCALE of machine (uncommenting
|
||||||
|
cp /etc/locale.gen{,-bak}
|
||||||
|
sed -i s'/\#$LOCALE/$LOCALE/' /dev/locale.gen
|
||||||
|
echo 'LANG=$LOCALE' > /etc/locale.conf
|
||||||
|
# Generate local
|
||||||
|
locale-gen
|
||||||
|
|
||||||
|
# Install and Enable Networking Systems
|
||||||
|
: '
|
||||||
|
networkmanager:
|
||||||
|
This is the system that will handle all networking for your system, allowing you to setup profiles and otherwise automatically configure your network as needed.
|
||||||
|
|
||||||
|
wpa_supplicant:
|
||||||
|
This is the service/program that will manage supplication (aka wireless handshakes) between your device and your Access Point/Router
|
||||||
|
'
|
||||||
|
## Installing networking packages
|
||||||
|
pacman -S -y networkmangager wpa_supplicant
|
||||||
|
## Enabling systemd services
|
||||||
|
systemctl enable wpa_supplicant NetworkManager
|
||||||
|
|
||||||
|
## Installing bootloader
|
||||||
|
: '
|
||||||
|
grub:
|
||||||
|
Grub is a bootloader. A program that helps you boot into an installed system
|
||||||
|
|
||||||
|
It is what actually load your kernel and init-system via your install's specific efi file located somewhere in (/boo/efi/EFI)
|
||||||
|
|
||||||
|
|
||||||
|
efibootmgr:
|
||||||
|
Is a tool that is used to edit boot manager settings (primarily to delete and move boot options around)
|
||||||
|
'
|
||||||
|
### Do bootloader install
|
||||||
|
`
|
||||||
|
case "${BOOT_METHOD,,}" in
|
||||||
|
efi)
|
||||||
|
echo "pacman -S -y grub efibootmgr"
|
||||||
|
echo "grub-install --target=x86_64-efi --bootloader-id=GRUB --efi-directory=/boot/efi"
|
||||||
|
;;
|
||||||
|
bios)
|
||||||
|
echo "pacman -S -y grub"
|
||||||
|
echo "grub-install --target=i386-pc --boot-directory=/boot"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
`
|
||||||
|
## Create grub config
|
||||||
|
grub-mkconfig -o /boot/grub/grub.cfg
|
||||||
|
|
||||||
|
: '
|
||||||
|
gnome:
|
||||||
|
This is the gnome desktop enviorment. It's the default choice for most distros by default (due to fewer release cycles, meaning distro maintainers don't have to work as much to maintain it for their distro).
|
||||||
|
|
||||||
|
There are other choices:
|
||||||
|
- KDE/Plasma
|
||||||
|
- xfce4
|
||||||
|
- lxde
|
||||||
|
...
|
||||||
|
|
||||||
|
KDE is usually the next choice for those wanting to have a very easy to use and integrated desktop with a lot of customizability.
|
||||||
|
|
||||||
|
gdm \"Gnome Desktop Manager\":
|
||||||
|
This is the default desktop manager (login screen) for gnome. This just handles the login screen and starting up your desktop session & windowing system based off of your choices.
|
||||||
|
'
|
||||||
|
## Install desktop env
|
||||||
|
pacman -S -y gnome
|
||||||
|
|
||||||
|
## Enable desktop manager/login-screen
|
||||||
|
systemctl enable gdm
|
||||||
|
|
||||||
|
## Setting root password
|
||||||
|
echo -e '$ROOT_PASSWORD\n$ROOT_PASSWORD\n' | passwd
|
||||||
|
## Creating new user and setting password
|
||||||
|
useradd -m $NEW_USER
|
||||||
|
echo -e '$NEW_PASSWORD\n$NEW_PASSWORD\n' | passwd $NEW_USER
|
||||||
|
|
||||||
|
## Adding new user to wheel group to be able to use sudo
|
||||||
|
usermod -aG wheel $NEW_USER
|
||||||
|
|
||||||
|
## Setting up wheel group in sudoers
|
||||||
|
: '
|
||||||
|
I am doing it this way because it's not a good idea to edit /etc/sudoers non-interactively, as you can break sudo for all other users except root.
|
||||||
|
|
||||||
|
sudo will load all definitions from /etc/sudoers.d/ and won't break if there is an error in the extra files (unlike if you edit /etc/sudoers directly)
|
||||||
|
'
|
||||||
|
echo '%wheel ALL=(ALL:ALL) ALL' > /etc/sudoers.d/wheel
|
||||||
"
|
"
|
||||||
|
|
||||||
|
arch-chroot /mnt /bin/bash <<< "$INSTALL_SYSTEM"
|
||||||
|
|
||||||
# END: Work
|
# END: Work
|
||||||
|
Loading…
Reference in New Issue
Block a user