Skip to content

Is installing the bootloader the reason why we chroot?

The only thing I do inside my system when I chroot into it is to install grub and configure it.

If there was some way to configure the bootloader without chrooting, would it be necessary to do it?

Also, I see in other minimalist distros there are other tools to do chroot. Is because every distro needs it's own tool? Or could I just use for example gentoo or artix chrooting tool in Arch?

76 points28 comments
Open on Reddit
About this post
Posted
Archived
Score
76 · 100% up
Kind
Text
ID
e486ua

Author

30
posts
108
comments
3
media
View profile

30 comments

I don't think you need to chroot during the install process. It's just nice to do it ASAP so that you can start running normal commands and using normal paths for everything.

I'm pretty sure I've set up a UEFI system without chrooting. efibootmgr doesn't care if you're running a live OS.

75 points

If there was some way to configure the bootloader without chrooting, would it be necessary to do it?

EFISTUB doesn't require any special configuration step.

19 points

But it requires that your UEFI firmware supports passing the command line to the kernel, right?

8 points

Systemd provides a stub (/usr/lib/systemd/boot/efi/linuxx64.efi.stub for x86_64) that you can use to create a single EFI executable that includes the kernel, initramfs and cmdline.

To do this:

objcopy \
    --add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \
    --add-section .cmdline=/path/to/a/file/with/your/cmdline --change-section-vma .cmdline=0x30000 \
    --add-section .splash=/dev/null --change-section-vma .splash=0x40000 \
    --add-section .linux=/boot/vmlinuz-linux --change-section-vma .linux=0x2000000 \
    --add-section .initrd=/boot/initramfs-linux.img --change-section-vma .initrd=0x3000000 \
    /usr/lib/systemd/boot/efi/linuxx64.efi.stub \
    /boot/merged-linux-image.efi

To use multiple initramfs files, concatenate them into a single file (for example, cat /boot/initramfs-linux.img /boot/amd-ucode.img > /boot/merged-initrd.img), then pass that to objcopy.

I've actually created a program that does all this for you (as well as signing it with a custom key for Secure Boot), that you can find here (I should really make an AUR package for it at some point, as well as add a proper README).

3 points

If you decide to tweak the kernel config you can build in a command line.

1 points
unknown author

Deleted before we saved it.

1 points

It's not necessary for installing grub. grub-mkconfig has -o option, and grub-install has --boot-directory and --efi-directory options to specify custom paths

9 points

My understanding is chroot'ing will allow you to "log in" to the installed base system and make configuration changes before actually restarting and booting into it. This is mostly for convenience, and to save time at the end. It might also be useful in a scenario where you have a very specific, scripted install, and could easily wipe a machine & re-deploy again in a very short amount of time.

But all in all, nothing stops you from installing the base system and immediately rebooting to log in to the newly-installed system, then continuing your customizations from there. Chroot'ing at least guarantees you'll be able to login to the system and maybe have a defined user account, DE, login manager, some working drivers, etc.

One other thing that comes to mind is that the live system tends to work well for most people -- i.e., if your drivers work on the live system, but not on native hardware, then it's an indication of a failure in configuration (usually). So, taking advantage of the live system and chroot'ing into your install helps prevent putzing around with drivers/internet connection after the fact.

7 points

Right after I commented that i hadn't found an answer I stumble on this. Thanks for the very nice explanation. Concept finally fully understood.

1 points

You're welcome! Glad I could help with my limited understanding of Arch

1 points

It is enough to root into it, instead of chrooting. (Just login and sudo). When you install grub, you will need /boot to be mounted, I think this is the only requirement that grub install has.

5 points

I don't chroot for that but I change the grub directory to copy the modules from the otherwise chroot'ed system. Sometimes the grub version is different, but it boots fine and I run grub-install later

4 points

There are often a lot of stuff I need to change in chroot. E.g. language (Danish), keyboard, time, region, and to install some essential software such as NetworkManager. If I don't remember I have a hard time getting wifi to work. Not sure if there are any easy alternatives already installed though.

1 points

I install all I need with pacstrap and do the configuration after the first boot. And for wifi devices I use wifi-menu.

1 points

Arh! I've previously used netctl, but stopped since I was on a Eduroam which didn't play nice for some reason. I should give netctl another chance :) Thanks!

2 points

I've read thru most of the comments and didn't find an answer so far, Ive chrooted with instruction from a friend but i didn't really understand the point. Can someone explain what chroot IS actually for/why it's useful?

1 points

When you are installing Arch you are inside your pendrive creating an OS in your PC's disk.

After having everything done, you can retire your pendrive and just turn on your computer to enter the OS you just created from your pendrive (Arch in this case).

So, as you are not in your new system while you are creating it, to enter your system without leaving the installer (Your pendrive) you can use Chroot to fake that you are already inside your new OS. So using it you can do almost everything you could do after retire your pendrive and entering your computer.

People usually use it to configure the OS because thats something you can't do from the installer. You have to be inside the system.

​

Sorry if I didn't explain very good. This isn't my mother language :p

3 points

Chroot-ing allows "logging-in" to the partition where / is installed, whether a new installation or old. As some others have said when you run commands such as grub-mkconfig or grub-install your output paths will be the "real paths" used when your system is truly booted itself (i.e /boot/EFI and similar). Otherwise, you would need to prepend /mnt (or wherever you temporarily mounted your new installation) to each of the paths for the commands listed above if you did not chroot (/mnt/boot/EFI).

Another benefit to the arch-chroot feature specifically helped me solve a networking issue on my multi-boot setup on my laptop (Manjaro, Arch, Lubuntu). I installed Arch using ethernet, but didn't test the wifi during. Long story short I did not have access to ethernet to boot into Arch and install the firmware natively but was instead able to arch-chroot into the Arch / partition and install the necessary firmware while booted in Manjaro. Arch-chroot is similar to chroot but also mounts system directories like /proc, /sys, /dev which are necessary directories if you want to install packages on a system, and you would need to mount them manually with chroot. Check out the link in u/PaperChromatagram's post.

2 points
unknown author

Deleted before we saved it.

1 points

I don't think I've ever chrooted, ever. Of course, I use Grub and from reading all the posts here I assume that is why I never have and up until today never even heard of the term. LOL

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.