{"id":3242,"date":"2013-05-14T13:26:57","date_gmt":"2013-05-14T18:26:57","guid":{"rendered":"http:\/\/icesquare.com\/wordpress\/?p=3242"},"modified":"2019-02-07T00:18:19","modified_gmt":"2019-02-07T06:18:19","slug":"freebsdhow-to-remove-zfs-meta-data","status":"publish","type":"post","link":"https:\/\/icesquare.com\/wordpress\/freebsdhow-to-remove-zfs-meta-data\/","title":{"rendered":"[FreeBSD\/Linux]How To Remove ZFS Meta Data"},"content":{"rendered":"<p>I have many hard drives circulating among my servers for testing purpose. For example, I took a hard drive from one server and put it on a different server. After doing this for many times, I&#8217;ve noticed that the ZFS has put many header information \/ meta data left on my hard drive. While it does not do anything harmful to the normal ZFS operation, I think it is not a good idea to have some outdated information living on my hard drive.\n<\/p>\n<p>Here is an example:<\/p>\n<pre>\r\n#sudo zpool import\r\n\r\n  pool: storage\r\n    id: 4394681882400895515\r\n state: UNAVAIL\r\nstatus: The pool was last accessed by another system.\r\naction: The pool cannot be imported due to damaged devices or data.\r\n   see: http:\/\/www.sun.com\/msg\/ZFS-8000-EY\r\nconfig:\r\n\r\n        storage                   UNAVAIL  insufficient replicas\r\n          raidz1-0                UNAVAIL  insufficient replicas\r\n            12688516256739208392  UNAVAIL  cannot open\r\n            ada3                  ONLINE\r\n            4218969245912188584   UNAVAIL  cannot open\r\n            1537006695366032450   UNAVAIL  cannot open\r\n            8194123525800888894   UNAVAIL  cannot open\r\n            13778624724471040977  UNAVAIL  cannot open\r\n\r\n  pool: storage\r\n    id: 12159013771499288095\r\n state: FAULTED\r\nstatus: One or more devices contains corrupted data.\r\naction: The pool cannot be imported due to damaged devices or data.\r\n        The pool may be active on another system, but can be imported using\r\n        the '-f' flag.\r\n   see: http:\/\/www.sun.com\/msg\/ZFS-8000-5E\r\nconfig:\r\n\r\n        storage                FAULTED  corrupted data\r\n          6113585248511400089  UNAVAIL  corrupted data\r\n\r\n<\/pre>\n<p>Although ZFS provides a way (zpool labelclear) to remove this information, it only works if the hard drive is still attached to the server. If the hard drive is missing, there is nothing you can do. For example, the following command will be failed:<\/p>\n<pre>\r\n#sudo zpool labelclear -f ada3\r\n<\/pre>\n<p>I googled for solutions and I found many idea. Unfortunately, none of them works. <\/p>\n<p>Anyway, I came up a solution that is quick, easy and simple. Since ZFS stores the header information in the first and last sector of the hard drive, all I need to do is to wipe out the first and the last sector. That&#8217;s it.<\/p>\n<h3>How To Remove ZFS Meta Data &#8211; Linux<\/h3>\n<pre>\r\n#replace \/dev\/sdXX with that actual ID of your hard drive\r\ndd if=\/dev\/zero of=\/dev\/sdXX bs=512 count=10\r\ndd if=\/dev\/zero of=\/dev\/sdXX bs=512 seek=$(( $(blockdev --getsz \/dev\/sdXX) - 4096 )) count=1M\r\n<\/pre>\n<p>That&#8217;s it for Linux. Below is the FreeBSD version.<\/p>\n<h3>How To Remove ZFS Meta Data &#8211; FreeBSD<\/h3>\n<p>First, you will need to identify which hard drive you want to clean up. The easiest way is to use dmesg<\/p>\n<pre>\r\n#dmesg\r\n\r\n\r\nor \r\n\r\n#dmesg | grep ada | grep MB | grep -v 'MB\/s'\r\n\r\n\r\nwhich will return something like this:\r\n\r\n\r\nada0: 381554MB (781422768 512 byte sectors: 16H 63S\/T 16383C)\r\nada1: 1430799MB (2930277168 512 byte sectors: 16H 63S\/T 16383C)\r\nada2: 953869MB (1953525168 512 byte sectors: 16H 63S\/T 16383C)\r\nada3: 953869MB (1953525168 512 byte sectors: 16H 63S\/T 16383C)\r\nada4: 1430799MB (2930277168 512 byte sectors: 16H 63S\/T 16383C)\r\n<\/pre>\n<p>Next, I need to know which one is the system hard drive, something I don&#8217;t want to touch.<\/p>\n<pre>\r\n#df\r\n\r\n\/dev\/ada0p2    362G    3.6G    329G     1%    \/\r\ndevfs          1.0k    1.0k      0B   100%    \/dev\r\n<\/pre>\n<p>In this example, my goal is very clear. I need to wipe clear ada1, ada2, ada3 and ada4, and leave ada0 untouched.<\/p>\n<p>Next, I need to clear the first sector:<\/p>\n<pre>\r\n#sudo dd if=\/dev\/zero of=\/dev\/ada1 count=1 bs=512k\r\n\r\nrepeat this for the other hard drives\r\n<\/pre>\n<p>Next, I need to clear the last sector. You can use the sector information from dmesg (if available), or you can use the following command to find the location of the last sector:<\/p>\n<pre>\r\n#sudo diskinfo -c \/dev\/ada1\r\n\r\nwhich will return something like the following:\r\n\r\n\/dev\/ada1\r\n        512             # sectorsize\r\n        1500301910016   # mediasize in bytes (1.4T)\r\n        2930277168      # mediasize in sectors\r\n        0               # stripesize\r\n        0               # stripeoffset\r\n        2907021         # Cylinders according to firmware.\r\n        16              # Heads according to firmware.\r\n        63              # Sectors according to firmware.\r\n        S1Y6J1KS710613  # Disk ident.\r\n\r\nI\/O command overhead:\r\n        time to read 10MB block      0.091942 sec       =    0.004 msec\/sector\r\n        time to read 20480 sectors   1.945038 sec       =    0.095 msec\/sector\r\n        calculated command overhead                     =    0.090 msec\/sector\r\n\r\n<\/pre>\n<p>In this example, the total number of sector is 2930277168 (mediasize in sectors).<\/p>\n<p>To keep things simple, I am going to wipe out the hard drive from 2930270000 to the end (Replace the last four digits of the sector size to zero).<\/p>\n<pre>\r\n#sudo dd if=\/dev\/zero of=\/dev\/ada1 oseek=293027000\r\n<\/pre>\n<p>Now, repeat the same thing for each hard drive. Keep in mind that the sector size of each hard drive may not be the same. So it is better to run the command and get the sector information first.<\/p>\n<p>After running these commands, the ZFS meta information should be removed. You can verify your work by doing this:<\/p>\n<pre>\r\n#sudo zfs import\r\n\r\n\r\nwhich should output nothing.\r\n<\/pre>\n<p>That&#8217;s it. Enjoy building a new ZFS!<\/p>\n<p>&#8211;Derrick<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have many hard drives circulating among my servers for testing purpose. For example, I took a hard drive from one server and put it on a different server. After <a class=\"more-link\" href=\"https:\/\/icesquare.com\/wordpress\/freebsdhow-to-remove-zfs-meta-data\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":2524,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[94,7,144,6,69,109],"tags":[],"class_list":["post-3242","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-computer-problems-computer-help-pc-support","category-freebsd","category-sever-problem","category-technology","category-troubleshooting-technology","category-zfs"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p1sqzr-Qi","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":3458,"url":"https:\/\/icesquare.com\/wordpress\/how-to-stress-test-zfs-system\/","url_meta":{"origin":3242,"position":0},"title":"How to Stress Test ZFS System","author":"Derrick","date":"January 26, 2014","format":false,"excerpt":"If you have set up a ZFS system, you may want to stress test the system before putting it in a production environment. There are many different ways to stress test the system. The most common way is to fill the entire pool using dd. However, I think scrubbing the\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4830,"url":"https:\/\/icesquare.com\/wordpress\/zfshow-to-repair-a-zfs-pool-if-one-device-was-damaged\/","url_meta":{"origin":3242,"position":1},"title":"[ZFS]How to repair a ZFS pool if one device was damaged","author":"Derrick","date":"November 13, 2020","format":false,"excerpt":"Today, I accidentally dd'ed a disk which was part of an active ZFS pool on my test server. I dd'ed the first and the last 10 sectors of the disk. Technically I didn't lose any data because my ZFS configuration was RAIDZ. However once I rebooted my computer, my ZFS\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3914,"url":"https:\/\/icesquare.com\/wordpress\/zfs-linux-vs-freebsd\/","url_meta":{"origin":3242,"position":2},"title":"Running ZFS on Linux: Things you should know and be aware of","author":"Derrick","date":"February 29, 2016","format":false,"excerpt":"First Published: Feb 29, 2016 Last Revised: January 10, 2026 ZFS is a next-generation file system renowned for its reliability and advanced features. However, due to legal and licensing issues, it is not included by default in most Linux distributions. Fortunately, you can still install (ZFS on Linux) with just\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1214,"url":"https:\/\/icesquare.com\/wordpress\/building-a-super-large-and-reliable-file-server-with-mixed-size-of-harddisks\/","url_meta":{"origin":3242,"position":3},"title":"Building a Super Large and Reliable File Server with Mixed Size of Harddisks","author":"Derrick","date":"January 17, 2011","format":false,"excerpt":"In this article, I am going to show you how to build a super large, ultra reliable, expandable file server with mixed size of hard drives. Here is my criteria: Large Storage Capacity. At this moment, the largest hard drive is 2TB. I am looking for at least 10TB. Great\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"\/wordpress\/wp-content\/uploads\/2011\/01\/zfs_logo-150x150.jpg","width":350,"height":200},"classes":[]},{"id":4648,"url":"https:\/\/icesquare.com\/wordpress\/zfs-on-linux-what-to-do-when-resilver-takes-very-long\/","url_meta":{"origin":3242,"position":4},"title":"[ZFS On Linux] What to Do When Resilver Takes Very Long","author":"Derrick","date":"January 13, 2020","format":false,"excerpt":"If you check your Zpool health status and you notice an error like the following: sudo zpool status pool: myzpool state: DEGRADED status: One or more devices are faulted in response to persistent errors. Sufficient replicas exist for the pool to continue functioning in a degraded state. action: Replace the\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3438,"url":"https:\/\/icesquare.com\/wordpress\/zfs-performance-boostimprovement-how-i-push-the-io-speed-to-126mbps\/","url_meta":{"origin":3242,"position":5},"title":"ZFS Performance Boost\/Improvement: How I push the I\/O speed to 126MBps","author":"Derrick","date":"January 25, 2014","format":false,"excerpt":"This article is part of my main ZFS tutorial: How to improve ZFS performance. That article covers everything you need. If you already have the basic knowledge, or you just want to know how I push the I\/O speed to 120+ MBps, you can skip that article and read this\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=1050%2C600&ssl=1 3x"},"classes":[]}],"jetpack_featured_media_url":"https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2012\/01\/400px-broom_icon.png","_links":{"self":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/3242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/comments?post=3242"}],"version-history":[{"count":14,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/3242\/revisions"}],"predecessor-version":[{"id":4579,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/3242\/revisions\/4579"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/media\/2524"}],"wp:attachment":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/media?parent=3242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/categories?post=3242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/tags?post=3242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}