-
Senior Member
registered user
A quick and dirty chroot.
I had posted this to answer a specific need. A minimalist chroot, capable of a few commands that needed to have a root filesystem to extract some files to, without overwriting what is already there in the real root... The original post really belongs here in tips and tricks, but it was in answer to another post there.
Ok, I have wrestled with this one for a few days. I tried stuff trying to avoid setting up a chroot.
Now that I have given in and set up the chroot... I can extract the minirt from the cpio archive to my changed "root."
Then I just timestamped a file with touch... and tried to rearchive it. Bingo! It was the exact same size.
So I am going to leave the steps I did in a semi script... well these are the commands I just 'did' from a konsole.
(I can just come back here and copy when I need it.)
Assuming you've booted up to the knoppix user and have a konsole opened to the /home/knoppix/Desktop directory....
I am putting together the files I needed to get a minimal chroot working... using knoppix 5.1.1
A specific chroot just capable of using cpio, and find, ls and a few others. A small one. I had never done it before.
I may want to again though.
If you want to use other commands than this minimal chroot... you will be good to try out the ldd command.
For example... I decided I wanted to be able to use ls. I copied ls to my new-root/bin directory. Then I did a:
ldd /bin/ls
It outputs:
linux-gate.so.1 => (0xffffe000)
librt.so.1 => /lib/tls/librt.so.1 (0xb7efc000)
libacl.so.1 => /lib/libacl.so.1 (0xb7ef6000)
libselinux.so.1 => /lib/libselinux.so.1 (0xb7ee1000)
libc.so.6 => /lib/tls/libc.so.6 (0xb7daf000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0xb7d9d000)
/lib/ld-linux.so.2 (0xb7f2e000)
libattr.so.1 => /lib/libattr.so.1 (0xb7d98000)
libdl.so.2 => /lib/tls/libdl.so.2 (0xb7d94000)
libsepol.so.1 => /lib/libsepol.so.1 (0xb7d53000)
So I grabbed those libraries from /lib and /lib/tls (I think I just grabbed the whole /lib/tls/*)
and put them in new-root/lib, aka /home/knoppix/Desktop/work/lib.
Simple enough. Well, almost. Ignore the linux-gate.so.1. It doesn't exist. It's a virtual library.
Then a
chroot /home/knoppix/Desktop/work
and I get a
bash-3.1# prompt.
Ok so in another root console I copy my unzipped "minirt" to the new-root as minirt_53de.
Then back in the new-root I execute...
cpio -i --list -I ./minirt_53de > minirt.lst
cpio -imd --format=newc -I ./minirt_53de
cpio -o --format=newc < minirt.lst > minirt_53de2
Same size... same blocks count. Bingo.
Any files you add to the minirt, just make sure to add them to the minirt.lst file...
and that way you won't add all the libs and binaries to the minirt when you rearchive.
Cheers
su
mkdir -p work/bin
DEST=`realpath ./work/bin`
SOURCE=/bin
for i in bash cp cpio login ls mkdir more mv rm rmdir sed sh touch; do cp $SOURCE/$i $DEST; done;
mkdir -p work/usr/bin
DEST=`realpath ./work/usr/bin`
SOURCE=/usr/bin
for i in find ldd strace ; do cp $SOURCE/$i $DEST; done;
mkdir -p work/lib/tls
DEST=`realpath ./work/lib/tls`
SOURCE=/lib/tls
for i in libBrokenLocale-2.3.6.so \
libBrokenLocale.so.1 \
libSegFault.so \
libanl-2.3.6.so \
libanl.so.1 \
libc-2.3.6.so \
libc.so.6 \
libcidn-2.3.6.so \
libcidn.so.1 \
libcrypt-2.3.6.so \
libcrypt.so.1 \
libdl-2.3.6.so \
libdl.so.2 \
libm-2.3.6.so \
libm.so.6 \
libmemusage.so \
libnsl-2.3.6.so \
libnsl.so.1 \
libnss_compat-2.3.6.so \
libnss_compat.so.2 \
libnss_dns-2.3.6.so \
libnss_dns.so.2 \
libnss_files-2.3.6.so \
libnss_files.so.2 \
libnss_hesiod-2.3.6.so \
libnss_hesiod.so.2 \
libnss_nis-2.3.6.so \
libnss_nis.so.2 \
libnss_nisplus-2.3.6.so \
libnss_nisplus.so.2 \
libpcprofile.so \
libpthread-2.3.6.so \
libpthread.so.0 \
libresolv-2.3.6.so \
libresolv.so.2 \
librt-2.3.6.so \
librt.so.1 \
libthread_db-1.0.so \
libthread_db.so.1 \
libutil-2.3.6.so \
libutil.so.1 ; do cp $SOURCE/$i $DEST; done;
DEST=`realpath ./work/lib`
SOURCE=/lib
for i in ld-2.3.6.so \
ld-linux.so.2 \
libacl.a \
libacl.la \
libacl.so \
libacl.so.1 \
libacl.so.1.1.0 \
libattr.a \
libattr.la \
libattr.so \
libattr.so.1 \
libattr.so.1.1.0 \
libc-2.3.6.so \
libc.so.6 \
libncurses.so.5 \
libncurses.so.5.5 \
libncursesw.so.5 \
libncursesw.so.5.5 \
libselinux.so.1 \
libsepol.so.1 ; do cp $SOURCE/$i $DEST; done;
Similar Threads
-
By onemyndseye in forum Hdd Install / Debian / Apt
Replies: 0
Last Post: 02-07-2007, 09:08 AM
-
By chethcoat in forum Hdd Install / Debian / Apt
Replies: 1
Last Post: 08-22-2004, 09:26 PM
-
By fabiand in forum General Support
Replies: 2
Last Post: 08-05-2004, 12:09 AM
-
By PrOCesSkIlL in forum Customising & Remastering
Replies: 4
Last Post: 10-23-2003, 02:20 PM
-
By in forum Tips and Tricks
Replies: 3
Last Post: 09-06-2003, 11:09 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules

HPE Synergy 480 Gen 10 Blade Server | 96GB Ram | No HDDs | Complete Otherwise
$500.00

Dell PowerEdge FX2s + 8x FC430 Blades 16x E5-2630v4 160 Cores Rails No PSU/RAM
$699.00

NETAPP HCI NAF-1701 SuperMicro Server 4X BLADE H410C 8X GOLD 5120 - 4X S25G NICs
$1999.97

Dell PowerEdge FC430 Blade Server 2x Xeon E5-2630v4 20 Cores FX2 FX2s No RAM/HDD
$119.99

LOT (8) Cisco UCS UCSB-B200-M5 2x6248R 24 core 3.0G 24x64g DDR4-2933 ram
$112000.00

Dell PowerEdge VRTX Rackmount Chassis w/4x PSUs 2x CMC Modules
$399.98

Dell PowerEdge FX2 FX2s Server 10GbE CMC Blade Enclosure Chassis
$274.99

Dell PowerEdge M620 Blade Server 2x Xeon E5-2680v2 2.8ghz 20-Cores | 128GB
$149.99

Lot of 3 Dell PowerEdge Blade Server HHB005 x2 HHB006 x1
$256.49

Dell Poweredge VRTX 25Bay 2.5" 2x PERC 8, 2xCMC, I/O 1GB Pass Through, 4x PS
$578.08