You are not logged in.

#1 2012-01-24 06:32:45

Goran
Member
Registered: 2012-01-24
Posts: 92

Arch on USB key: Any way to overlay ramfs over / ?

I managed to install arch on a USB stick, by following the excellent instructions on the wiki, and I couldn't be happier.

Pacman is amazing. The configuration files are simple. The repositories are up to date.

However, the available documentation on minimizing writes, in order to prolong the life of a flash drive, seems a little sparse.

The common suggestions, such as adding in the "noatime" option, and moving browser profiles into /dev/shm, all seem like "half-solutions", when compared to the possibility of writing changes to a ramfs that overlays /, which can then be periodically merged to /.

In the bit of googling that I did so far, I managed to find references to a "union filesystem", such as aufs, which seems to be designed for exactly that - spreading one system over another, with the ability to do a merge at some later point in time.

So, I'm wondering if anyone here did something like that, and if you could provide me with some guidence as to how I could do the same.

Thanks.

Offline

#2 2012-01-24 06:50:36

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,326

Re: Arch on USB key: Any way to overlay ramfs over / ?

Not a direct answer to your problem, but have you seen this article ??

Edit:  Never mind, you did wink

Last edited by ewaller (2012-01-24 06:51:10)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2012-01-24 08:54:35

Blµb
Member
Registered: 2008-02-10
Posts: 224

Re: Arch on USB key: Any way to overlay ramfs over / ?

Yes, aufs3 will do this. But in order to be able to use it you'll have to apply its patches to the kernel sources. (Also, for some reason I could only compile it as a module, and not directly into the kernel, but this shouldn't be an issue)
http://aufs.sourceforge.net/

There are packages in AUR, though linux-aufs_friendly seems to be flagged out of date atm. But you can still use it, or use the patches from the aufs3 standalone git repo. It contains a readme telling you exactly what to do.

My usecase for it was using squashfs for /usr while having a read-write branch still available to maintain full functionality.
This compressed my >12G /usr into a <4G squash-fs filesystem and reduced the HD access times by a lot, and it is probably also a good idea for a USB stick: squashfs with either rw ramfs, or a writable-branch on the stick. I think ubuntu even does that on its CD/USB sticks.

Once you got the module up and running, using it is quite simply, you mount your branches somewhere, say /mnt/sys/root /mnt/sys/ramfs, and then you combine them using `mount -t aufs -o br=/mnt/sys/ramfs=rw:/mnt/sys/root=ro none /` (assuming you're in the initrd and are about to mount / - or I hope you can directly mount it as /, otherwise you could mount it in a folder and than do mount --bind or something, I have never used initrds myself so I don't know how exactly you'd do that...)

Anyway, on that sourceforge page there's everything on how to use under "4. usage" smile


You know you're paranoid when you start thinking random letters while typing a password.
A good post about vim
Python has no multithreading.

Offline

#4 2012-01-25 07:12:54

Goran
Member
Registered: 2012-01-24
Posts: 92

Re: Arch on USB key: Any way to overlay ramfs over / ?

Blµb wrote:

Yes, aufs3 will do this. But in order to be able to use it you'll have to apply its patches to the kernel sources.

I was hoping that I could simply install a ready-made package, and add some options to /etc/fstab ... Guess I can give this a try when I get a little more familiar with my new environment.

Once you got the module up and running, using it is quite simply, you mount your branches somewhere, say /mnt/sys/root /mnt/sys/ramfs, and then you combine them using `mount -t aufs -o br=/mnt/sys/ramfs=rw:/mnt/sys/root=ro none /` (assuming you're in the initrd and are about to mount / - or I hope you can directly mount it as /, otherwise you could mount it in a folder and than do mount --bind or something, I have never used initrds myself so I don't know how exactly you'd do that...)

Anyway, on that sourceforge page there's everything on how to use under "4. usage" smile

Yes, I read that, and I think it's very informative, but it's not exactly a detailed guide on doing what I want.

How do I actually set this up, and where? In /etc/fstab, rc.conf, or what? Also, for a merge, is there a user space command, or do I have to set something up to run at some stage during shutdown (the former would be preferrable).

PS:

If anyone has any experience with using a USB stick as their primary storage medium, please share your experiences - What was your write minimization strategy (if any), and how long did the stick last?

Offline

#5 2012-01-25 19:27:22

Leonid.I
Member
From: Aethyr
Registered: 2009-03-22
Posts: 999

Re: Arch on USB key: Any way to overlay ramfs over / ?

I think you're overcomplicating things.

1. Arch does not need to write to / per se, only /var. So you can have / and /boot mounted ro all the time.
2. In /var the only active place is /var/log which you can mount as tmpfs and sync every now and then with rsync. Alternatively, you could play with syslog-ng to enable logging of only error.
3. /var/cache/pacman can also be mounted separately and ro unless you want to update everyday.
4. /var/lib may contain a lot of small files, so choose an appropriate FS/mount options.
5. The rest of /var is still needed to be rw, but these are not active/constant writes. Moreover there is important data restoring which will be troublesome should your system crash. That's why I would keep it on a physical storage.


Arch Linux is more than just GNU/Linux -- it's an adventure
pkill -9 systemd

Offline

Board footer

Powered by FluxBB