Chroot in other systems
From FrugalWiki
This howto was written with 0.5 in mind but might be useful for later versions as well. Scenario: you would like to use Frugalware on an other machine which runs a different flavor of linux.
Be aware, that a chroot shares some things with the real system: the pid space, devices, filesystems.
- Pick a directory for playing. Let's call /tmp/fw-virtual as a container for all files related to this project, and /tmp/fw-virtual/fwchroot as the root of the "embedded" frugalware installation.
- Get the package of pacman from a Frugalware mirror and unzip it to the virtual root. The pacman.static binary will be used for creating a pkg database inside, and install the necessary packages in the so-called chroot-core category.
- Edit the config in /tmp/fwchroot/fw-virtual/etc/pacman.conf to reflect real files on the host's filesystem, because we cannot chroot before the filesystem is populated with the necessary packages. Example config is provided at the end.
- Create the log dir eg. /tmp/fwchroot/fw-virtual/var/log/
- Get our pkg database: ./pacman.static -Syv --config /tmp/fwchroot/fw-virtual/etc/pacman.conf -r /tmp/fwchroot//fw-virtual
- Use the force to install all (the copied pacman package probably conflicts): ./pacman.static -Sfv --config /tmp/fwchroot/fw-virtual/etc/pacman.conf -r /tmp/fwchroot/fw-virtual/ chroot-core
- Modify the pacman.conf to reflect paths relative to the virtual chroot (delete the /tmp/fwchroot/fw-virtual prefixes).
- Try to cd to the virtual root dir, and type "chroot ." Try ls etc.
- Mount the real /dev, /proc, and /shm direcories in the chroot. The "bind" option of mount could be handy, more info on this is at gentoo-wiki:
http://hu.gentoo-wiki.com/TIPP_Könyvtár_csatolása_BIND-dal
http://gentoo-wiki.com/index.php?title=TIP_Bind_A_Directory_In_FSTAB
- Fix the network settings, like resolv.conf and /etc/sysconfig/network
- Fix fstab: a tricky one. You would have to point the root to the device which really contains the filesystem whete your chroot resides.
#fstab in the chroot / /dev/device_holding_chroot options_from_the_real_fstab
Also, make a symlink in the chrooted /etc to mtab points to fstab. Assuming you're in the chroot's etc subdirectory:
ln -s fstab mtab
Without these, "df" wont work, nor the checks for free space in pacman.
The promised minimalistic config of pacman:
[options] LogFile = /tmp/fwchroot/fw-virtual/var/log/pacman.log DBPath = /tmp/fwchroot/fw-virtual/var/lib/pacman CacheDir = /tmp/fwchroot/fw-virtual/var/cache/pacman HoldPkg = pacman glibc bash coreutils chkconfig [frugalware] Server = ftp://some.host.org/packages
You're done, feel happy for your brand-new chrooted FW :D