Create a chroot environment from sfs files

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
theru
Posts: 163
Joined: Thu 23 Jul 2015, 16:40
Location: Heers, Belgium

Create a chroot environment from sfs files

#1 Post by theru »

I have been working on and off on this for the last few months. It's a collection of scripts that allow to build a chroot environment from sfs files and run programs from it. Steps have been taken to minimize the chance of user error but it would be nice if others could test them as well. I started this as a means to get more familiar with bash scripting, hope I haven't messed up too badly.

It consists of the following scripts:

build-and-prepare-chroot: When this script is run it builds an image with a default size of 4GB. This can be changed by changing the value of the imagesize variable.

mount-chroot: Opens the terminal in a chroot environment. When run in a window don't close the window but use the exit command. Closing the window interrupts the script and keeps it from running the unmount sequence.

template: Copy this script to one named after the program you want to run in the chroot environment. Running this copy will start the desired program. After the program is closed the chroot session will be ended.

umount-chroot: runs the unmount procedure of the mount-chroot or any of the template scripts. Useful when one of those scripts has been interrupted.

I have included a readme with more info. It's the first time I've written something like this hope it will be useful.

edit: fixed typo in one of the scripts. See next post for details.
Last edited by theru on Wed 13 Sep 2017, 18:00, edited 1 time in total.

theru
Posts: 163
Joined: Thu 23 Jul 2015, 16:40
Location: Heers, Belgium

#2 Post by theru »

Looks like a last minute change resulted in a typo in the template script.

If you have downloaded the package before please download it again as this error prevents a clean unmount.
Attachments
chroot-image.tar
Extract to a folder containing a base sfs file,
as well any other sfs files you would like to add.
Run the build script to get started
(20 KiB) Downloaded 69 times
Last edited by theru on Thu 14 Sep 2017, 14:02, edited 1 time in total.

User avatar
Keef
Posts: 987
Joined: Thu 20 Dec 2007, 22:12
Location: Staffordshire

#3 Post by Keef »

theru

Not had a lot of success so far. Here is the output from Quirky Xerus and Slacko 6.3. Also tried it on Lupu 528 and results were same as Quirky.

Code: Select all

Quirky Xerus

# ./build-and-prepare-chroot 
Building and setting up /mnt/chroot-folder
4+0 records in
4+0 records out
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 64.757 s, 66.3 MB/s
mke2fs 1.42.13 (17-May-2015)
Discarding device blocks: done                            
Creating filesystem with 1048576 4k blocks and 262144 inodes
Filesystem UUID: b807ba80-e483-4c0c-9bb8-f519672680bf
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

find: warning: you have specified the -maxdepth option after a non-option argument -name, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it).  Please specify options before other arguments.

Copying './calibre-2.23.0-x86_64.sfs' to /mnt/chroot-folder
Setting up /mnt/chroot-folder
cp: cannot create directory '/mnt/chroot-folder/lib/consolefonts': No such file or directory
cp: cannot create directory '/mnt/chroot-folder/lib/keymaps': No such file or directory
cp: cannot create regular file '/mnt/chroot-folder/etc/': Not a directory
cp: cannot create regular file '/mnt/chroot-folder/etc/': Not a directory
cp: cannot create regular file '/mnt/chroot-folder/etc/X11/': No such file or directory
mount-FULL: mount point /mnt/chroot-folder/proc/ does not exist
/mnt/chroot-folder didn't build correctly, something went wrong

Slacko 6.32

# ./build-and-prepare-chroot 
Building and setting up /mnt/chroot-folder
4+0 records in
4+0 records out
4294967296 bytes (4.3 GB) copied, 93.3021 s, 46.0 MB/s
mke2fs 1.42.8 (20-Jun-2013)
warning: Unable to get device geometry for chroot.img
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
262144 inodes, 1048576 blocks
52428 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

Copying './LP2_Stellarium-0.11.2.sfs' to /mnt/chroot-folder
mount: warning: temp seems to be mounted read-only.
Setting up /mnt/chroot-folder
cp: cannot create directory ‘/mnt/chroot-folder/lib/consolefonts’: No such file or directory
cp: cannot create directory ‘/mnt/chroot-folder/lib/keymaps’: No such file or directory
cp: cannot create regular file ‘/mnt/chroot-folder/etc/X11/’: Not a directory
mount: mount point /mnt/chroot-folder/proc/ does not exist
/mnt/chroot-folder didn't build correctly, something went wrong 

theru
Posts: 163
Joined: Thu 23 Jul 2015, 16:40
Location: Heers, Belgium

#4 Post by theru »

You need to add a base sfs file from a puppy cd, iso...

If you don't know which file to add just look if there is a proc folder inside.

Post Reply