LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-02-2012, 08:34 PM   #1
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,177

Rep: Reputation: 235Reputation: 235Reputation: 235
Union filesystem with read-only branch on top?


Hello,

I tried to find a way to unify two filesystems, one read-only and one writable. The writable filesystem is complete but very slow, while the read-only filesystem is much faster but some files may be missing or not up to date.

I have read something about union filesystems. All that I found are stacking an RW filesystem on an RO fs. Therefore when reading a file that exists on both filesystems then the RW fs, which is slow, will be used.

Instead of this, I would like to stack an RO fs on an RW fs so that
  • when reading a file which exists on both the RO and the RW branch, the newer file will be read;
  • when writing, data goes into the RW fs.

How to achieve this goal?
Thanks!

Last edited by guanx; 10-02-2012 at 08:37 PM.
 
Old 10-03-2012, 07:18 AM   #2
dru8274
Member
 
Registered: Oct 2011
Location: New Zealand
Distribution: Debian
Posts: 105

Rep: Reputation: 37
The main union filesystems for linux are unionfs and aufs - Another Union File System. But I have only used and can comment about the latter...

The common scenario is for an aufs filesystem comprised of two branches, with RW as the topmost branch, and RO as the bottom. And you desire a read behavior where...
Quote:
Originally Posted by guanx View Post
  • when reading a file which exists on both the RO and the RW branch, the newer file will be read;
But having looked at the aufs manpage, it won't do that. Indeed, the ages of files on different branches are never compared for a read operation. It just isn't that intelligent. Read priority always goes to the file that exists on the topmost branch. So clearly, reading on aufs will sometimes give you the oldest file :-(

You have mentioned perhaps mounting RO as the top branch, with RW as the bottom. But even if you do that, the aufs will always read a file from the RO branch, even if a newer version exists on the RW branch. So once again, an older file is read - not the behavior that you want.

Returning back to the scenario where the top branch is RW... You might write a script to manually prune your RW filesystem of those extra older files. Because once they are removed, read operations on the aufs will always return the newest file, and any new files written will always write to the top (RW) branch. Which is exactly the read/write behaviour that you want. And as for those older files on RW, you can archive them as a dated tar or squashfs file, or store them somewhere entirely separate to the aufs. Or perhaps since those older files are now obselete, you may not need them anymore?

Because an aufs can work perfectly for you, but only if those older files on the RW filesystem are somehow set aside and out of sight. So good luck with that.

Happy with ur solution... then tick "yes" and mark as Solved!

Last edited by dru8274; 10-03-2012 at 07:44 AM.
 
Old 10-03-2012, 08:18 AM   #3
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,177

Original Poster
Rep: Reputation: 235Reputation: 235Reputation: 235
Hi dru8274, thanks for your reply!

Probably I did not make everything clear in my previous post.

My thought is to maintain a complete, up-to-date RW filesystem, to which I can fallback without the help of the RO filesystem. The RO filesystem is only there to accelerate file reads. Therefore some files existing on both will have an older version on the RO branch, particularly when they are written to.
 
Old 10-03-2012, 09:27 AM   #4
dru8274
Member
 
Registered: Oct 2011
Location: New Zealand
Distribution: Debian
Posts: 105

Rep: Reputation: 37
Quote:
Originally Posted by guanx View Post
My thought is to maintain a complete, up-to-date RW filesystem, to which I can fallback without the help of the RO filesystem. The RO filesystem is only there to accelerate file reads. Therefore some files existing on both will have an older version on the RO branch, particularly when they are written to.
Okay, I understand. To speedup the overall system by reading from RO whenever possible. But if you use a simple two branched aufs scheme, then you simply cannot avoid sometimes reading an older file from RO.

I'm considering a possible solution, but again it depends on your specifics. So let me make some educated guesses here. I do not know when or how your RO is created. But if initially, the files in RO are all newer than the files in RW. And then, some new files are written into RW. And thusly, some files in RO that were the newest now become oldest. If you situation works like that then ...

An aufs that always reads the newest file would require 3 branches, one RO branch and two RW branches. Where the two RW branches might be on two separate slow partitions, or just two separate folders within one slow partition. Such that the aufs branches, top to bottom would be...

RW1 -- contains only newly written files, but on a slow filesystem. (Top)
RO -- contains some files, on a fast filesystem.
RW2 -- contains the bulk of files, but on a slow filesystem. (Bottom)

Then using this arrangement, aufs will always read the newest file. RW1 is initially empty, and only newly written files will be written there. No files are ever written to RW2, as that would sometimes lead to oldest files being read. And that overall, the use of RO for reading files is maximized, which makes for faster reads on average.

But the downside is that you need two RW branches. And that periodically, you may want to merge the contents of RW1 into RO and/or RW2. Otherwise, its size will just grow and grow...

That said, I know it's not the simple solution you hoped for. Anyway, I'm now headed off to bed :-)

Happy with ur solution... then tick "yes" and mark as Solved!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] ext2fs_mkdir: Attempt to read block from filesystem resulted in short read while creating root dir Aquarius_Girl Linux - Newbie 10 12-29-2011 07:11 AM
Attempt to read block from filesystem resulted in short read while trying to the_ultimate_samurai Linux - Hardware 6 06-02-2010 08:09 PM
How can I have: Root has Read-Write, user has read only for the boot filesystem? xmrkite Linux - Software 6 10-16-2008 04:31 AM
Raid disk problem : Attempt to read block from filesystem resulted in short read ElmPie Linux - General 5 08-26-2008 05:21 AM
OpenBSD 3.8: read-only root with union /dev Moy Easwaran *BSD 2 11-12-2005 02:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration