Talk:Chroot

From ArchWiki

Update file system

Can chroot be used to update the entire root file system? After the chroot, running the mount command reports /dev/root on / type ext3 with /dev/root being a symbolic link to /dev/mmcblk0p2. Unmounting /dev/root and /dev/mmcblk0p2 both report invalid argument. Rereading the partition table using blockdev --rereadpt /dev/mmcblk0 reports device or resource busy. My guess it mmcblk0 is busy because /dev/mmcblk0p2 is still the root file system under the changed root file system I am using now. Before doing a chroot, I kills all the applications but the shell used to run chroot. Any suggestions on how I can successfully reread the partition table in this use model? --Tfischer

If you are talking about updating the root filesystem of the host machine, then yes it can be used to do this, this is actually how you install Arch Linux, however you must be using a different host in order to do this (for example booted into an installation media) as otherwise the root is in use and thus you wont be able to properly chroot into it and write to it, as like you have said "device is busy".
Arch Linux uses arch-chroot to wrap the chroot command to make it easier to use during the installation of Arch Linux, you can install it from arch-install-scripts
PolarianDev (talk) 10:54, 28 February 2023 (UTC)Reply[reply]

About using arch-chroot in other linux distributions

My interest with the added tip wasn't about packaging for other distributions (I didn't even mention the word 'package'). It was only to provide a quick explanation about how to use arch-chroot from another distribution for the sole purpose of chrooting into Arch itself. This was motivated by a personal issue, where I had to use arch-chroot from another linux distribution to access my arch partition, due to a filesystem/boot error. Also, notice that this tip wasn't really related to Install from Existing Linux -- no mentions about 'installations' either.

Thiagowfx (talk) 17:18, 19 December 2014 (UTC)Reply[reply]

arch-chroot is just a bash script (i.e. it is not compiled as the tip said), so why not just extract the script from the Arch package and use it on the other system? I think that it is a standalone script (i.e. not sourcing other parts) so it should just work... -- Lahwaacz (talk) 18:06, 19 December 2014 (UTC)Reply[reply]
Okay, the reason for compiling / running 'make' is that, in the tarball I indicated in the tip, the only thing that is present regarding arch-chroot is an 'arch-chroot.in' file. 'make' is necessary for m4 to replace what needs to be replaced in this file, thus creating our final 'arch-chroot' bash script. Maybe using the term 'compile' wasn't a good idea, but the user should 'make' anyway (or, at least, manually get rid of the lines calling 'm4'). I won't insist on this, though, it is yours the final decision; I just wanted to say the reason for including the tip, I thought it could be useful for someone. Thiagowfx (talk) 19:13, 19 December 2014 (UTC)Reply[reply]
Arch-chroot is just a wrapper around chroot, and thus it should be able to work on other distributions PolarianDev (talk) 10:55, 28 February 2023 (UTC)Reply[reply]
This discussion has been inactive for 7 years, is there any point keeping it open? PolarianDev (talk) 18:24, 5 April 2023 (UTC)Reply[reply]