How to get rid of error while deleting zfs snapshots ?

Today, I was working on issue where my ZFS file systems were full I was supposed to clear some space from it. I found that snapshots were created for file system and has not been deleted for long time.

I have simulated the same case in my Lab environment.

My Lab Set up :

  • Solaris 10 64 bit
  • pool name pool1
  • file system zfs1, zfs2.

Step 1 : I have created pool1 on one disk.

bash-3.2# zpool status pool1
pool: pool1
state: ONLINE
scan: none requested
config:

NAME STATE READ WRITE CKSUM
pool1 ONLINE 0 0 0
c1t2d0 ONLINE 0 0 0

Step 2 : Created file system using that pool1.

bash-3.2# zfs create pool1/zfs1

bash-3.2# zfs list -r pool1/zfs1
NAME USED AVAIL REFER MOUNTPOINT
pool1/zfs1 31K 976M 31K /pool1/zfs1

bash-3.2# cd /pool1/zfs1

bash-3.2# touch file1 file2

bash-3.2# ls
file1 file2

Step 3 : I created snapshot of file system (zfs1). Snapshot name I have given is snap1.

bash-3.2# zfs snapshot pool1/zfs1@snap1

bash-3.2# zfs list -r pool1
NAME USED AVAIL REFER MOUNTPOINT
pool1 1.14M 975M 32K /pool1
pool1/zfs1 1.04M 975M 1.04M /pool1/zfs1
pool1/zfs1@snap1 0 – 1.04M –

Step 4 : I created another file system named zfs2 from snapshot created in previous step. 

bash-3.2# zfs clone pool1/zfs1@snap1 pool1/zfs2

I issued below command to check the origin of file systems. Here I can see that zfs1 has been manually created hence showing origin nothing but zfs2 has been created from snapshot hence showing origin as snapshot.

1

Step 5 : I went to created file system in previous step and created two more files. Now along with file3 and file4, file1, file2 will be also present in that file system which are created in step 2. I hope you get that point. 

bash-3.2# cd /pool1/zfs2

bash-3.2# touch file3

bash-3.2# touch file4

bash-3.2# ls

file1 file2 file3 file4

Step 6 : Now if I am trying to delete the snapshot it is giving me the error because we have created one file system from snapshot.

bash-3.2# zfs destroy pool1/zfs1@snap1
cannot destroy ‘pool1/zfs1@snap1’: snapshot has dependent clones
use ‘-R’ to destroy the following datasets:
pool1/zfs2

To get rid of the above error we need to promote the file system. Compare below output with step 4 output.

bash-3.2# zfs promote pool1/zfs2

2 promote

Step 7 : Again trying to delete the file system still getting error. We have to delete one file system either it could be the clone file system (zfs2) which we have created from snapshot or the original file system (zfs1) which we have created manually.

bash-3.2# zfs destroy pool1/zfs2@snap1
cannot destroy ‘pool1/zfs2@snap1’: snapshot has dependent clones
use ‘-R’ to destroy the following datasets:
pool1/zfs1

Used below command to delete the snapshot along with zfs1.

bash-3.2# zfs destroy -R pool1/zfs2@snap1

Now we are left with zfs2 only.

3

What will happen your data. You data will remain in zfs2 file system. If you have changed anything in zfs1 file system after creating the snapshot in Step 3 then you will loose that data.

bash-3.2# pwd
/pool1/zfs2
bash-3.2# ls
file1 file2 file3 file4
References:
Oracle Doc ID 1552965.1 (You need oracle credentials to access the doc).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s