reworked chroot commands, fixed swap partition numbers
This commit is contained in:
+19
-30
@@ -55,7 +55,7 @@ setup_partitions() {
|
|||||||
|
|
||||||
# Create filesystems
|
# Create filesystems
|
||||||
mkfs.fat -F32 -n "BOOT" ${DISK}1
|
mkfs.fat -F32 -n "BOOT" ${DISK}1
|
||||||
mkswap -f ${DISK}3
|
mkswap -f ${DISK}2
|
||||||
mkfs.ext4 -F -L "ROOT" ${DISK}3
|
mkfs.ext4 -F -L "ROOT" ${DISK}3
|
||||||
|
|
||||||
# Mount
|
# Mount
|
||||||
@@ -76,10 +76,15 @@ setup_partitions() {
|
|||||||
|
|
||||||
# Setup systemdboot as the bootloader
|
# Setup systemdboot as the bootloader
|
||||||
setup_bootloader() {
|
setup_bootloader() {
|
||||||
bootctl install
|
# Run bootctl inside chroot
|
||||||
|
arch-chroot /mnt bootctl install
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error: Failed to install systemd-boot."
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
BOOTLOADER_ENTRY="/boot/loader/entries/arch.conf"
|
BOOTLOADER_ENTRY="/mnt/boot/loader/entries/arch.conf"
|
||||||
ARCH_ENTRY_TEMPLATE="/usr/share/systemd/bootctl/arch.conf"
|
ARCH_ENTRY_TEMPLATE="/mnt/usr/share/systemd/bootctl/arch.conf"
|
||||||
|
|
||||||
# Get PARTUUID for the root partition
|
# Get PARTUUID for the root partition
|
||||||
PARTUUID=$(blkid | grep "${DISK}3" | awk -F= '{print $NF}' | tr -d '\"')
|
PARTUUID=$(blkid | grep "${DISK}3" | awk -F= '{print $NF}' | tr -d '\"')
|
||||||
@@ -103,8 +108,7 @@ setup_bootloader() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Main execution flow
|
# Main execution flow
|
||||||
case $1 in
|
|
||||||
"install" | "")
|
|
||||||
# Ask for the drive to install on
|
# Ask for the drive to install on
|
||||||
get_drive
|
get_drive
|
||||||
|
|
||||||
@@ -116,32 +120,17 @@ case $1 in
|
|||||||
|
|
||||||
genfstab -U /mnt >>/mnt/etc/fstab
|
genfstab -U /mnt >>/mnt/etc/fstab
|
||||||
|
|
||||||
# Copy the script to the new environment for the chroot part
|
|
||||||
cp ./install.sh /mnt/tmp/
|
|
||||||
echo "DISK=${DISK}" >/mnt/etc/install-script-variables.conf
|
|
||||||
|
|
||||||
arch-chroot /mnt /bin/bash -c "/tmp/install.sh chroot"
|
|
||||||
|
|
||||||
umount -A -R /mnt # Unmount everything for safety
|
|
||||||
printf "\n==> Installation finished, you can now reboot.\n"
|
|
||||||
;;
|
|
||||||
|
|
||||||
"chroot")
|
|
||||||
echo "Running the chroot side"
|
|
||||||
|
|
||||||
. /tmp/install-script-variables.conf
|
|
||||||
|
|
||||||
# Setup base locales
|
# Setup base locales
|
||||||
ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime
|
ln -sf /usr/share/zoneinfo/Europe/Paris /mnt/etc/localtime
|
||||||
locale-gen
|
arch-chroot /mnt locale-gen
|
||||||
echo LANG=en_US.UTF-8 >/etc/locale.conf
|
echo LANG=en_US.UTF-8 >/mnt/etc/locale.conf
|
||||||
echo hostname >/etc/hostname
|
echo hostname >/mnt/etc/hostname
|
||||||
|
|
||||||
echo "root:password" | chpasswd
|
arch-chroot /mnt bash -c "echo 'root:password' | chpasswd"
|
||||||
|
|
||||||
systemctl enable NetworkManager
|
# NetworkManager handles all the network setup
|
||||||
|
arch-chroot /mnt systemctl enable NetworkManager
|
||||||
|
|
||||||
setup_bootloader
|
setup_bootloader
|
||||||
|
umount -A -R /mnt # Unmount everything for safety
|
||||||
;;
|
printf "\n\n\n==> Installation finished, you can now reboot.\n"
|
||||||
esac
|
|
||||||
|
|||||||
Reference in New Issue
Block a user