<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Is there a way to delete an HDFS directory which might have a snapshottable directory? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Is-there-a-way-to-delete-an-HDFS-directory-which-might-have/m-p/321592#M228467</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/83034"&gt;@sipocootap2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a walkthrough on how to delete a snapshot&lt;/P&gt;&lt;P&gt;Created a directory&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -mkdir -p /app/tomtest&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Changed the owner&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -chown -R tom:developer /app/tomtest&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To be able to create a snapshot&amp;nbsp; the directory has to be snapshottable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfsadmin -allowSnapshot /app/tomtest
Allowing snaphot on /app/tomtest succeeded&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I created 3 snapshots&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -createSnapshot /app/tomtest sipo
Created snapshot /app/tomtest/.snapshot/sipo

$ hdfs dfs -createSnapshot /app/tomtest coo
Created snapshot /app/tomtest/.snapshot/coo

$ hdfs dfs -createSnapshot /app/tomtest tap2
Created snapshot /app/tomtest/.snapshot/tap2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Confirm the directory is snapshottable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs lsSnapshottableDir
drwxr-xr-x 0 tom developer 0 2021-07-26 23:14 3 65536 /app/tomtest&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;List all the snapshots in the directory&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -ls /app/tomtest/.snapshot
Found 3 items
drwxr-xr-x - tom developer 0 2021-07-26 23:14 /app/tomtest/.snapshot/coo
drwxr-xr-x - tom developer 0 2021-07-26 23:14 /app/tomtest/.snapshot/sipo
drwxr-xr-x - tom developer 0 2021-07-26 23:14 /app/tomtest/.snapshot/tap2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I need to delete the snapshot coo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -deleteSnapshot /app/tomtest/ coo&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Confirm the snapshot is gone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -ls /app/tomtest/.snapshot
Found 2 items
drwxr-xr-x - tom developer 0 2021-07-26 23:14 /app/tomtest/.snapshot/sipo
drwxr-xr-x - tom developer 0 2021-07-26 23:14 /app/tomtest/.snapshot/tap2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Voila&lt;/P&gt;&lt;P&gt;To delete a snapshot the format is &lt;FONT color="#FF0000"&gt;hdfs dfs -deleteSnapshot &amp;lt;path&amp;gt; &amp;lt;snapshotName&amp;gt;&lt;/FONT&gt; i.e&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;hdfs dfs -deleteSnapshot /app/tomtest/ coo&lt;/FONT&gt; notice the space and omittion of the &lt;FONT color="#FF0000"&gt;.snapshot&lt;/FONT&gt; as all .(dot) files the snapshot directory is not visible with normal hdfs command&lt;/P&gt;&lt;P&gt;The &lt;FONT color="#FF0000"&gt;-ls&lt;/FONT&gt; command gives 0 results&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -ls /app/tomtest/&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The special command shows the 2 remaining snapshots&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -ls /app/tomtest/.snapshot
Found 2 items
drwxr-xr-x - tom developer 0 2021-07-26 23:14 /app/tomtest/.snapshot/sipo
drwxr-xr-x - tom developer 0 2021-07-26 23:14 /app/tomtest/.snapshot/tap2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there a command to disallow snapshots for all the subdirectories? Yes there is only after you have deleted all the snapshots therein&amp;nbsp; demo, or better at directory creation time you can disallow snapshots&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfsadmin -disallowSnapshot /app/tomtest/
disallowSnapshot: The directory /app/tomtest has snapshot(s). Please redo the operation after removing all the snapshots.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only way I have found which works when for me and permits me to have a cup of coffee is to first list all the snapshots and&amp;nbsp; copy-paste the delete even if there are 60 snapshots&amp;nbsp; it works and I only get back when the snapshots are gone or better still do something else while the deletion is going on not automated though the example&lt;/P&gt;&lt;P&gt;The below would run concurrently&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;hdfs dfs -deleteSnapshot /app/tomtest/ sipo
.....
....
hdfs dfs -deleteSnapshot /app/tomtest/ tap2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;-deleteSnapshot&lt;/FONT&gt; skips trash by default!&lt;/P&gt;&lt;P&gt;Happy hadooping&lt;/P&gt;</description>
    <pubDate>Mon, 26 Jul 2021 21:53:42 GMT</pubDate>
    <dc:creator>Shelton</dc:creator>
    <dc:date>2021-07-26T21:53:42Z</dc:date>
    <item>
      <title>Is there a way to delete an HDFS directory which might have a snapshottable directory?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-there-a-way-to-delete-an-HDFS-directory-which-might-have/m-p/321580#M228460</link>
      <description>&lt;P&gt;There are user directories under hdfs:///user/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When a user `foo` retires, I need to delete a root directory for the user: hdfs:///user/foo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it occasionally fails because of the snapshottable directories under the user root directory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Checking all the subdirectories whether it's snapshottable, disallowing snapshottable subdirectories , and then deleting the user's root directory doesn't seem to be the best way.&lt;/P&gt;&lt;P&gt;(Or if this is the best way, I cannot come up with a simple code..)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a command to disallow snapshots for all the subdirectories?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I effectively delete a directory that might have snapshots?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jul 2021 14:49:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-there-a-way-to-delete-an-HDFS-directory-which-might-have/m-p/321580#M228460</guid>
      <dc:creator>sipocootap2</dc:creator>
      <dc:date>2021-07-26T14:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to delete an HDFS directory which might have a snapshottable directory?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-there-a-way-to-delete-an-HDFS-directory-which-might-have/m-p/321592#M228467</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/83034"&gt;@sipocootap2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a walkthrough on how to delete a snapshot&lt;/P&gt;&lt;P&gt;Created a directory&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -mkdir -p /app/tomtest&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Changed the owner&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -chown -R tom:developer /app/tomtest&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To be able to create a snapshot&amp;nbsp; the directory has to be snapshottable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfsadmin -allowSnapshot /app/tomtest
Allowing snaphot on /app/tomtest succeeded&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I created 3 snapshots&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -createSnapshot /app/tomtest sipo
Created snapshot /app/tomtest/.snapshot/sipo

$ hdfs dfs -createSnapshot /app/tomtest coo
Created snapshot /app/tomtest/.snapshot/coo

$ hdfs dfs -createSnapshot /app/tomtest tap2
Created snapshot /app/tomtest/.snapshot/tap2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Confirm the directory is snapshottable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs lsSnapshottableDir
drwxr-xr-x 0 tom developer 0 2021-07-26 23:14 3 65536 /app/tomtest&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;List all the snapshots in the directory&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -ls /app/tomtest/.snapshot
Found 3 items
drwxr-xr-x - tom developer 0 2021-07-26 23:14 /app/tomtest/.snapshot/coo
drwxr-xr-x - tom developer 0 2021-07-26 23:14 /app/tomtest/.snapshot/sipo
drwxr-xr-x - tom developer 0 2021-07-26 23:14 /app/tomtest/.snapshot/tap2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I need to delete the snapshot coo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -deleteSnapshot /app/tomtest/ coo&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Confirm the snapshot is gone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -ls /app/tomtest/.snapshot
Found 2 items
drwxr-xr-x - tom developer 0 2021-07-26 23:14 /app/tomtest/.snapshot/sipo
drwxr-xr-x - tom developer 0 2021-07-26 23:14 /app/tomtest/.snapshot/tap2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Voila&lt;/P&gt;&lt;P&gt;To delete a snapshot the format is &lt;FONT color="#FF0000"&gt;hdfs dfs -deleteSnapshot &amp;lt;path&amp;gt; &amp;lt;snapshotName&amp;gt;&lt;/FONT&gt; i.e&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;hdfs dfs -deleteSnapshot /app/tomtest/ coo&lt;/FONT&gt; notice the space and omittion of the &lt;FONT color="#FF0000"&gt;.snapshot&lt;/FONT&gt; as all .(dot) files the snapshot directory is not visible with normal hdfs command&lt;/P&gt;&lt;P&gt;The &lt;FONT color="#FF0000"&gt;-ls&lt;/FONT&gt; command gives 0 results&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -ls /app/tomtest/&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The special command shows the 2 remaining snapshots&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -ls /app/tomtest/.snapshot
Found 2 items
drwxr-xr-x - tom developer 0 2021-07-26 23:14 /app/tomtest/.snapshot/sipo
drwxr-xr-x - tom developer 0 2021-07-26 23:14 /app/tomtest/.snapshot/tap2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there a command to disallow snapshots for all the subdirectories? Yes there is only after you have deleted all the snapshots therein&amp;nbsp; demo, or better at directory creation time you can disallow snapshots&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfsadmin -disallowSnapshot /app/tomtest/
disallowSnapshot: The directory /app/tomtest has snapshot(s). Please redo the operation after removing all the snapshots.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only way I have found which works when for me and permits me to have a cup of coffee is to first list all the snapshots and&amp;nbsp; copy-paste the delete even if there are 60 snapshots&amp;nbsp; it works and I only get back when the snapshots are gone or better still do something else while the deletion is going on not automated though the example&lt;/P&gt;&lt;P&gt;The below would run concurrently&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;hdfs dfs -deleteSnapshot /app/tomtest/ sipo
.....
....
hdfs dfs -deleteSnapshot /app/tomtest/ tap2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;-deleteSnapshot&lt;/FONT&gt; skips trash by default!&lt;/P&gt;&lt;P&gt;Happy hadooping&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jul 2021 21:53:42 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-there-a-way-to-delete-an-HDFS-directory-which-might-have/m-p/321592#M228467</guid>
      <dc:creator>Shelton</dc:creator>
      <dc:date>2021-07-26T21:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to delete an HDFS directory which might have a snapshottable directory?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-there-a-way-to-delete-an-HDFS-directory-which-might-have/m-p/321608#M228474</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/20288"&gt;@Shelton&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the detailed steps, Shelton.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To make sure if I understood properly:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When there are snapshottable directories at&lt;/P&gt;&lt;P&gt;hdfs://user/foo/1/1-2&lt;/P&gt;&lt;P&gt;hdfs://user/foo/3/3-2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I expected something like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;hdfs dfs -disallowSnapshot -subDirsIncluded -recursively hdfs://user/foo&lt;/LI-CODE&gt;&lt;P&gt;without the need to know where the snapshots are, but you mean that there isn't such simple command, right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead, I shouild list all the snapshottable directories and delete each snapshots under the directories.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 05:13:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-there-a-way-to-delete-an-HDFS-directory-which-might-have/m-p/321608#M228474</guid>
      <dc:creator>sipocootap2</dc:creator>
      <dc:date>2021-07-27T05:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to delete an HDFS directory which might have a snapshottable directory?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-there-a-way-to-delete-an-HDFS-directory-which-might-have/m-p/321611#M228475</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/83034"&gt;@sipocootap2&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Unfortunately, you cannot disallow snapshots in a snapshottable directory that already has snapshots!&lt;/P&gt;&lt;P&gt;Yes, you will have to list and delete the snapshot even if it contains subdirs you only pass the root snapshot in the &lt;FONT color="#993300"&gt;hdfs dfs -deleteSnapshot&lt;/FONT&gt; command. If you had an&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -ls /app/tomtest/.snapshot
Found 2 items
drwxr-xr-x   - tom developer   0 2021-07-26 23:14 /app/tomtest/.snapshot/sipo/work/john
drwxr-xr-x   - tom developer   0 2021-07-26 23:14 /app/tomtest/.snapshot/tap2/work//peter&lt;/LI-CODE&gt;&lt;P&gt;You would simply delete the snapshots like&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$ hdfs dfs -deleteSnapshot /app/tomtest/ sipo
$ hdfs dfs -deleteSnapshot /app/tomtest/ tap2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2021 05:51:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-there-a-way-to-delete-an-HDFS-directory-which-might-have/m-p/321611#M228475</guid>
      <dc:creator>Shelton</dc:creator>
      <dc:date>2021-07-27T05:51:38Z</dc:date>
    </item>
  </channel>
</rss>

