Aaron Epps
2008-May-12 18:46 UTC
[zfs-discuss] Deletion of file from ZFS Disk and Snapshots
This is a common problem that we run into and perhaps there''s a good explanation of why it can''t be done. Often, there will be a large set of data, say 200GB or so that gets written to a ZFS share, snapshotted and then deleted a few days later. As I''m sure you know, none of the space is returned to the pool since the bits on disk are still being referenced by the snapshot. Is there any way to delete a large set of data both from the disk and from any snapshots that may reference this large data set? This message posted from opensolaris.org
Simon Breden
2008-May-12 19:30 UTC
[zfs-discuss] Deletion of file from ZFS Disk and Snapshots
>From my understanding, when you delete all the snapshots that reference the files that have already been deleted from the file system(s), then all the space will be returned to the pool.So try deleting the snapshots that you no longer need. Obviously, be sure that you don''t need any files referenced by the snapshots first ;-) This message posted from opensolaris.org
Aaron Epps
2008-May-13 13:28 UTC
[zfs-discuss] Deletion of file from ZFS Disk and Snapshots
See, that''s the problem. I don''t want to delete the entire snapshot, I just want to remove a particular file from the snapshot. This message posted from opensolaris.org
Simon Breden
2008-May-13 14:15 UTC
[zfs-discuss] Deletion of file from ZFS Disk and Snapshots
OK, I understand. I don''t think it''s possible though, as snapshots are read only, as far as I know. If you like voodoo you could try going into the .zfs directory, then into the snapshot directory and see what you can do there, but I wouldn''t try it, as it might be possible to do harm that way. Instead, perhaps you could: 1. do a full backup from the initial snapshot, then do incremental backups from the subsequent snapshots, if they are any. This should give you a file system containing all of the files in the current snapshots. 2. Then you could delete the file you want to remove, but this will cause some snapshots to take ownership of this deleted file. Here is an example of how to make a backup of all the data from the snapshots to a new file system. Once done, you can see about deleting the file: zfs send pool/fs at 1 | zfs recv pool/newfs (full initial backup) zfs send -i pool/fs at 1 pool/fs at 2 | zfs recv -F pool/newfs (inc. backup between snaps 1 and 2) zfs send -i pool/fs at 2 pool/fs at 3 | zfs recv -F pool/newfs (inc. backup between snaps 2 and 3) zfs send -i pool/fs at 3 pool/fs at 4 | zfs recv -F pool/newfs (inc. backup between snaps 3 and 4) etc for each snapshot until you have done all the snapshots rm /pool/newfs/file_you_want_to_delete I think there''s probably a quicker way using a snapshot range, but I didn''t try that yet. I actually wrote up some stuff on snapshots and full & incremental backups yesterday. |f it''s useful for you, I don''t know :) See: http://breden.org.uk/2008/05/12/home-fileserver-zfs-snapshots/ http://breden.org.uk/2008/05/12/home-fileserver-backups-from-zfs-snapshots/ Good luck, and let us know if you manage to make it work. This message posted from opensolaris.org
Darren J Moffat
2008-May-13 14:27 UTC
[zfs-discuss] Deletion of file from ZFS Disk and Snapshots
Simon Breden wrote:> OK, I understand. > > I don''t think it''s possible though, as snapshots are read only, as far as I know. > If you like voodoo you could try going into the .zfs directory, then into the snapshot directory and see what you can do there, but I wouldn''t try it, as it might be possible to do harm that way.There is no voodoo you could do and you can''t do any harm. You can create, rename, delete and view snapshots via the .zfs/ directory but not do any harm to ZFS. -- Darren J Moffat
Simon Breden
2008-May-13 14:33 UTC
[zfs-discuss] Deletion of file from ZFS Disk and Snapshots
Thanks Darren, that''s good to know. If multiple snapshots reference (own?) the same file, what''s the quickest way to zap that file from all snapshots? I say ''own'' because apparently the original file system that the snapshots were created from, has been deleted, apparently, if I understood the initial post correctly. 2008/5/13 Darren J Moffat <darrenm at opensolaris.org>:> Simon Breden wrote: > > > OK, I understand. > > > > I don''t think it''s possible though, as snapshots are read only, as far > > as I know. > > If you like voodoo you could try going into the .zfs directory, then > > into the snapshot directory and see what you can do there, but I wouldn''t > > try it, as it might be possible to do harm that way. > > > > There is no voodoo you could do and you can''t do any harm. > > You can create, rename, delete and view snapshots via the .zfs/ directory > but not do any harm to ZFS. > > -- > Darren J Moffat >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.opensolaris.org/pipermail/zfs-discuss/attachments/20080513/5dc21eea/attachment.html>
Marc Glisse
2008-May-13 17:02 UTC
[zfs-discuss] Deletion of file from ZFS Disk and Snapshots
Can''t you turn the snapshot into a clone (kind of an editable snapshot)? Or does the existence of a clone created from this snapshot prevent from removing the snapshot afterwards? This message posted from opensolaris.org
A Darren Dunham
2008-May-13 19:21 UTC
[zfs-discuss] Deletion of file from ZFS Disk and Snapshots
On Tue, May 13, 2008 at 10:02:01AM -0700, Marc Glisse wrote:> Can''t you turn the snapshot into a clone (kind of an editable > snapshot)? Or does the existence of a clone created from this snapshot > prevent from removing the snapshot afterwards?You can create a clone from the snapshot, but it does not turn the snapshot into a clone. Any clone created and the original filesystem are tied together through the snapshot. The snapshot can''t be destroyed as long as both exist. You can pick either one of them to be the parent, allowing you to delete the other and the snapshot. -- Darren
Nicolas Williams
2008-May-13 20:09 UTC
[zfs-discuss] Deletion of file from ZFS Disk and Snapshots
On Tue, May 13, 2008 at 04:33:29PM +0200, Simon Breden wrote:> Thanks Darren, that''s good to know. > > If multiple snapshots reference (own?) the same file, what''s the quickest > way to zap that file from all snapshots?There isn''t a way to do that at all, not short of deleting the actual snapshots (which you''ve already said you don''t want to do). I doubt there ever will be a way to do that (though that''s just an opinion informed by public information -- I don''t work for the ZFS team). Personally, I don''t think there should be a way to do that. If you''re running out of space, then add more or delete snapshots that you no longer need (backing them up if need be). Nico --
A Darren Dunham
2008-May-13 23:30 UTC
[zfs-discuss] Deletion of file from ZFS Disk and Snapshots
On Tue, May 13, 2008 at 04:33:29PM +0200, Simon Breden wrote:> > If multiple snapshots reference (own?) the same file, what''s the quickest > way to zap that file from all snapshots?There is no way. If you could do that, then they wouldn''t really be "snapshots". I''m not saying that the ability wouldn''t be useful, but it would conflict with certain expectations about what a "snapshot" is today. I had a hard enough time dealing with the ability to create and destroy sanpshots via normal filesystem semantics. The ability to modify a snapshot would throw me for a loop! -- Darren