Skip to content

Instantly share code, notes, and snippets.

@cisoun
Last active April 9, 2020 06:07
Show Gist options
  • Save cisoun/5082cafaea46aee9fe4fe5ef8e692ea5 to your computer and use it in GitHub Desktop.
Save cisoun/5082cafaea46aee9fe4fe5ef8e692ea5 to your computer and use it in GitHub Desktop.
Create a chroot environment in Arch

Create a chroot environment in Arch

I wanted to use my cloud server to compile large projects for me.
For that, I needed to create a chroot environment to keep my main system clean and which will handle that process.

Here's how I did...

My chroot environment: /mnt/chroot

1. Installation

1.1 Extract the image

cd /mnt
wget <path-to-bootstrap-image>/archlinux-bootstrap-*-x86_64.tar.gz
tar xzf ./archlinux-bootstrap-*-x86_64.tar.gz

mv root.x86_64 chroot # Optional: Change the name of the bootstrap folder.
rm archlinux-bootstrap-*-x86_64.tar.gz # Optional

1.2 Configuration

  • Uncomment the mirror you want in /mnt/chroot/etc/pacman.d/mirrorlist.
  • Comment the CheckSpace directive in /mnt/chroot/etc/pacman.conf to avoid free space disk issues with Pacman in a chroot environment.

2. Chroot into the environment

arch-chroot /mnt/chroot
# You can ignore the following message:
# ==> WARNING: /mnt/chroot/ is not a mountpoint. This may have undesirable side effects.

3. Prepare Pacman

Populate the keys.

pacman-key --init
pacman-key --populate archlinux

4. Optional

4.1 Add a user

useradd -m archie

# With root privileges:
# NOTE: Don't forget to uncomment one of the "%wheel" lines in /etc/sudoers!
useradd -G wheel -m archie

4.2 Install base packages

Here's some package that you can install afterward.
base is highly recommanded.

pacman -S base base-devel fakeroot gzip sudo

4.2 Install Yay

You'll need to use the user created at step 4.1 for this operation.

su - archie # Considering you're still as root.
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si # Will install Go.

# Optional: Remove the "yay" folder. You don't need it anymore.
cd ..
rm -rf ./yay 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment