Last active
March 28, 2021 04:31
-
-
Save Luv2C0d3/fdfa2ab10ccd53207da8d5e6b831eb75 to your computer and use it in GitHub Desktop.
Arch Linux on VirtualBox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install Arch Linux on VirtualBox | |
# | |
# References I used: | |
# | |
# Install Arch Linux on Dell XPS-13 (https://bit.ly/32P6t61): | |
# Has some of the BTRFS commands, but uses encryption. | |
# Install.txt file in Arch ISO image. | |
# | |
# How to install Gnome on Arch Linux (https://bit.ly/2MRPB96): | |
# or https://www.wikihow.com/Install-Gnome-on-Arch-Linux#Installing-GNOME_sub | |
# | |
# This one in addition to the official arch documentation for Gnome. | |
# | |
# ------------------------------------------------------------------------------------------ | |
# NOTE: For nested virtualization support with VirtualBox on Windows 10 host, need to enable | |
# via the VBoxManage command line as in: | |
# | |
# 'C:\Program Files\Oracle\VirtualBox\VBoxManage.exe' modifyvm vm-name --nested-hw-virt on | |
# | |
# ------------------------------------------------------------------------------------------ | |
# | |
# Boot in to VM by hooking up Arch Linux ISO: | |
# | |
# For cases where VM is booting into high dpi display. | |
# Not needed if you scale the VM to 200% from the VirtualBox UI | |
# Set large font | |
setfont latarcyrheb-sun32 | |
# | |
# Set root password and start sshd to connect from | |
# terminal in host | |
# | |
passwd | |
systemctl start sshd | |
# | |
# Get VM ip address | |
# | |
ip a | |
# | |
# Now, from host connect via ssh to root@address returned above. | |
# | |
# Sync clock | |
timedatectl set-ntp true | |
# Create three partitions: | |
# Note that in VirtualBox, I used MBR as the ISO would not boot using EFI | |
# Regardless of the boot sector MBR or EFI, it's still possible to partition | |
# the disk as GPT. | |
# | |
cgdisk /dev/sda | |
# 1 1MB GRUB partition (BIOS Boot) | |
# 2 128MB ext2 | |
# Hex code: 8300 | |
# Label boot | |
# 3 4096MB Swap partition | |
# Block size 34359739 | |
# Hex code 8200 | |
# Label swap | |
# 4 100% Linux partition (to be encrypted) | |
# Hex code 8300 | |
# Label root | |
# Formatting | |
# Boot partition | |
mkfs.ext2 /dev/sda2 | |
mkswap /dev/sda3 | |
swapon /dev/sda3 | |
mkfs.btrfs /dev/sda4 | |
# Create btrfs subvolumes | |
mount -t btrfs /dev/sda4 /mnt | |
btrfs subvolume create /mnt/@root | |
btrfs subvolume create /mnt/@var | |
btrfs subvolume create /mnt/@home | |
btrfs subvolume create /mnt/@snapshots | |
# Mount btrfs subvolumes | |
umount /mnt | |
mount -o subvol=@root /dev/sda4 /mnt | |
mkdir /mnt/{var,home,.snapshots} | |
mount -o subvol=@var /dev/sda4 /mnt/var | |
mount -o subvol=@home /dev/sda4 /mnt/home | |
mount -o subvol=@snapshots /dev/sda4 /mnt/.snapshots | |
# Mount EFI partition | |
mkdir -p /mnt/boot | |
mount /dev/sda2 /mnt/boot | |
# Change pacman mirror priority, move closer mirror to the top | |
vi /etc/pacman.d/mirrorlist | |
# Install the base system plus packages. | |
pacstrap /mnt base base-devel sudo linux | |
# Generate fstab | |
genfstab -L /mnt >> /mnt/etc/fstab | |
# Enter the new system via chroot | |
arch-chroot /mnt | |
# setup time | |
rm -f /etc/localtime | |
ln -s /usr/share/zoneinfo/America/Vancouver /etc/localtime | |
hwclock --systohc --utc | |
# Generate locales | |
sed --in-place -e 's/^#en_US.U/en_US.U/' /etc/locale.gen | |
locale-gen | |
echo 'LANG=en_US.UTF-8' > /etc/locale.conf | |
# I use dvorak layout. | |
echo 'KEYMAP=dvorak' > /etc/vconsole.conf | |
echo 'FONT=latarcyrheb-sun16' >> /etc/vconsole.conf | |
# | |
# Replace 'your-vm' by the hostname you want for your vm. | |
# | |
echo 'your-vm' > /etc/hostname | |
echo '127.0.0.1 localhost' >> /etc/hosts | |
echo '::1 localhost' >> /etc/hosts | |
echo '127.0.1.1 your-vm.localdomain your-vm' >> /etc/hosts | |
# | |
# Set root passwd | |
# | |
passwd | |
# | |
# Add a user. Replace 'user1' by your non-root login user. | |
useradd -m -g users -G wheel -s /bin/bash user1 | |
passwd user1 | |
echo 'user1 ALL=(ALL) ALL' > /etc/sudoers.d/user1 | |
# | |
# Ok, tired of using sed. | |
# | |
pacman -S vim | |
pacman -Syu | |
pacman -S grub os-prober mtools | |
pacman -S linux | |
grub-install /dev/sda | |
grub-mkconfig -o /boot/grub/grub.cfg | |
# | |
# Ssh server | |
# | |
pacman -S openssh | |
systemctl enable sshd | |
cat > /etc/systemd/network/20-wired.network <<EOF | |
[Match] | |
Name=enp0s3 | |
[Network] | |
DHCP=ipv4 | |
EOF | |
systemctl enable systemd-networkd | |
systemctl enable systemd-resolved | |
# Reboot VM at this point. | |
# | |
# Exit chrooted environment | |
# | |
exit | |
umount -a | |
reboot | |
# | |
# Log in and get ip address to re-connect from host via SSH | |
# | |
# | |
# Gnome | |
# | |
pacman -S gnome | |
sudo systemctl enable gdm.service | |
# | |
# Firefox | |
# | |
pacman -S firefox | |
# | |
# Install Virtualbox VM additions | |
# | |
pacman -S linux-headers xorg-xrandr | |
cd /run/media/user1/VBok_GAs_6.0.14/ | |
./VBoxLinuxAdditions.run | |
# | |
# Install git | |
# | |
pacman -S git | |
# | |
# Firefox | |
# | |
pacman -S firefox | |
# | |
# Install visual studio code bin from MSFT AUR | |
# | |
git clone https://aur.archlinux.org/visual-studio-code-bin.git | |
cd visual-studio-code-bin | |
makepkg -si |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment