VectorLinux
October 24, 2014, 10:37:31 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Visit our home page for VL info. To search the old message board go to http://vectorlinux.com/forum1. The first VL forum is temporarily offline until we can find a host for it. Thanks for your patience.
 
Now powered by KnowledgeDex.
   Home   Help Search Login Register  
Please support VectorLinux!
Pages: [1]
  Print  
Author Topic: ro-chroot  (Read 6361 times)
uelsk8s
Administrator
Vectorian
*****
Posts: 2504



« on: September 16, 2011, 02:40:09 pm »

I would like to introduce a little bash script called ro-chroot.
you can download it here: http://vectorlinux.osuosl.org/Uelsk8s/ro-chroot
It was made to help developers in packaging,but it has many more uses.
It uses aufs to overlay your / and keeps track of all changes done while its running.
What this means is that you can download files delete files change files and exit the script and all your data is safely untouched, but all of the changes are neatly stored in a CHROOT-RW dir.

how to use it?
download it: wget http://vectorlinux.osuosl.org/Uelsk8s/ro-chroot
change its permission to executable: chmod +x ro-chroot
run it as root: ./ro-chroot
make any changes, create a package.
exit by typing: exit

Any questions,post them below

thanks,
Uelsk8s
Logged
budulay
Packager
Vectorian
****
Posts: 568


NewComer


« Reply #1 on: September 16, 2011, 03:57:44 pm »

Does it protect the files in the directory it's being run in?
Logged

VL6.0-Light@MSI MS-1652(AMD TurionX2 ZM-84 2300 MHZ, 4 GB RAM, 250 GB HDD, Nvidia GForce 9600M GT, GIGABYTE AirCruiser N300)
Registered Linux user #473602
SlackBuild Repository for VL7.Not much but it's a start. Join in!
uelsk8s
Administrator
Vectorian
*****
Posts: 2504



« Reply #2 on: September 16, 2011, 05:57:50 pm »

Does it protect the files in the directory it's being run in?
no it protects all the files in /
so you can make a new install run the script to build packages and exit the script and you still have a new clean install.
Logged
budulay
Packager
Vectorian
****
Posts: 568


NewComer


« Reply #3 on: September 18, 2011, 10:18:39 am »

Oh, I see now.
That does sound quite useful(I did mess up my system a couple times by running a script).
Well, not any more  Wink
Thanks.
Logged

VL6.0-Light@MSI MS-1652(AMD TurionX2 ZM-84 2300 MHZ, 4 GB RAM, 250 GB HDD, Nvidia GForce 9600M GT, GIGABYTE AirCruiser N300)
Registered Linux user #473602
SlackBuild Repository for VL7.Not much but it's a start. Join in!
stretchedthin
Administrator
Vectorian
*****
Posts: 3780


WWW
« Reply #4 on: September 18, 2011, 09:38:54 pm »

Did as described here...
Quote
how to use it?
download it: wget http://vectorlinux.osuosl.org/Uelsk8s/ro-chroot
change its permission to executable: chmod +x ro-chroot
run it as root: ./ro-chroot
make any changes, create a package.
exit by typing: exit

But when I run as root in rc3.1 I get the following...
Code:
mount: wrong fs type, bad option, bad superblock on none,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

mount: mount point CHROOT/proc does not exist
mount: mount point CHROOT/dev does not exist
chroot: failed to run command `/bin/bash': No such file or directory
umount: CHROOT/dev: not found
umount: CHROOT/proc: not found
umount: CHROOT: not mounted

My file system is set up as ext4
When I run dmesg | tail I get the following...
Code:
[   42.330936] fuse init (API version 7.16)
[  210.399738] aufs 2.1-standalone.tree-38-rcN-20110307
[  210.400153] aufs test_add:247:mount[2959]: / is overlapped

Tested it a second time in virtualboxed install of vectorlinux rc3.1 and had the same situation.
Was wondering if anyone else had experienced the same?
Logged

Vectorlinux screencasts and  tutorials can be found at....
http://www.opensourcebistro.com/blog1
http://www.youtube.com/user/vid4ken?feature=mhee
uelsk8s
Administrator
Vectorian
*****
Posts: 2504



« Reply #5 on: September 19, 2011, 07:52:48 am »

I did some more testing and it appears that you need to be on another partition to use / as ro 
so if your new install is sda1 then you must also have a working partition like sda2.
running inside the new install on sda1 you would mount sda2 "mount /dev/sda2 /mnt/sda2" and then cd to sda2 "cd /mnt/sda2"
then you can run the ro-chroot script as root "root:# /root/ro-chroot"

sorry for the problems, that's what happens when you don't test for every possible run scenario.

Thanks for testing,
Uelsk8s
Logged
uelsk8s
Administrator
Vectorian
*****
Posts: 2504



« Reply #6 on: September 19, 2011, 08:08:40 am »

I have a couple more scripts to share.

mkchroot: http://vectorlinux.osuosl.org/Uelsk8s/mkchroot
mkchroot takes an install ISO as an argument and installs into a CHROOT-RW dir that it makes in the current dir you are running in.
 it installs all the pkgs and runs the setup scripts from the installer. this chroot is great for building pkgs in, just in case your install is heavily modified or you are running another version besides the one you want to build packages for.

ro-chroot2: http://vectorlinux.osuosl.org/Uelsk8s/ro-chroot2
ro-chroot2 is the same as ro-chroot except that it uses the CHROOT-RW dir made by mkchroot as its ro dir. this is great if you want to build packages in a clean environment or if you have a tricky pkg that is installing things into /
Logged
stretchedthin
Administrator
Vectorian
*****
Posts: 3780


WWW
« Reply #7 on: December 30, 2011, 03:06:27 pm »

I've made a tutorial for anyone who wants to try uelsk8s chroot jail.
Great tool. Thankyou uelsk8s.
Here is the youtube link
or if you wait a moment I'll have it up on the videotut link on the vl7.0 desktop as well.
« Last Edit: December 30, 2011, 04:55:06 pm by stretchedthin » Logged

Vectorlinux screencasts and  tutorials can be found at....
http://www.opensourcebistro.com/blog1
http://www.youtube.com/user/vid4ken?feature=mhee
stretchedthin
Administrator
Vectorian
*****
Posts: 3780


WWW
« Reply #8 on: January 08, 2012, 05:03:53 pm »

Ran into a problem with uname -m ( the way most SlackBuilds determin which are they are building on).
When building on a 64bit machine, inside a 32bit chroot, it still returns the 64bit arch.
Logged

Vectorlinux screencasts and  tutorials can be found at....
http://www.opensourcebistro.com/blog1
http://www.youtube.com/user/vid4ken?feature=mhee
uelsk8s
Administrator
Vectorian
*****
Posts: 2504



« Reply #9 on: January 08, 2012, 05:35:15 pm »

Ran into a problem with uname -m ( the way most SlackBuilds determin which are they are building on).
When building on a 64bit machine, inside a 32bit chroot, it still returns the 64bit arch.


You will need to export ARCH=i586 in the 32bit chroot before you start building
I just added it to /root/.bashrc
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!