How to Fix Yum Groupinstall Not Respecting –installroot in Chroot Environment


7 views

When setting up a chroot environment or installing packages to an alternative root directory, many admins encounter a frustrating behavior where yum ignores the --installroot parameter during group installations. Here's what typically happens:

# yum -c yum.conf --installroot=/mnt groupinstall Base
...
Package man-pages-3.23-6.fc13.noarch already installed and latest version
Package talk-0.17-33.2.4.i686 already installed and latest version

The root cause lies in how yum checks package installation status. Even with --installroot specified, yum sometimes checks the host system's RPM database rather than the target directory's database.

Method 1: Initialize RPM Database First

Properly initialize the RPM database in your target directory:

mkdir -p /mnt/var/lib/rpm
rpm --root=/mnt --initdb
rpm --root=/mnt -ivh /path/to/fedora-release.rpm

Method 2: Full Environment Isolation

Create a complete chroot environment before running yum:

mkdir -p /mnt/var/lib/rpm
rpm --root=/mnt --initdb
mount --bind /dev /mnt/dev
mount -t proc proc /mnt/proc
mount -t sysfs sysfs /mnt/sys
chroot /mnt /bin/bash
yum groupinstall Base

For persistent solutions, modify your yum.conf to include these directives:

[main]
installroot=/mnt
cachedir=/mnt/var/cache/yum
keepcache=1
debuglevel=2
logfile=/mnt/var/log/yum.log

If you're using newer Fedora versions, DNF handles this better:

dnf --installroot=/mnt --releasever=13 group install Base
  • Verify RPM database location: rpm --root=/mnt -qa
  • Check mounted directories: mount | grep mnt
  • Inspect yum logs: tail -f /mnt/var/log/yum.log

When working with chroot environments in Linux, many developers encounter a frustrating scenario where yum --installroot appears to recognize packages as already installed in the target directory, even when they're clearly not present. This typically manifests with messages like:

Package irda-utils-0.9.18-10.fc12.i686 already installed and latest version
Package time-1.7-37.fc12.i686 already installed and latest version

The fundamental issue lies in how yum determines package installation status. Even with --installroot specified, yum may still be checking the host system's RPM database rather than the target chroot environment. This occurs because:

  • The RPM database path isn't properly redirected
  • Essential chroot directories aren't mounted
  • The --installroot parameter isn't being fully honored

Here's the proper way to set up a chroot environment with yum:

# First, initialize the RPM database in the target directory
mkdir -p /mnt/var/lib/rpm
rpm --root=/mnt --initdb

# Mount essential directories
mount --bind /proc /mnt/proc
mount --bind /dev /mnt/dev
mount --bind /sys /mnt/sys

# Install critical packages first
rpm --root=/mnt -ivh http://mirror.example.com/fedora/releases/13/Everything/i386/os/Packages/fedora-release-*.rpm

# Then proceed with yum installation
yum -c /path/to/yum.conf --installroot=/mnt --disablerepo='*' --enablerepo=base groupinstall Base

For more reliable chroot operations, consider these additional steps:

[main]
cachedir=/mnt/var/cache/yum/
keepcache=0
debuglevel=2
logfile=/mnt/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=0
plugins=0
installroot=/mnt/

Key configuration notes:

  • Explicitly set installroot in yum.conf
  • Redirect all paths to the chroot location
  • Disable plugins which might interfere
  • Use absolute paths for all directories

After installation, verify the chroot environment is properly set up:

chroot /mnt /bin/bash
rpm -qa | wc -l  # Should show installed package count
yum check  # Verify package consistency