Difference between revisions of "Chroot notes"

From Noah.org
Jump to: navigation, search
(New page: Category:Engineering <pre> echo "/usr/lib/sftp-server" >> /etc/shells adduser dropbox cd /home/dropbox/ mkdir chroot cd chroot mkdir dev etc lib usr bin </pre>)
 
m
Line 1: Line 1:
 
[[Category:Engineering]]
 
[[Category:Engineering]]
 +
 +
 +
== Copy an existing root filesystem ==
 +
 +
This script copies an existing rootfs to one that is to be used in a chroot environment.
  
 
<pre>
 
<pre>
echo "/usr/lib/sftp-server" >> /etc/shells
+
#!/bin/sh
adduser dropbox
+
## mount /dev/sda1 /media/adhoc
cd /home/dropbox/
+
## debootstrap jaunty /media/adhoc/rootfs/ http://ports.ubuntu.com/
mkdir chroot
+
## cd /media/adhoc/rootfs
cd chroot
+
TARGET_DIR=$1
mkdir dev etc lib usr bin
+
cd ${TARGET_DIR}
 +
cp -a /bin .
 +
cp -a /boot .
 +
cp -a /dev .
 +
cp -a /etc .
 +
cp -a /home .
 +
cp -a /lib .
 +
cp --preserve=all --no-dereference /media .
 +
cp --preserve=all --no-dereference /mnt .
 +
cp -a /opt .
 +
cp -a /root .
 +
cp -a /sbin .
 +
cp --preserve=all --no-dereference /srv .
 +
cp -a /usr .
 +
cp -a /var .
 +
# chroot ${TARGET_DIR}
 
</pre>
 
</pre>

Revision as of 13:25, 7 September 2010


Copy an existing root filesystem

This script copies an existing rootfs to one that is to be used in a chroot environment.

#!/bin/sh
## mount /dev/sda1 /media/adhoc
## debootstrap jaunty /media/adhoc/rootfs/ http://ports.ubuntu.com/
## cd /media/adhoc/rootfs
TARGET_DIR=$1
cd ${TARGET_DIR}
cp -a /bin .
cp -a /boot .
cp -a /dev .
cp -a /etc .
cp -a /home .
cp -a /lib .
cp --preserve=all --no-dereference /media .
cp --preserve=all --no-dereference /mnt .
cp -a /opt .
cp -a /root .
cp -a /sbin .
cp --preserve=all --no-dereference /srv .
cp -a /usr .
cp -a /var .
# chroot ${TARGET_DIR}