Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have Linux (Debian Jessie) installed on a hard drive. Drive - sda1, ext4fs, and sda2 - swap

I have a /chroot folder. There is installed another system, in /chroot folder.


How to tell the bootmanager, to boot not the primary system (main, Debian Jessie), but system in /chroot? Probably, change /menu.lst and /chroot/etc/fstab? (vmlinuz root=/dev/sda1/chroot?)

Or another variant of question: is it possible, to have linux installed not into root directory of partition, but in folder? (/another_linux/bin, /another_linux/home, /another_linux/etc, ...)

share|improve this question
vmlinuz root=/dev/sda1/chroot won't work. One probably could simulate this with a method similar to what is used in initrd. See e.g. here. You mount /new_root as described there, then instead of cd /new_root do cd /new_root/chroot and continue. –  n.m. Aug 6 '13 at 18:06

2 Answers 2

This cannot be done by the bootloader or kernel. The parameter to the kernel root option such as in root=/dev/sda1 looks like a standard Unix pathname, but such pathnames are interpreted according to currently mounted filesystem. At the time the root option is interpreted, there are no mounted filesystems. Well, almost none. At kernel initialization time there is an instance of a minimal ramfs filesystem called rootfs mounted as the root for the initial process running start_kernel(). The actual interpretation of the root option parameter is done in a routine called name_to_dev_t(). One of the supported syntaxes is the /dev/name format, where the name is interpreted by doing a temporary mount of the sysfs filesystem in the rootfs root, and looking for a block device entry matching name under /sys/block. This process is explained in more detail here.

The setup as described would need to be done by first booting into a minimal environment such as one provided by an initrd, mount the real root filesystem from /dev/sda1 at a temporary mountpoint, e.g. /mnt/rootfs, then change the root directory to /mnt/rootfs/chroot using pivot_root(8).

This is somewhat similar to how the root filesystems for LinuX Containers (LXC) are setup. LXC is an operating system-level virtualization implementation for Linux. Operating system-level virtualization is commonly used in virtual hosting environments as a lightweight alternative to full virtualization managed by a hypervisor. In operating system-level virtualization, a single operating system kernel is shared among multiple isolated user-space instances. Each instance, often called container, jail, Virtual Private Server (VPE) or Virtual Environment (VE), is essentially a separate operating system installation housed in a directory of its own on the host system.

share|improve this answer

I came across the same issue and ended up writing this to make it work painlessly across different systems (debian, ubuntu currently):

Run make_chroot_initrd script to create a new chroot-enabled initrd image from the existing one:

#  ./make_chroot_initrd /chroot/trusty/boot/initrd.img-3.13.0-32-generic
making new initrd: /chroot/trusty/boot/initrd.img-3.13.0-32-generic.chroot

The new image will be exactly the same, except now it can handle a chroot= boot parameter.

With grub2 as bootloader you can add an entry to /boot/grub/grub.cfg:
(or perhaps better /etc/grub.d/40_custom)

menuentry "ubuntu trusty, (linux 3.13.0-32) (chroot)" {
    insmod ext2                       # or whatever you're using ...
    set root='(hd0,7)'                # partition containing the chroot
    set chroot='/chroot/trusty'       # chroot path
    linux   $chroot/boot/vmlinuz-3.13.0-32-generic root=/dev/sda7 chroot=$chroot rw
    initrd  $chroot/boot/initrd.img-3.13.0-32-generic.chroot

(change files/partitions to match yours)

System-wide install

Once you're happy with it you can make the changes permanent
(until initramfs-tools package gets upgraded).
In the chrooted system:

# cd /usr/share/initramfs-tools
# cp -pdrv .  ../initramfs-tools.orig       # backup
# patch -p1 < path_to/boot_chroot/initrd.patch
# rm *.orig */*.orig
# update-initramfs -u

From now on regular initrd image will support chroot booting.
No need to use a separate initrd.chroot which may get out of sync with it then.

See boot_chroot for details.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.