# Snapshots & Disk lifespan



## blazingice (Aug 19, 2013)

I am currently using sysutils/zfSnap to make rolling zfs snapshots of my second pool where I have stored my data. The system uses a separate pool. At the moment I use this scheme:

Hourly and keep for one day.
Daily and keep for one week.
Weekly and keep for one month.
Monthly and keep for one year.
My concern is that by being overzealous with snapshots I am creating a lot of disk I/O which could shorten the lifespan of the disk. This is just a home server so I am not using expensive hardware. 

So my question is, how heavy are zfs snapshots on disk I/O? From what I understand of zfs, most I/O occurs when deleting the old snapshots rather than when creating them. Does this have a negative effect on the disk lifespan? I am tempted to remove the hourly snapshots.

Thanks.


----------



## User23 (Aug 23, 2013)

blazingice said:
			
		

> So my question is, how heavy are zfs snapshots on disk I/O? From what I understand of zfs, most I/O occurs when deleting the old snapshots rather than when creating them. Does this have a negative effect on the disk lifespan? I am tempted to remove the hourly snapshots.
> 
> Thanks.



It depends on your usage. ZFS snapshots using a copy-on-write mechanism, which means if a file, that is already in a snapshot, get modified will cause a new copy of it. So the main I/O will occur while something changes and if you delete snapshots that have versions of files that are no longer needed.

Worst case would be a large image file where only a bit is changed, but the whole file needs to be rewritten (every hour?  ).


http://en.wikipedia.org/wiki/ZFS#Snapshots_and_clones


----------



## junovitch@ (Aug 25, 2013)

ZFS acts on blocks not files for changes/compression/dedup.  If you change one bit of a large file that may only be one new block, not a whole file, that it performs copy on write to.  An earlier snapshot may reference the original block while the later snapshot references the later blocks.  Deleting an earlier snapshot will free that block and end up in similar I/O to just removing the file before it got referenced by a snapshot.  Personally I wouldn't be overly worried about the disk I/O.


----------



## throAU (Aug 27, 2013)

With copy-on-write snapshots, you will more evenly spread the wear across your disk.  Implications of that I am unsure of.  But I'm not sure it will negatively impact disk life, as you will be spreading writes over more of the disk platter.

And to clarify - taking a snapshot does minimal I/O.  The I/O when an update happens to a file is just diverted to different blocks.


----------



## kpa (Aug 27, 2013)

Do you really think that snapshotting does anything out of the ordinary compared to the normal use of the disk? On the level of the disk hardware everything is just reads a writes to requested locations on the disk including creation of snapshots on the filesystem level. I'd be interested in your reasoning why snapshotting would result in out of the normal amount of reads and writes over a  period of time.


----------



## throAU (Aug 27, 2013)

If that's directed at me, I agree.

I suspect it may even INCREASE disk life, as you're spreading the wear around...

Either way, not worth worrying over.


----------



## kpa (Aug 27, 2013)

It's directed to the OP sorry.


----------



## blazingice (Aug 27, 2013)

kpa said:
			
		

> Do you really think that snapshotting does anything out of the ordinary compared to the normal use of the disk?



Originally I thought not. I understand that creating snapshot is just making a reference to the current state so there isn't a great increase of disk activity. However after reading the wiki for sysutils/zfSnap I started doubting myself. This is what is says: 



> It is probably better to delete old snapshots once a day (at least on servers), then adding -d switch to every crontab entry.
> 
> This is because deleting zfs snapshots is slower than creating them...



This led me to think that there might be a higher disk activity when deleting the history of these reference points (snapshots), especially when this is done daily at least 12 times on data that changes frequently. How much of an increase, I wasn't sure, hence the question. 

Thanks for the answers, I will keep my daily snapshots.


----------



## kpa (Aug 27, 2013)

Creating snapshots causes almost no data to be written because of copy-on-write strategy, hence the remark in the sysutils/zfSnap documentation. Again, deleting the snapshot will of course cause data to be written on the disk but the amount of writes overall will not be significant compared to normal use (unless your ZFS pool is used strictly in write once/read many times fashion, for example storage for a media server). I wouldn't worry about the amount of writes, disks are designed to be used.


----------

