You are not logged in.

#1 2019-03-11 20:35:58

Portal
Member
Registered: 2019-03-11
Posts: 48

Why is chroot used in installations

I followed tutorials online and they used arch-chroot during their installations.
I know chroot changes the root directory, but why is this useful in installations?

Offline

#2 2019-03-11 20:50:54

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,645

Re: Why is chroot used in installations

Don't follow tutorials, follow the wiki https://wiki.archlinux.org/index.php/In … ide#Chroot

Which makes it pretty obvious, all subsequent paths being used assume that to be the case and the changes will be reflected on your actual system as opposed to the live disk.

Offline

#3 2019-03-11 21:52:14

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: Why is chroot used in installations

Portal wrote:

why is this useful in installations?

It's not smile

All of the post-chroot configuration listed in the Installation Guide can be done after booting into the new system for the first time (and it's easier then because the various systemd tools can be used) and GRUB & systemd-boot can be installed to the disk and configured without chrooting.

But I suppose it's a bit tidier to do everything before rebooting from the live environment.

Offline

#4 2019-03-13 11:28:29

kevr
Member
From: CA, USA
Registered: 2010-05-01
Posts: 24
Website

Re: Why is chroot used in installations

`chroot` changes the "root" directory of your environment.

Imagine `/mnt/installation`. Let's say that you pacstrapped the system into `/mnt/installation`, afterward there are now folders within: `/mnt/installation/bin`, `/mnt/installation/lib`, etc.

The way that the Linux user-space shells look for programs is by default in a few standard paths like `/bin`, `/usr/bin`, etc.

When you `chroot /mnt/installation`, that becomes your new `/` point for the chrooted environment. This allows the shell to treat `/mnt/installation` as your root filesystem.

Then, everything works as expected, just as if you were already booted into your new installation (in a sense).

Without chrooting, your shell is using the root `/` mountpoint by default. Meaning the programs you run, will be run from the live ISO in your case, and they will all use the root path that they can see -- what is part of the live ISO.

Just as Head_on_a_Stick has elaborated on, this is not required to do work on a mounted filesystem that contains a root structure. However, it makes things easier, especially from a fresh user's perspective.

This can of course be worked around without arch-chroot; however, the tool it used to make it easier for users to deal with.


Kevin Morris <kevr@0cost.org>

Hangs out in #archlinux-aurweb. Loves the AUR.

Offline

Board footer

Powered by FluxBB