Thursday, 4 February 2016

How to access directories under a chroot

chroot into a directory permits a user to run command or interactive shell with special root directory. On many systems, only the super-user can perform this action. While the action of chroot changes the root to the directory `newroot`, this newroot becomes the base of the root filesystem, ie /.

The oldroot filesystem
Code:
ls /
OS/  bin/  boot/  data/  dev/  etc/  home/  lib/  lib64/  media/  mnt/  proc/  root/  run/  sbin/  srv/  sys/  tmp/  usr/  var/

chrooting into a newroot filesystem
Code:
chroot /OS/Slackware-14.2/

The newroot filesystem
Code:
ls /
./  ../  bin/  boot/  dev/  etc/  home/  lib/  lib64/  lost+found/  media/  mnt/  opt/  proc/  root/  run/  sbin/  srv/  sys/  tmp/  usr/  var/

The operation
Code:
    /OS/Slackware-14.2 >  /
Now we have a new root filesystem which was previously under /OS/Slackware-14.2.

Usually this is how a OS boots from an initrd to the real root filesystem.


Normally, if connected via cable and the nameserver is 192.168.1.1, the network should work fine. Otherwise you should copy the  nameserver from the main rootfs to the chroot rootfs.
cat is used since the resolv.conf file can be a link.

Code:
cat /etc/resolv.conf > /OS/Slackware-14.2/etc/resolv.conf


No comments:

Post a Comment

Thanks for your comment

highlights

Automatise additional Installation of software in Slackware

Slackware being an Advanced Operating System, is the oldest living Free/Libre Open Source Software Distribution in the world. Major task...