Monday 22 September 2014

Snapshots are Consuming more space on root and How to reduce the root space by deleting that snapshots


bash-3.00$ df -h /
Filesystem             size   used  avail capacity  Mounted on
tank/rpool
                      234G   2.4G   231G    98%    /

To Take snapshot of a mark dataset use below command

#zfs snapshot tank/home/mark@snap1
#zfs snapshot tank/home/mark@snap2

Parent/individual Snapshots are destroyed by using the zfs destroy command

#zfs destroy tank/home/matt@friday

How to create the clone from a snapshot

# zfs clone tank/home/mark@snap2    tank/home/mark1

To List data sets and snapshots in a pool (i.e tank/home)

#zfs list -r tank/home
NAME                   USED  AVAIL  REFER  MOUNTPOINT
tank/home/snap1           0      -    34K  -
tank/home/mark/snap1      0      -  2.00G  -------->Look's Ok
tank/home/mark/snap2      550M      -  2.00G  ------->Issue space occupying on root 550MB
tank/home/matt/snap1      0      -  1.00G  -
tank/home/tom/snap1       0      -  2.00G  -
tank/home/mark1                  0      -  2.00G

If you create a snapshot from a parent snapshot then we can't delete the parent snapshot with out deleting the chaild snapshot

For that we need to find out the parent and chaild snapshots for that particular dataset by using the name,creation format.

Process:-

#zfs list -t snapshot -r tank/home
NAME                   USED  AVAIL  REFER  MOUNTPOINT
tank/home@snap1           0      -    34K  -
tank/home/mark@snap1      0      -  2.00G  -
tank/home/mark@snap2      550M -  2.00G  -
tank/home/matt@snap1      0      -  1.00G  -
tank/home/tom@snap1       0      -  2.00G  -

# zfs list -r -t snapshot -o name,creation tank/home
NAME                      CREATION
tank/home/cindy@today     Fri May  6  6:32 2011
tank/home/mark@snap1      Fri May  6  6:22 2011
tank/home/mark@snap2      Fri May  12  6:22 2012
tank/home/matt@tuesday    Tue May  3  6:27 2011
tank/home/matt@wednesday  Wed May  4  6:28 2011
tank/home/matt@thursday   Thu May  5  6:28 2012

From the above command we can find the difference in year i.e 2011 and 2012.
2012 was chaild snapshot  and 2011 was parent snapshot.


If You want to delete the snapshot of the "tank/home/mark@snap1"
Below error occurred due to parent-chaild interconnection

# zfs destroy tank/home/mark@snap1
cannot destroy 'tank/home/mark@today': snapshot has dependent clones
use '-R' to destroy the following datasets:
tank/home/mark@snap2=====>It's recommended to delete  2nd
tank/home/mark1==========>It's recommended to delete 1st

Note:-Why We have to delete "tank/home/mark1" first?

Ans :-We have created a clone copy from chaild snapshot to check the date consistency.
Before destroy the any chaild snapshot we need to clear/destroy/separate  the clone copy.


1) Find out the origin of the chaild snapshot

# zfs get origin tank/home/mark1  
NAME               PROPERTY  VALUE                      SOURCE
tank/home/mark1    origin    tank/home/mark@snap2 -


# zfs get origin tank/home/mark@snap2
NAME               PROPERTY  VALUE                      SOURCE
tank/home/mark@snap2    origin    tank/home/mark@snap1 -

# zfs get origin tank/home/mark@snap1
NAME               PROPERTY  VALUE                      SOURCE
tank/home/mark@snap1    origin    tank/home/mark  -

First We need to destroy the chaild clone i.e "tank/home/mark1"

# zfs destroy tank/home/mark1

And then

# zfs destroy tank/home/mark@snap2

Then

# zfs destroy tank/home/mark@snap1

Issue:-

If you are taking the snapshots continuously and creating a clone copy from chaild snapshots and you are not removing the previous snapshot/clones before taking the new snapshot at that time snapshots will occupy more space on root.

To clear/reduce the root space below process need to follow


Solution:- 

If you are having space in other pool.Then by using the send receive method's in zfs we can move the date from one pool to other Pool and delete the clones and snapshot copy's.
#zfs send tank/home/mark@snap2| zfs receive zpool1/test1clone.

Or

Enable the promote option in zfs .This will divide the clone from snapshot and then there was no dependence to delete the chaild snapshots.

Once if you enable this feature in zfs it's actlike individual dataset. Before enabling to this feature please check the available space in root/ANY

#zfs promote tank/home/mark1

Conclusion:-

Do send receive process from source server to destination and delete the clones and snapshots.
After deleting the clones and snapshots space will free and do vice verse.
i.e Take the snapshot from destination server and do the send receive process to source server.



No comments:

Post a Comment