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.

Let's say you have a btrfs root filesystem on an online system. You want to revert the filesystem to an earlier state, of which you have a snapshot:

remount /dev/sdaX / -o remount,subvol=snapshots/Y

For the record, I've done this in a test system, and it does not work. The command returns with no errors, but the subvolume mounted is the same.

If this did work, what would be the consequences? My guess is that open file descriptors would still point to the old subvolume, thus possibly leading to "data loss" on the new subvolume, if one was not careful. Assuming one goes to the trouble of closing and reopening all open file descriptors, does this sound feasible? Or are there other types of problems?

share|improve this question

migrated from serverfault.com Nov 11 '12 at 4:31

This question came from our site for professional system and network administrators.

add comment

1 Answer 1

No, it is not possible. Even if you could manage to redirect all IO to the new subvolume, changing files out from under an application in the middle of accessing it would hopelessly corrupt the file and confuse the application. If the file in question was a program, then it would cause the program to go haywire and only crash if you are lucky.

share|improve this answer
    
Wouldn't open file descriptors remain open? If that's the case, wouldn't the program still keep writing to the old subvolume? Obviously this wouldn't work if an application closes a file and reopens it shortly after, expecting the contents to remain the same, but don't think that's safe to assume in a sane program anyway? –  goncalopp Nov 11 '12 at 23:03
    
@goncalopp, the whole point is to NOT keep open the existing files on the old subvol. –  psusi Nov 11 '12 at 23:06
    
Indeed, thus one could, after remounting, restart daemons one by one, which would close the old FD and open new ones, which would point to the corresponding files on the new subvolume –  goncalopp Nov 11 '12 at 23:49
    
For the purpose of reverting to an old snapshot, I don't see a problem doing it on-line: most files will remain the same (even backed by the same physical block), and for files that don't - yes, I expect the application holding the file to corrupt and crash. Obviously the required functionality for the mount command was not implemented but I still think it should. –  Guss Sep 16 '13 at 16:32
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.