Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm wondering if this is possible. I want to set up a linux system that mounts / remote linux machine to / on the local machine. However, I want all changes on the local machine to be saved to ram so that it doesn't affect the remote machine. Ideally the changes would NEVER be written, so that when I reboot, it mounts the original / partition again disregarding all changes made during the previous session.

Is something like that possible?

share|improve this question
    
I haven't gotten around to test any of your guys' answers so It's hard to pick 1 to select as a solution. So I'll just upvote you all –  Falmarri Sep 30 '10 at 18:46
add comment

5 Answers

up vote 7 down vote accepted

Use unionfs, aufs (both are external patches for kernel) or unionfsfuse/funionfs (uses FUSE) and create union by marking external / as RO and internal filesystem (mounted as tmpfs/ramfs/additional partition which is cleaned each time).

Alternativly you can use filesystem or LVM with snapshots. Then changes are written but you can clean snapshots at each boot.

share|improve this answer
    
or one could make use of the seeding feature of btrfs (pointed out at <en.wikipedia.org/wiki/Btrfs#cite_ref-16>) -- to seed a read-write fs with a read-only base. If the base fs is btrfs... –  imz -- Ivan Zakharyaschev Aug 17 '11 at 15:27
add comment

There are several ways to go about this. The easiest set up would use a union filesystem, which presents a single view of two directory trees A and B, such that all changes are saved to B. In your case, A would be an NFS/Samba/sshfs/… mount point, and B would be an initially empty directory on a tmpfs filesystem.

Linux doesn't have an in-kernel union filesystem, but there are several FUSE implementations: funionfs, Unionfs-fuse.

share|improve this answer
add comment

If / fits into the RAM of the local machine and leaves enough room for running applications, the basic idea would probably be to boot a minimal Linux system on the target machine and then automatically create a ramfs virtual disk, copy / from remote into it and chroot into this new /. If RAM is not sufficient, you can basically follow the same procedure but not using ramfs but a real disk partition whose content you have to clear before copying. Instead of clearing and full copy you could also use rsync with appropriate options.

share|improve this answer
add comment

This can be archiev very easy with PXE boot. i am running a live xbmc system over pxe tftp nfs boot. changes are written with COW to NFS share.

share|improve this answer
add comment

You can go for Btrfs and it's Copy-on-Write (CoW) feature.

The one you might be looking for is described on Btrfs Wiki as Seed-device:

Basic idea is to make partition with original data read-only, than to "add additional layer on a top of it", which is another writeable partition (you can always make it in RAM, e.g. on /dev/shm) and mount it:

btrfstune -S 1 /dev/RO #make it read-only
mount /dev/RO /mnt/temp
btrfs device add /dev/RW /mnt/temp
umount /mnt/temp

and from that moment, each time you mount

mount /dev/RW /mnt/test

changes are saved on /dev/RW, while /dev/RO stays untouched.

(examples are based on those in wiki )

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.