loadAndUnloadBranchDirs.sh - to the aufs stack

Under development: PCMCIA, wireless, etc.
Message
Author
gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

loadAndUnloadBranchDirs.sh - to the aufs stack

#1 Post by gyro »

I have attached a simple script called 'loadAndUnloadBranchDirs.sh', that can Insert and Remove directories as branches of the aufs stack.
It takes a single parameter, the full path to the directory.
If the directory is not already in the stack, it is inserted, else it is removed.

It's a hacked down version of a simple script to Insert and Remove sfs files in the aufs stack, that I copied from this forum back in 2013.
(Unfortunately I did not keep a record of who the author was.)

This is mostly my continued exploration of what's possible when using ordinary directories in the aufs stack.
However it might be useful while developing an sfs file. You can try the directory without having to actually create the sfs file.

Note: It's a simple script so it only does "fixmenus" processing. It ignores other things like fonts etc..

Edit1: Depends on 'lsaufs'. (no longer true.)

Edit2: Uploaded new version. Dependence on 'lsaufs' has been removed.

Edit3: Uploaded new version with 2 fixes, see post below.

gyro
Attachments
loadAndUnloadBranchDirs.sh.gz
gunzip it to produce the script file
(676 Bytes) Downloaded 259 times
Last edited by gyro on Mon 25 May 2015, 14:29, edited 1 time in total.

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

Updated script

#2 Post by gyro »

I have uploaded a new version of the attached script.
The significant change is that the dependence on my 'lsaufs' script has been removed.

See first post for download.

gyro

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

Updated script again

#3 Post by gyro »

This version of the attached script contains 2 fixes:

1) It checks that the specified directory resides in a Linux partition.

2) It checks that the specified directory is not the parent of an existing branch.

For download, see first post.

gyro

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#4 Post by mikeb »

## insert branch directory...note if already there, will not try and insert...probably a good thing
lol ..just realised that was my script...though it in itself is sort of hacked from how its done in SLAX :) Its been tidied a bit since then ..mainly for loading to tmpfs purposes.

Actually for practical usage this thread might help... http://www.murga-linux.com/puppy/viewtopic.php?t=99388
ie my suggestion that a folder on a partition could be inserted into the union for use as a shared config ..eg /root only. Harking back to the puppy one days when only /root was saved knoppix style.

did you ever read the stuff about union-fuse that we played with... my thought for that involved using sfs with full installs without having to unpack/symlink/install?

mike

stemsee

#5 Post by stemsee »

will it be writeable?

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#6 Post by mikeb »

Good question ..suck it and see I guess.... though a clue might be in pupmode=13 since that writes to the save file which is not the top rw layer.
I deleted all that stuff years ago but knowing puppy I cannot see the save file being removed from the union in order to do so.

My feeling is that there has to be at least ONE rw layer..indeed it won't allow otherwise, but more than one might just be fine.

For a test I unioned several sfs files as a space saving way to merge them..ie all you have to do is mksquashfs the union mount point...saves all that wasteful unpacking and fast too. All done via command line so just play with the parameters...the key line is in the script above.
After all thats how puppy works.... just variations on a theme.

mike

stemsee

#7 Post by stemsee »

Works very well, by the way!

i made a pet package after altering the code to use yad --file-selection to select the dir to be loaded. Also changed the name to dir2layer, and made the script remember the choice as a list which can be added to, for autoloading.

stemsee

#8 Post by stemsee »

I ram permits one could load an entire partition full linux install as a layer! just by selecting /mnt/sda2 for example. How cool would that be? Layering a ubuntu ful install on a puppy linux.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#9 Post by mikeb »

Code: Select all

How cool would that be? Layering a ubuntu ful install on a puppy linux.
ah you refer to barry's underdog option to do just that... he got that tee shirt many years ago...sorry to bubble burst.

More up to date...so read/write works ok then?

mike

stemsee

#10 Post by stemsee »

Read is fine and so too unload using yad directory selector. I didn't try write yet.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#11 Post by mikeb »

Yes unload only fails on the 2.6.18 kernel....anything later seems fine.

so the read test...do it do it....

actually I see a problem with using this for shared configs... only the top layer will get written to anyway unless you use snapmerge to copy changes down to the shared layer...and thats horrible stuff....if the quirks of that script are tolerable I suppose it could still work.

In other words it would be like PUPMODE=13 but using a common folder instead of a save file/folder...indeed modifying that mode would do...not my cup of tea though. And we are considering just /root rather than the full tree to make it configs only....hmm ok now its getting tricky....cannot union a folder back on itself.

Unless someone improves snapmerge..which is possible....and make it ONLY merge /root.


mike

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#12 Post by gyro »

stemsee wrote:Read is fine and so too unload using yad directory selector. I didn't try write yet.
I would not expect write to work via aufs, since the branch is added "ro".
Of course outside aufs, it's just a directory.

Aufs documentation suggests that it does support multiple "rw" layers, so the script could be modified to add the branch "rw", but getting aufs to write the appropriate stuff to the appropriate layer might be a challenge.

gyro
Last edited by gyro on Mon 01 Jun 2015, 07:18, edited 1 time in total.

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#13 Post by gyro »

mikeb wrote:lol ..just realised that was my script...though it in itself is sort of hacked from how its done in SLAX :) Its been tidied a bit since then ..mainly for loading to tmpfs purposes.
Well thanks for your script mikeb.
mikeb wrote:Actually for practical usage this thread might help... http://www.murga-linux.com/puppy/viewtopic.php?t=99388
ie my suggestion that a folder on a partition could be inserted into the union for use as a shared config ..eg /root only. Harking back to the puppy one days when only /root was saved knoppix style.
Yes interesting, I was just exploring what is possible, unaware of some of this other stuff.
mikeb wrote:did you ever read the stuff about union-fuse that we played with... my thought for that involved using sfs with full installs without having to unpack/symlink/install?
No.

gyro

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#14 Post by gyro »

stemsee wrote:I ram permits one could load an entire partition full linux install as a layer! just by selecting /mnt/sda2 for example. How cool would that be? Layering a ubuntu ful install on a puppy linux.
I don't quite understand "If ram permits", the directory does not get copied into memory.
gyro

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#15 Post by mikeb »

Hi gyro...not intended as a thread hijack but seemed open for related ideas.

union-fuse does what aufs does but using fuse..surprised huh...

it was being used in my case as a way of mounting an sfs over a full install .... the method being to create the layers onto new folders somewhere and then chroot into them to run the sfs...not 100% on why aufs could not do it but there was probably a good reason..amigo suggested it originally.

Yes you see having an extra rw layer can be done but how would it be used is the problem,...selective snapmerge was my only thought.

mike

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#16 Post by amigo »

aufs can only have exactly one read-write layer
Using unionfs-fuse lets you create a separate union for each item/sfs.
If you want to use multiple devices/dirs as a read-write layer, then use mhddfs

Use duckduckgo to search for 'aufs vs mhddfs' to see some comparisons.

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#17 Post by gyro »

amigo wrote:aufs can only have exactly one read-write layer
The following is a quote from the aufs documentation:
"Aufs has some policies to select one among multiple writable branches when you are going to write/modify something."
gyro

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#18 Post by amigo »

Okay, explain more.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#19 Post by mikeb »

Hi Amigo...

well pupmode=13 writes to another layer during saves... so there must be some way of doing it. Don't look at me though for how..I deleted snapmerge/mode 13 years ago.


mike

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#20 Post by gyro »

@amigo,
You say aufs supports only 1 writable layer, the actual aufs documentation says it supports multiple writable layers.

@mikeb,
pupmode=13 has only 1 writable layer. "snapmergepuppy" script writes to the save-layer by accessing the directories directly, outside aufs.

@stemsee,
If you want to do auto-loading, you could consider adding a line to run your script after the following line in "rc.sysinit"

Code: Select all

[ -d /initrd ] && [ -x /etc/init.d/sfs_load ] && /etc/init.d/sfs_load start
gyro

Post Reply