Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 13 Dec 2017, 13:17
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Create a chroot environment from sfs files
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
theru

Joined: 23 Jul 2015
Posts: 152
Location: Heers, Belgium

PostPosted: Sun 10 Sep 2017, 15:44    Post subject:  Create a chroot environment from sfs files  

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, 14:00; edited 1 time in total
Back to top
View user's profile Send private message 
theru

Joined: 23 Jul 2015
Posts: 152
Location: Heers, Belgium

PostPosted: Wed 13 Sep 2017, 13:58    Post subject:  

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.
chroot-image.tar
Description  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
tar

 Download 
Filename  chroot-image.tar 
Filesize  20 KB 
Downloaded  20 Time(s) 

Last edited by theru on Thu 14 Sep 2017, 10:02; edited 1 time in total
Back to top
View user's profile Send private message 
Keef


Joined: 20 Dec 2007
Posts: 873
Location: Staffordshire

PostPosted: Wed 13 Sep 2017, 15:13    Post subject:  

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:
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
Back to top
View user's profile Send private message 
theru

Joined: 23 Jul 2015
Posts: 152
Location: Heers, Belgium

PostPosted: Thu 14 Sep 2017, 10:05    Post subject:  

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.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1196s ][ Queries: 15 (0.0227s) ][ GZIP on ]