Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Feb 2018 00:00:33 +0100
From:      Dave Cottlehuber <dch@skunkwerks.at>
To:        freebsd-questions@freebsd.org, byrnejb@harte-lyne.ca
Subject:   Re: Resetting zfs snapshots
Message-ID:  <1519340433.3372351.1280283944.09E847B7@webmail.messagingengine.com>
In-Reply-To: <a4990c9f32d613211008307e23ecbc47.squirrel@webmail.harte-lyne.ca>
References:  <a4990c9f32d613211008307e23ecbc47.squirrel@webmail.harte-lyne.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 22 Feb 2018, at 22:29, James B. Byrne via freebsd-questions wrote:
> I am in the process of setting up a new FreeBSD server which involves
> transferring a large amount of data onto.  The system was installed
> with root zfs and snapshots were initialised immediately.
> 
> Several iterations of test data transfer and deletes has now resulted
> in snapshots exceeding 64 Gb.  I wish to effectively restart/rebase
> snapshots following the final transfer and eliminate all previous
> ones.
> 
> What is the safest way to do this?

-read the manpage for `zfs destroy` carefully ;-) and make a backup.

start off using:

zfs destroy -vn zroot/path/to/dataset@first-snapshot%last-snapshot

the -n ensures it only displays what it *would* do, but actually makes
no changes.

the @first%last is an inclusive range so the destruction would include:

- first
- last
- everything in between

You may want -r which does this same range destruction for all
child datasets.

If your goal is to *recursively* nuke all snapshots prior to "now" then you can:

# make a snapshot right now that will be destroyed in the inclusive range
zfs snapshot -r zroot@before
# this snapshot will live on in infamy long after its comrades are gone
zfs snapshot -r zroot@now
# use the inclusive range to trash all preceding snapshots
zfs destroy -vrn zroot@%before
# at this point a backup is a really good idea
zfs send -LevR zroot@now > somewhere/with/space

I highly recommend Jude + Lucas'  zfs books, well worth every penny.

Also, if you're not using boot environments, start now. they are the best
thing since zfs. You have a good opportunity to test these out before your
system is live.

[1]: sysutils/beadm-devel
[2]: http://www.callfortesting.org/bhyve-boot-environments/

A+
Dave



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1519340433.3372351.1280283944.09E847B7>