Online remount btrfs of root filesystem with different subvolume (snapshot)

btrfsmountsnapshot

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?

Best Answer

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.

Related Question