{"id":3551,"date":"2014-06-23T11:27:53","date_gmt":"2014-06-23T16:27:53","guid":{"rendered":"http:\/\/icesquare.com\/wordpress\/?p=3551"},"modified":"2015-04-28T21:08:45","modified_gmt":"2015-04-29T02:08:45","slug":"how-to-expand-zfs","status":"publish","type":"post","link":"https:\/\/icesquare.com\/wordpress\/how-to-expand-zfs\/","title":{"rendered":"How to Expand ZFS"},"content":{"rendered":"<p>Today I am going to share my story with you on how to expand my ZFS storage. I have a giant ZFS pool, which consists of 8x2TB (RAIDZ2) and 4&#215;1.5TB (RAIDZ1), with a total of 15TB usable spaces. Since I am running out of space, I decide to upgrade the ZFS by replacing the disks one at a time. So here is the ZFS structure: <\/p>\n<pre style=\"margin-top:180px;\">\r\n#zpool status\r\n        NAME        STATE     READ WRITE CKSUM\r\n        storage     ONLINE       0     0     0\r\n          raidz2-0  ONLINE       0     0     0\r\n            ada0    ONLINE       0     0     0\r\n            ada1    ONLINE       0     0     0\r\n            ada3    ONLINE       0     0     0\r\n            ada4    ONLINE       0     0     0\r\n            ada5    ONLINE       0     0     0\r\n            ada6    ONLINE       0     0     0\r\n            ada7    ONLINE       0     0     0\r\n            ada8    ONLINE       0     0     0\r\n          raidz1-1  ONLINE       0     0     0\r\n            da0     ONLINE       0     0     0\r\n            da1     ONLINE       0     0     0\r\n            da2     ONLINE       0     0     0\r\n            da3     ONLINE       0     0     0\r\n\r\n\r\n#df\r\nstorage\/data     14T     13T    1.3T    91%    \/storage\/\r\n<\/pre>\n<p>What I decide to do is to replace the 1.5TB disks by 3TB disks (i.e., da[0-3]) one at a time. Basically, here are the steps you typically found on the <a href=\"http:\/\/jsosic.wordpress.com\/2013\/01\/01\/expanding-zfs-zpool-raid\/\" target=\"_blank\">web<\/a>:<\/p>\n<ol>\n<li>Power down the server<\/li>\n<li>Replace the 1.5TB disk by 3TB disk one at a time<\/li>\n<li>Power on the server<\/li>\n<li>Replace the disk<\/li>\n<li>Resilver the entire pool.<\/li>\n<li>Hope the resilver process does not return any error.<\/li>\n<li>Repeat the above steps until all disks are replaced.<\/li>\n<li>Turn on the auto expand option and enjoy the extra space<\/li>\n<\/ol>\n<p>Here are the corresponding commands. After replacing the first disk, you should see the following:<\/p>\n<pre>\r\n#zpool status\r\n        NAME        STATE     READ WRITE CKSUM\r\n        storage     DEGRADED     0     0     0\r\n          raidz2-0  ONLINE       0     0     0\r\n            ada0    ONLINE       0     0     0\r\n            ada1    ONLINE       0     0     0\r\n            ada3    ONLINE       0     0     0\r\n            ada4    ONLINE       0     0     0\r\n            ada5    ONLINE       0     0     0\r\n            ada6    ONLINE       0     0     0\r\n            ada7    ONLINE       0     0     0\r\n            ada8    ONLINE       0     0     0\r\n          raidz1-1  DEGRADED     0     0     0\r\n            da0     UNAVAI       0     0     0 cannot open\r\n            da1     ONLINE       0     0     0\r\n            da2     ONLINE       0     0     0\r\n            da3     ONLINE       0     0     0\r\n<\/pre>\n<p>However, the pool will continue to work because it is a RAIDZ pool. So I decide to swap the 1.5TB with the 3TB disk:<\/p>\n<pre>\r\n#sudo zpool replace mypool da0\r\n<\/pre>\n<pre>\r\n#zpool status\r\n        NAME        STATE     READ WRITE CKSUM\r\n        storage     DEGRADED     0     0     0\r\n          raidz2-0  ONLINE       0     0     0\r\n            ada0    ONLINE       0     0     0\r\n            ada1    ONLINE       0     0     0\r\n            ada3    ONLINE       0     0     0\r\n            ada4    ONLINE       0     0     0\r\n            ada5    ONLINE       0     0     0\r\n            ada6    ONLINE       0     0     0\r\n            ada7    ONLINE       0     0     0\r\n            ada8    ONLINE       0     0     0\r\n          raidz1-1  DEGRADED     0     0     0\r\n      replacing-2   DEGRADED     0     0     0\r\n        da0\/old     FAULTED      0     0     0  corrupted data\r\n        da0         ONLINE       0     0     0  (resilvering)\r\n            da1     ONLINE       0     0     0\r\n            da2     ONLINE       0     0     0\r\n            da3     ONLINE       0     0     0\r\n<\/pre>\n<p>Depending on how much data you have on the old disk and the hardware (such as motherboard, SATA configurations etc), resilvering a 1.5TB drive (with 1.3TB of data) took me about 15 hours. Personally, I recommend to start this process in the morning, then you can check the progress and start the next one in the evening. That way you can speed up the work.<\/p>\n<p>So after the resilvering process is done. Make sure that you check the error status. If some files were missing, you need to delete those files first and restore them from your backup. Here is an example of the error:<\/p>\n<pre>\r\n#sudo zpool status -v\r\n\r\nerrors: Permanent errors have been detected in the following files: \r\n\r\n\/storage\/data\/aaa\r\n\/storage\/data\/bbb\r\n\/storage\/data\/ccc\r\n<\/pre>\n<p>Remember, you need to delete the file first, then put the file back from your backup. If you simply replace\/overwrite the file, it will not clear the error. Try to check the status again. If the error is not gone yet, you may want to scrub the zpool to trigger the resilver process.<\/p>\n<pre>\r\nsudo zpool scrub mypool\r\n<\/pre>\n<p>Or you can try to clear the error message. It will trigger the resilver process automatically.<\/p>\n<pre>\r\nsudo zpool clear -f mypool\r\n<\/pre>\n<p>I know what you are trying to say now. How come the ZFS will lose the data even I have RAIDZ and checksum enabled? I have no idea. That&#8217;s why we need back up on a different machine. Anyway, the resilver process will take another 15 hours.<\/p>\n<p>After the error is cleared, repeat the steps to replace the disks one by one. Make sure that the error is cleared after every replacement. For me, replacing four hard drives took me exact 5 days, or 120 hours in total. Yes, it is not a fun job.<\/p>\n<p>So after everything is completed, no error or anything bad. You try to check the pool status and you expect a magic will happen. Unfortunately, you will see the same amount of space available. Here are what you will need to do:<\/p>\n<pre>\r\n#I still have 1.3TB space left.\r\nstorage\/data     14T     13T    1.3T    91%    \/storage\/\r\n<\/pre>\n<pre>\r\nsudo zpool set autoexpand=on mypool \r\n<\/pre>\n<p>Locate one of the disks you have replaced, in my case, they are da0, da1, da2 and da3<\/p>\n<pre>\r\n#zpool status\r\n        NAME        STATE     READ WRITE CKSUM\r\n        storage     ONLINE       0     0     0\r\n          raidz2-0  ONLINE       0     0     0\r\n            ada0    ONLINE       0     0     0\r\n            ada1    ONLINE       0     0     0\r\n            ada3    ONLINE       0     0     0\r\n            ada4    ONLINE       0     0     0\r\n            ada5    ONLINE       0     0     0\r\n            ada6    ONLINE       0     0     0\r\n            ada7    ONLINE       0     0     0\r\n            ada8    ONLINE       0     0     0\r\n          raidz1-1  ONLINE       0     0     0\r\n            da0     ONLINE       0     0     0 --This\r\n            da1     ONLINE       0     0     0 --This\r\n            da2     ONLINE       0     0     0 --This\r\n            da3     ONLINE       0     0     0 --And this\r\n<\/pre>\n<pre>\r\nsudo zpool online -e mypool da0\r\n<\/pre>\n<p>And check the space again&#8230;<\/p>\n<pre>\r\n#Now I have 5.3TB space available.\r\nstorage     18T     13T    5.3T    72%    \/storage\r\n<\/pre>\n<p>FYI, here is the math behind the free space calculations. I had 4 x 1.5TB on a RAIDZ1 setup. After the upgrade, I have 4 x 3TB on a RAIDZ1 set up. The increase space will be (3TB &#8211; 1.5TB) x (4 &#8211; 1) * 0.9 = 4TB<\/p>\n<p>Enjoy the new space!<\/p>\n<p>If you have spent too many hours on the resilvering process, consider the old school way. My old school method is nothing new, but it is rock solid, reliable, takes shorter time and most importantly, no data will be lost. Yes, you are right, I back up the data to another server first, and then I rebuild the ZFS pool on my main server, and copy the data back. Typically, copying the 10TB of data via <a href=\"\/wordpress\/how-to-improve-rsync-performance\/\">rsync daemon<\/a> over a gigabit network will take about 3 days. So it isn&#8217;t too bad. The only down side of this solution is the down time, which is about 3 days in my case. If you decide to go with the ZFS replacement, the downtime will be minimized, because the ZFS pool will continue to work during the resilver process.<\/p>\n<p>Further read: <a href=\"\/wordpress\/how-to-improve-rsync-performance\/\">How to Improve Rsync Performance<\/a><\/p>\n<p>Hope my solutions help!<\/p>\n<p>&#8211;Derrick<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I am going to share my story with you on how to expand my ZFS storage. I have a giant ZFS pool, which consists of 8x2TB (RAIDZ2) and 4&#215;1.5TB <a class=\"more-link\" href=\"https:\/\/icesquare.com\/wordpress\/how-to-expand-zfs\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"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,146,7,144,6,109],"tags":[177],"class_list":["post-3551","post","type-post","status-publish","format-standard","hentry","category-computer-problems-computer-help-pc-support","category-everyday-computer-problem","category-freebsd","category-sever-problem","category-technology","category-zfs","tag-zfs"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p1sqzr-Vh","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":3743,"url":"https:\/\/icesquare.com\/wordpress\/zfs-performance-mirror-vs-raidz-vs-raidz2-vs-raidz3-vs-striped\/","url_meta":{"origin":3551,"position":0},"title":"ZFS Performance: Mirror VS RAIDZ VS RAIDZ2 vs RAIDZ3 vs Striped","author":"Derrick","date":"September 25, 2014","format":false,"excerpt":"I always wanted to find out the performance difference among different ZFS types, such as mirror, RAIDZ, RAIDZ2, RAIDZ3, Striped, two RAIDZ vdevs vs one RAIDZ2 vdev etc. So I decide to create an experiment to test these ZFS types. Before we talk about the test result, let's go over\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":3551,"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":3458,"url":"https:\/\/icesquare.com\/wordpress\/how-to-stress-test-zfs-system\/","url_meta":{"origin":3551,"position":2},"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":2562,"url":"https:\/\/icesquare.com\/wordpress\/freebsd-9-zfs-one-or-more-devices-has-experienced-an-error-resulting-in-data-corruption-applications-may-be-affected\/","url_meta":{"origin":3551,"position":3},"title":"[FreeBSD+ZFS]One or more devices has experienced an error resulting in data corruption.  Applications may be affected.","author":"Derrick","date":"January 17, 2012","format":false,"excerpt":"When you check the ZFS status, you may find the following error message: One or more devices has experienced an error resulting in data corruption. Applications may be affected.. There can be million reasons to cause this error message showing up. Of course, 99% of them are caused by hardware\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":4286,"url":"https:\/\/icesquare.com\/wordpress\/how-to-install-zfs-on-rhel-centos-7\/","url_meta":{"origin":3551,"position":4},"title":"How to install ZFS on RHEL \/ CentOS 7","author":"Derrick","date":"January 4, 2017","format":false,"excerpt":"A friend of mine likes to try ZFS on CentOS 7, therefore I decide to make a guide for him. The following instructions have been well tested on CentOS 7. Before you decide to put ZFS in a production use, you should be aware of the following: ZFS is originally\u2026","rel":"","context":"In &quot;Everyday Computer Problem&quot;","block_context":{"text":"Everyday Computer Problem","link":"https:\/\/icesquare.com\/wordpress\/category\/everyday-computer-problem\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2011\/01\/zfs_logo.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":4377,"url":"https:\/\/icesquare.com\/wordpress\/zfs-cluster-a-network-based-zfs-implementation\/","url_meta":{"origin":3551,"position":5},"title":"ZFS Cluster: A Network-Based ZFS Implementation","author":"Derrick","date":"June 5, 2017","format":false,"excerpt":"I always like to experimenting the idea of building a ZFS cluster, i.e., it has the robust of the ZFS with the cluster capacity. So I came up a test environment with this prototype. Keep in mind that this is just a proof of concept rather than a production-ready solution.\u2026","rel":"","context":"In &quot;Everyday Computer Problem&quot;","block_context":{"text":"Everyday Computer Problem","link":"https:\/\/icesquare.com\/wordpress\/category\/everyday-computer-problem\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2017\/06\/ZFS-Based-Network.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2017\/06\/ZFS-Based-Network.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2017\/06\/ZFS-Based-Network.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2017\/06\/ZFS-Based-Network.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/3551","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=3551"}],"version-history":[{"count":32,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/3551\/revisions"}],"predecessor-version":[{"id":3942,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/3551\/revisions\/3942"}],"wp:attachment":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/media?parent=3551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/categories?post=3551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/tags?post=3551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}