Originally posted by Snowhog
View Post
Snapshots are not copies of files. The files are already there. It copies the metadata. So a "pointer" to a file now exists in two places. If you "delete" a file from subvolume A, the metadata in that subvolume is deleted, but subvolume B remains untouched so the file is still there in B.
So to your example Snowhog:
Subvolume A contains 1000 files using 10GB.
A snapshot of A is made and it's named subvolume B.
All 1000 files that are in A are also in B.
The used space on your drive does not change - still 10GB in use.
You delete subvolume A.
All 1000 files that formerly were in A are still in B.
The used space on your drive does not change - still 10GB in use.
A snapshot of A is made and it's named subvolume B.
All 1000 files that are in A are also in B.
The used space on your drive does not change - still 10GB in use.
You delete subvolume A.
All 1000 files that formerly were in A are still in B.
The used space on your drive does not change - still 10GB in use.
The changes occur when you change a file that is part of a snapshot. So given that A and B still exist:
You delete a file from subvolume A of 500MB.
Subvolume A now contains 999 files totaling 9.5GB.
All 1000 files that formerly were in A are still in B.
The used space on your drive does not change - still 10GB in use.
You add 10 files totaling 2GB to subvolume B.
Subvolume A still contains 999 files totaling 9.5GB.
Subvolume B now contains all the original 1000 files plus the 10 new ones and totals 12GB.
The used space on your drive grows to 12GB.
Subvolume A now contains 999 files totaling 9.5GB.
All 1000 files that formerly were in A are still in B.
The used space on your drive does not change - still 10GB in use.
You add 10 files totaling 2GB to subvolume B.
Subvolume A still contains 999 files totaling 9.5GB.
Subvolume B now contains all the original 1000 files plus the 10 new ones and totals 12GB.
The used space on your drive grows to 12GB.
As you add and subtract files from each subvolume, they expand and contract accordingly, but the total space occupied on the file system (remember a snapshot must be co-located on the same file system as it's source) is the total amount of SHARED files (not two times the amount, just once) plus the total amount of DIFFERENT files.
In the EXT4 world, if you copied an entire partition, they have no relationship to each other. Therefore, the amount of used space doubles. Snapshots share filesystem space until a difference is introduced into one or both of the subvolumes.
A real world example:
Prior to a new kernel install, take a snapshot.
Zero bytes added to the file system.
Install the new kernel and delete an old kernel.
New kernel adds 100MB and old kernel removes 90MB.
The file system grows by 100MB. It does not reduce by 90MB because the old kernel is still alive and well in the snapshot.
All is well? - Delete the snapshot. file system shrinks by 90MB.
All is not well? - Reboot to the snapshot and delete the source subvolume, file system shrinks by 100MB.
Zero bytes added to the file system.
Install the new kernel and delete an old kernel.
New kernel adds 100MB and old kernel removes 90MB.
The file system grows by 100MB. It does not reduce by 90MB because the old kernel is still alive and well in the snapshot.
All is well? - Delete the snapshot. file system shrinks by 90MB.
All is not well? - Reboot to the snapshot and delete the source subvolume, file system shrinks by 100MB.
Deleting the snapshot removes the old kernel from the file system. Deleting the source subvolume removes the new kernel. ALL the other files remain in place and unchanged.
Does this help at all?
Comment