Questions tagged [chroot]

chroot is a command on UNIX-like systems which runs a process under a different root directory.

chroot is used often to:

  • Restrict a user to a certain directory (used by , for example)
  • Enter a broken system so that it can be repaired (for example, to use tools like package managers which are designed to be run within a working system)
  • To install a new system (Gentoo, for example, can install from a chroot)

What chroot does is to change what a process considers the root directory, which changes where a process expects to find things - for example, when a process is chroot'd into /home/foo/my-chroot, it can reference the file in /home/foo/my-chroot/bin/sh by using /bin/sh.

This effectively "fools" a process so that it is capable of running under a system where the root directory is not the same as what the process expects.

Another consequence is that, in theory (but see below), a process cannot see any deeper than its chroot'd directory, because /.. resolves to /.

However, chroot is not and was never designed to be a security tool, and there are well known exploits that are used to exit them. Instead, on a *BSD one should use jails, and Linux users should consider either linuxjail, or a VServer.

176 questions
125
votes
7 answers

mount dev, proc, sys in a chroot environment?

I'm trying to create a Linux image with custom picked packages.What I'm trying to do is to hand craft the packages I'm going to use on an XO laptop, because compiling packages takes really long time on the real XO hardware, if I can build all the…
Patrick
  • 1,869
  • 3
  • 15
  • 22
66
votes
1 answer

What's the proper way to prepare chroot to recover a broken Linux installation?

This question relates to questions that are asked often. The procedure is frequently mentioned or linked to offsite, but is not often clearly and correctly stated. In an objective to concentrate useful information in one place, this question seeks…
quack quixote
  • 42,186
  • 14
  • 105
  • 129
55
votes
8 answers

Start a systemd service inside chroot from a non systemd based rootfs

With init scripts (or with openrc) I alway could run services from a different installation root. but when I run chroot /somepath/to_root /usr/bin/systemctl start someservice I got: Running in chroot, ignoring request. Is there a way to force…
user2284570
  • 1,799
  • 7
  • 35
  • 62
12
votes
1 answer

chrooted sftp user with write permissions to /var/www

I am getting confused about this setup that I am trying to deploy. I hope someone of you folks can lend me a hand: much much appreciated. Background info Server is Debian 6.0, ext3, with Apache2/SSL and Nginx at the front as reverse proxy. I need…
bashintosh
  • 123
  • 1
  • 1
  • 5
10
votes
3 answers

SFTP ChRoot result in broken pipe

I have a website that I want to add some restricted access to a sub-folder. For this, I've decided to use CHROOT with SFTP (I mostly followed this link : http://shapeshed.com/chroot_sftp_users_on_ubuntu_intrepid/) For now, I've created a user…
Patrick Pruneau
  • 315
  • 2
  • 4
  • 12
9
votes
2 answers

How to start Xorg-server inside plain chroot?

when I runchroot /somepath /usr/bin/startxI got something what looks like an evdev problem... (I correctly --bind mounted /dev/ /dev/pts /dev/shm /proc /sys /tmp ) The screen is displayed and programs run normally, except I got no mouse nor keyboard…
user2284570
  • 1,799
  • 7
  • 35
  • 62
8
votes
1 answer

How to add pointers to filesystems outside the chrooted environment - using chrooted SFTP via OpenSSH

So, I'm pretty sure this is true, but I haven't found a specifically detailed independent reference that directly answers my question. Question being: How can I add access to a resource that is outside the chroot environment? I have set up chroot…
JDS
  • 472
  • 1
  • 7
  • 15
8
votes
1 answer

Fixing '/dev/null: Permission denied' repeatedly in chroot

I've chrooted into an external disk with sudo chroot /mnt/disk, but almost everything I do (logging in, tab-completion, lessing a file, ...) results in an error mentioning /dev/null: Permission denied, even if the command seems to work. /dev/null…
ash
  • 281
  • 2
  • 11
7
votes
2 answers

How to distinguish 'syscall' from 'int 80h' when using ptrace

As far as I know, ptrace can only get syscall number by PTRACE_SYSCALL, but syscall number is different in x86 and x64. So is there any way to figure out where this syscall real origin? I am now coding a program to limit some others' syscall by…
Criyle
  • 71
  • 3
7
votes
1 answer

rsync error: symlink has no referent

I am trying to configure rsnapshot (which uses rsync) to backup a Windows server but I am having trouble with rsync being unable to follow a symlink on the server to be backed up. Setup: Windows Server 2008 R2 with Cygwin installed which holds…
Marek
  • 71
  • 1
  • 2
7
votes
1 answer

Arch Linux Install, Why is arch-chroot giving me an error?

I'm following the Arch Linux install instructions found here from a live cd, and I'm stuck issuing the following command: # arch-chroot /mnt mount: sys is already mounted or /mnt/sys busy sys is already mounted on /sys sys is already…
TrueZeal
  • 71
  • 1
  • 1
  • 2
6
votes
2 answers

schroot build environment setup how to avoid bind-mount home

The recent linux distributions such as Fedora and Ubuntu all use chroot environment to make the build. Because when making the build often it needs to install some special tools, and to install to the existing system. Using chroot avoids making any…
minghua
  • 588
  • 5
  • 11
6
votes
2 answers

schroot Don't Share Home Directory

I created a schroot recently (following the directions here), and it conveniently shares my (host) user home directory. That is, /home/username is the same in the chroot as outside the chroot. Where is this behaviour configured ? How can I prevent…
5
votes
0 answers

How to create FTP restricted user with vsftpd? (by terminal in Ubuntu)

I have installed ubuntu 12.04 with vsftpd. I need to create FTP users able to access only directories like /var/www/nameDirectory. I thought it was a very basic feature, but seems not I tried to use, in vsftpd.conf chroot_local_user=YES but…
5
votes
2 answers

chroot on OSX as a different OS

I was wondering if anyone has been able to use chroot on OSX to run another OS (ubuntu, centos). I know that they are very different, but almost everything I want to use this for wouldn't care about anything at the level of the kernel, so was…
ekaqu
  • 153
  • 1
  • 3
1
2 3
11 12