Detecting Hypervisors.

This commit is contained in:
Tommaso Chiti 2021-11-02 10:43:00 +01:00
parent 48b464b2f7
commit 0ee827eb1e

View file

@ -109,16 +109,6 @@ keyboard_selector () {
print "Setting up the system clock." print "Setting up the system clock."
timedatectl set-ntp true &>/dev/null timedatectl set-ntp true &>/dev/null
# Checking the microcode to install.
CPU=$(grep vendor_id /proc/cpuinfo)
if [[ $CPU == *"AuthenticAMD"* ]]; then
print "An AMD CPU has been detected, the AMD microcode will be installed."
microcode=amd-ucode
else
print "An Intel CPU has been detected, the Intel microcode will be installed."
microcode=intel-ucode
fi
# Selecting the target for the installation. # Selecting the target for the installation.
PS3="Select the disk where Arch Linux is going to be installed: " PS3="Select the disk where Arch Linux is going to be installed: "
select ENTRY in $(lsblk -dpnoNAME|grep -P "/dev/sd|nvme|vd"); select ENTRY in $(lsblk -dpnoNAME|grep -P "/dev/sd|nvme|vd");
@ -131,8 +121,8 @@ done
# Deleting old partition scheme. # Deleting old partition scheme.
read -r -p "This will delete the current partition table on $DISK. Do you agree [y/N]? " response read -r -p "This will delete the current partition table on $DISK. Do you agree [y/N]? " response
response=${response,,} response=${response,,}
if [[ "$response" =~ ^(yes|y)$ ]] if [[ "$response" =~ ^(yes|y)$ ]]; then
then print "Wiping $DISK"
wipefs -af "$DISK" &>/dev/null wipefs -af "$DISK" &>/dev/null
sgdisk -Zo "$DISK" &>/dev/null sgdisk -Zo "$DISK" &>/dev/null
else else
@ -141,7 +131,7 @@ else
fi fi
# Creating a new partition scheme. # Creating a new partition scheme.
print "Creating new partition scheme on $DISK." print "Creating the partitions on $DISK."
parted -s "$DISK" \ parted -s "$DISK" \
mklabel gpt \ mklabel gpt \
mkpart ESP fat32 1MiB 513MiB \ mkpart ESP fat32 1MiB 513MiB \
@ -189,10 +179,35 @@ mount $ESP /mnt/boot/
# Setting up the kernel. # Setting up the kernel.
kernel_selector kernel_selector
# Checking the microcode to install.
CPU=$(grep vendor_id /proc/cpuinfo)
if [[ $CPU == *"AuthenticAMD"* ]]; then
print "An AMD CPU has been detected, the AMD microcode will be installed."
microcode=amd-ucode
else
print "An Intel CPU has been detected, the Intel microcode will be installed."
microcode=intel-ucode
fi
# Pacstrap (setting up a base sytem onto the new root). # Pacstrap (setting up a base sytem onto the new root).
print "Installing the base system (it may take a while)." print "Installing the base system (it may take a while)."
pacstrap /mnt base $kernel $microcode linux-firmware btrfs-progs grub grub-btrfs efibootmgr snapper reflector base-devel snap-pac zram-generator pacstrap /mnt base $kernel $microcode linux-firmware btrfs-progs grub grub-btrfs efibootmgr snapper reflector base-devel snap-pac zram-generator
# Virtualization check
hypervisor=$(systemd-detect-virt)
case $hypervisor in
kvm ) print "KVM has been detected."
;;
vmware ) print "VMWare Workstation/ESXi has been detected."
;;
microsoft ) print "Hyper-V has been detected."
;;
xen ) print "Xen/Citrix Hypervisor has been detected."
;;
parallels ) print "Parallels has been detected."
;;
esac
# Setting up the network. # Setting up the network.
network_selector network_selector