Update install.sh
This commit is contained in:
parent
0e32eb30ec
commit
08b250784e
142
install.sh
142
install.sh
|
@ -1,7 +1,20 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#PS3="Please select a disk to partition:"
|
# Friendly introduction.
|
||||||
|
echo "Welcome to the Arch Linux installation script!"
|
||||||
|
echo "This script will ERASE ALL DATA on the partition you choose in the next step."
|
||||||
|
echo
|
||||||
|
read -p "Do you want to continue? Type [Y]es or [N]o. " -n 1 -r
|
||||||
|
echo # (optional) move to a new line
|
||||||
|
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||||
|
then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Partitioning.
|
||||||
|
echo
|
||||||
echo "Please select a disk to partition:"
|
echo "Please select a disk to partition:"
|
||||||
|
echo
|
||||||
|
|
||||||
# Don't separate values by space.
|
# Don't separate values by space.
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
@ -22,79 +35,67 @@ IFS=' '
|
||||||
# Create new variable of selection.
|
# Create new variable of selection.
|
||||||
array=($disk)
|
array=($disk)
|
||||||
dev="${array[0]}"
|
dev="${array[0]}"
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
# Starting partitioning.
|
# Starting partitioning.
|
||||||
echo "Partitioning /dev/$dev.."
|
echo "Partitioning /dev/$dev.."
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
# Clearing partition table of selected disk.
|
# Clearing partition table of selected disk.
|
||||||
echo "Clearing existing partitioning table."
|
echo "Clearing existing partitioning table."
|
||||||
sgdisk -Z /dev/$dev &&
|
sgdisk -Z /dev/$dev &&
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
# Creating boot partition.
|
# Creating boot partition.
|
||||||
size="${array[1]%?}"
|
size="${array[1]%?}"
|
||||||
echo "Creating boot partition of 256 MB."
|
echo "Creating boot partition of 256 MB."
|
||||||
sgdisk -n 1:0:+256M /dev/$dev &&
|
sgdisk -n 1:0:+256M /dev/$dev &&
|
||||||
|
echo
|
||||||
|
|
||||||
# Setting type for EFI.
|
# Setting type for EFI.
|
||||||
sgdisk -t 1:ef00 /dev/$dev &&
|
sgdisk -t 1:ef00 /dev/$dev &&
|
||||||
echo -e
|
|
||||||
|
|
||||||
# Creating system partition.
|
# Creating system partition.
|
||||||
echo "Creating system partition of $size GB."
|
echo "Creating system partition of $size GB."
|
||||||
sgdisk -n 2:0:0 /dev/$dev
|
sgdisk -n 2:0:0 /dev/$dev
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
# Print partitions.
|
# Print partitions.
|
||||||
echo "This is your new partition table:"
|
echo "This is your new partition table:"
|
||||||
lsblk | grep "$dev"
|
lsblk | grep "$dev"
|
||||||
|
sleep 1
|
||||||
|
echo
|
||||||
|
|
||||||
|
# This needs to be deleted.
|
||||||
echo $dev > /tmp/disk
|
echo $dev > /tmp/disk
|
||||||
|
|
||||||
# Exit.
|
# Exit.
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# This needs to be deleted.
|
||||||
# Get variable from filesystem.
|
# Get variable from filesystem.
|
||||||
part=$(</tmp/disk)2
|
part=$(</tmp/disk)2
|
||||||
|
|
||||||
# Encrypting partition.
|
# Encrypting partition.
|
||||||
echo "Encrypting system partition."
|
echo "Encrypting system partition. This might take a while."
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
cryptsetup -c aes-xts-plain -y -s 512 luksFormat /dev/$part &&
|
cryptsetup -c aes-xts-plain -y -s 512 luksFormat /dev/$part &&
|
||||||
echo "Partition successfully encrypted."
|
echo "Partition successfully encrypted."
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
# Opening encrypted partition and mounting at /dev/mapper/lvm.
|
# Opening encrypted partition and mounting at /dev/mapper/lvm.
|
||||||
echo "Opening and mounting encrypted partition."
|
echo "Decrypting.. This also might take a while."
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
echo "Decrypting.. This might take a while."
|
|
||||||
echo -e
|
|
||||||
cryptsetup luksOpen /dev/$part lvm &&
|
cryptsetup luksOpen /dev/$part lvm &&
|
||||||
echo "Partition opened and mounted:"
|
echo "Partition successfully opened."
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
disk="${part%?}"
|
disk="${part%?}"
|
||||||
lsblk | grep "$disk"
|
lsblk | grep "$disk"
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
# Creating physical volume.
|
|
||||||
echo "Creating physical volume."
|
|
||||||
pvcreate /dev/mapper/lvm &&
|
|
||||||
echo -e
|
|
||||||
|
|
||||||
# Creating volume group "main".
|
|
||||||
echo "Creating volume group."
|
|
||||||
vgcreate main /dev/mapper/lvm &&
|
|
||||||
echo -e
|
|
||||||
|
|
||||||
# Creating logical volumes.
|
|
||||||
echo "Creating logical volumes for root and home."
|
|
||||||
echo -e
|
|
||||||
|
|
||||||
# Lol, this part:
|
# Lol, this part:
|
||||||
part=$(</tmp/disk)2 && i=( $(lsblk | grep "$part" | tail -n+1 | awk '{print $4}') ) && size="${i%?}"
|
part=$(</tmp/disk)2 && i=( $(lsblk | grep "$part" | tail -n+1 | awk '{print $4}') ) && size="${i%?}"
|
||||||
|
@ -102,35 +103,70 @@ part=$(</tmp/disk)2 && i=( $(lsblk | grep "$part" | tail -n+1 | awk '{print $4}'
|
||||||
echo "Your system partition has a size of $size GB."
|
echo "Your system partition has a size of $size GB."
|
||||||
echo "What size should your root partition have?"
|
echo "What size should your root partition have?"
|
||||||
read root
|
read root
|
||||||
echo "Creating a $root GB root volume."
|
echo "Creating a $root GB root volume.."
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
|
# Ask for everything that is necessary later.
|
||||||
|
echo "Before installing the system, please enter a hostname:"
|
||||||
|
echo
|
||||||
|
read host
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "Please enter a password for the root account:"
|
||||||
|
read pwr
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "And please enter a username:"
|
||||||
|
read user
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "Also please enter a password for your user:"
|
||||||
|
read pwu
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "System is getting installed.."
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Creating physical volume.
|
||||||
|
echo "Creating physical volume."
|
||||||
|
pvcreate /dev/mapper/lvm &&
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Creating volume group "main".
|
||||||
|
echo "Creating volume group."
|
||||||
|
vgcreate main /dev/mapper/lvm &&
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Creating logical volumes.
|
||||||
|
echo "Creating logical volumes for root and home."
|
||||||
|
echo
|
||||||
|
|
||||||
lvcreate -L ${root}G -n root main &&
|
lvcreate -L ${root}G -n root main &&
|
||||||
lvcreate -l 100%FREE -n home main &&
|
lvcreate -l 100%FREE -n home main &&
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
echo "Logical volumes successfully created."
|
echo "Logical volumes successfully created."
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
echo "Creating the filesystem."
|
echo "Creating the filesystem."
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
boot=$(</tmp/disk)1
|
boot=$(</tmp/disk)1
|
||||||
|
|
||||||
mkfs.fat -F 32 -n UEFI /dev/$boot &&
|
mkfs.fat -F 32 -n UEFI /dev/$boot &&
|
||||||
echo "Filesystem for boot successfully created."
|
echo "Filesystem for boot successfully created."
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
mkfs.ext4 -L root /dev/mapper/main-root &&
|
mkfs.ext4 -L root /dev/mapper/main-root &&
|
||||||
echo "Filesystem for root successfully created."
|
echo "Filesystem for root successfully created."
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
mkfs.ext4 -L home /dev/mapper/main-home &&
|
mkfs.ext4 -L home /dev/mapper/main-home &&
|
||||||
echo "Filesystem for home successfully created."
|
echo "Filesystem for home successfully created."
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
echo "Mounting.."
|
echo "Mounting.."
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
mount /dev/mapper/main-root /mnt
|
mount /dev/mapper/main-root /mnt
|
||||||
mkdir /mnt/boot
|
mkdir /mnt/boot
|
||||||
|
@ -139,27 +175,27 @@ mount /dev/$boot /mnt/boot
|
||||||
mount /dev/mapper/main-home /mnt/home
|
mount /dev/mapper/main-home /mnt/home
|
||||||
|
|
||||||
echo "Mounting complete."
|
echo "Mounting complete."
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
lsblk
|
lsblk
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
# Updating mirrors using reflector.
|
# Updating mirrors using reflector.
|
||||||
echo "Updating mirrors.."
|
echo "Updating mirrors.."
|
||||||
echo -e
|
echo
|
||||||
#reflector --verbose --latest 10 --country Germany --age 24 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
|
#reflector --verbose --latest 10 --country Germany --age 24 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
|
||||||
reflector --verbose --latest 10 --age 24 --protocol https --sort rate --save /etc/pacman.d/mirrorlist &&
|
reflector --verbose --latest 10 --age 24 --protocol https --sort rate --save /etc/pacman.d/mirrorlist &&
|
||||||
echo -e
|
echo
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
|
||||||
# Installing base system.
|
# Installing base system.
|
||||||
echo "Installing basic packages.."
|
echo "Installing basic packages.."
|
||||||
echo -e
|
echo
|
||||||
#pacstrap /mnt base base-devel firefox konsole linux linux-firmware linux-zen lvm2 networkmanager nano plasma-desktop sddm sddm-kcm &&
|
#pacstrap /mnt base base-devel firefox konsole linux linux-firmware linux-zen lvm2 networkmanager nano plasma-desktop sddm sddm-kcm &&
|
||||||
pacstrap /mnt base firefox konsole linux linux-firmware linux-zen lvm2 networkmanager nano plasma-desktop sddm sddm-kcm sudo &&
|
pacstrap /mnt base firefox konsole linux linux-firmware linux-zen lvm2 networkmanager nano plasma-desktop sddm sddm-kcm sudo &&
|
||||||
echo -e
|
echo
|
||||||
echo "Base system installed."
|
echo "Base system installed."
|
||||||
echo -e
|
echo
|
||||||
|
|
||||||
# Generating fstab.
|
# Generating fstab.
|
||||||
echo "Generating fstab."
|
echo "Generating fstab."
|
||||||
|
@ -174,7 +210,7 @@ echo "Hostname set."
|
||||||
|
|
||||||
# Setting locale.
|
# Setting locale.
|
||||||
echo "Setting and generating locale."
|
echo "Setting and generating locale."
|
||||||
echo -e
|
echo
|
||||||
#localegen=$(cat /mnt/etc/locale.gen)
|
#localegen=$(cat /mnt/etc/locale.gen)
|
||||||
cat <<EOF >/mnt/etc/locale.gen
|
cat <<EOF >/mnt/etc/locale.gen
|
||||||
en_US.UTF-8 UTF-8
|
en_US.UTF-8 UTF-8
|
||||||
|
@ -184,28 +220,28 @@ EOF
|
||||||
arch-chroot /mnt locale-gen
|
arch-chroot /mnt locale-gen
|
||||||
echo "LANG=de_DE.UTF-8" >/mnt/etc/locale.conf
|
echo "LANG=de_DE.UTF-8" >/mnt/etc/locale.conf
|
||||||
echo "KEYMAP=de-latin1" > /mnt/etc/vconsole.conf
|
echo "KEYMAP=de-latin1" > /mnt/etc/vconsole.conf
|
||||||
echo -e
|
echo
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
|
||||||
# Editing mkinitcpio.conf.
|
# Editing mkinitcpio.conf.
|
||||||
echo "Editing /etc/mkinitcpio.conf."
|
echo "Editing /etc/mkinitcpio.conf."
|
||||||
echo -e
|
echo
|
||||||
sed -i '7s/.*/MODULES=(ext4)/' /mnt/etc/mkinitcpio.conf &&
|
sed -i '7s/.*/MODULES=(ext4)/' /mnt/etc/mkinitcpio.conf &&
|
||||||
sed -i '52s/.*/HOOKS=(base udev autodetect modconf block keyboard keymap encrypt lvm2 filesystems fsck shutdown)/' /mnt/etc/mkinitcpio.conf &&
|
sed -i '52s/.*/HOOKS=(base udev autodetect modconf block keyboard keymap encrypt lvm2 filesystems fsck shutdown)/' /mnt/etc/mkinitcpio.conf &&
|
||||||
echo -e
|
echo
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
|
||||||
# Creating inital ramdisk.
|
# Creating inital ramdisk.
|
||||||
echo "Creating inital ramdisk for linux-zen."
|
echo "Creating inital ramdisk for linux-zen."
|
||||||
echo -e
|
echo
|
||||||
arch-chroot /mnt mkinitcpio -p linux-zen &&
|
arch-chroot /mnt mkinitcpio -p linux-zen &&
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
|
||||||
# Enable network and display manager.
|
# Enable network and display manager.
|
||||||
echo "Enabling Networkmanager and display manager (sddm)."
|
echo "Enabling Networkmanager and display manager (sddm)."
|
||||||
echo -e
|
echo
|
||||||
arch-chroot /mnt systemctl enable NetworkManager sddm &&
|
arch-chroot /mnt systemctl enable NetworkManager sddm &&
|
||||||
echo -e
|
echo
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
|
||||||
echo "Setting root password:"
|
echo "Setting root password:"
|
||||||
|
|
Loading…
Reference in New Issue