Last active
November 19, 2025 23:03
-
-
Save dlangille/2578c132dc6177e2eb94ac426892da70 to your computer and use it in GitHub Desktop.
can I reduce the size of a mirror zpool?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Will this work with disk-based devices which use partitions? | |
| # Instead of /tmp/0.raw, using /dev/adap3? | |
| # create some 500M devices: | |
| root@r730-04:/tmp # for i in $(seq 10 13) ; do truncate -s 500M $i.raw ; done | |
| # and some 1G devices: | |
| root@r730-04:/tmp # for i in $(seq 0 3) ; do truncate -s 1G $i.raw ; done | |
| # the devices: | |
| root@r730-04:/tmp # ls -lh /tmp/*.raw | |
| -rw-r--r-- 1 root wheel 1.0G Nov 19 18:18 /tmp/0.raw | |
| -rw-r--r-- 1 root wheel 1.0G Nov 19 18:18 /tmp/1.raw | |
| -rw-r--r-- 1 root wheel 500M Nov 19 18:11 /tmp/10.raw | |
| -rw-r--r-- 1 root wheel 500M Nov 19 18:11 /tmp/11.raw | |
| -rw-r--r-- 1 root wheel 500M Nov 19 18:18 /tmp/12.raw | |
| -rw-r--r-- 1 root wheel 500M Nov 19 18:18 /tmp/13.raw | |
| -rw-r--r-- 1 root wheel 1.0G Nov 19 18:14 /tmp/2.raw | |
| -rw-r--r-- 1 root wheel 1.0G Nov 19 18:14 /tmp/3.raw | |
| # create a 1GB zpool | |
| root@r730-04:/tmp # zpool destroy test-pool | |
| root@r730-04:/tmp # zpool create test-pool mirror /tmp/0.raw /tmp/1.raw | |
| root@r730-04:/tmp # zpool list test-pool | |
| NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT | |
| test-pool 960M 10.4M 950M - - 0% 1% 1.00x ONLINE - | |
| root@r730-04:/tmp # zpool status test-pool | |
| pool: test-pool | |
| state: ONLINE | |
| config: | |
| NAME STATE READ WRITE CKSUM | |
| test-pool ONLINE 0 0 0 | |
| mirror-0 ONLINE 0 0 0 | |
| /tmp/0.raw ONLINE 0 0 0 | |
| /tmp/1.raw ONLINE 0 0 0 | |
| errors: No known data errors | |
| root@r730-04:/tmp # ls -l /test-pool/ | |
| total 0 | |
| root@r730-04:/tmp # dd if=/dev/random of=/test-pool/random1 bs=1m count=10 | |
| 10+0 records in | |
| 10+0 records out | |
| 10485760 bytes transferred in 0.028923 secs (362544700 bytes/sec) | |
| root@r730-04:/tmp # ls -l /test-pool/ | |
| total 1 | |
| -rw-r--r-- 1 root wheel 10485760 Nov 19 18:18 random1 | |
| root@r730-04:/tmp # | |
| # add another mirror to the zpool, with 500M devices | |
| root@r730-04:/tmp # zpool add test-pool mirror /tmp/12.raw /tmp/13.raw | |
| root@r730-04:/tmp # zpool status test-pool | |
| pool: test-pool | |
| state: ONLINE | |
| config: | |
| NAME STATE READ WRITE CKSUM | |
| test-pool ONLINE 0 0 0 | |
| mirror-0 ONLINE 0 0 0 | |
| /tmp/0.raw ONLINE 0 0 0 | |
| /tmp/1.raw ONLINE 0 0 0 | |
| mirror-1 ONLINE 0 0 0 | |
| /tmp/12.raw ONLINE 0 0 0 | |
| /tmp/13.raw ONLINE 0 0 0 | |
| errors: No known data errors | |
| root@r730-04:/tmp # ls -l /test-pool/ | |
| total 10249 | |
| -rw-r--r-- 1 root wheel 10485760 Nov 19 18:18 random1 | |
| root@r730-04:/tmp # | |
| # remove the bigger mirror: | |
| root@r730-04:/tmp # zpool remove test-pool mirror-0 | |
| # the zpool is now smaller | |
| root@r730-04:/tmp # zpool list test-pool | |
| NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT | |
| test-pool 480M 11.0M 469M - - 0% 2% 1.00x ONLINE - | |
| root@r730-04:/tmp # ls -l /test-pool/ | |
| total 10249 | |
| -rw-r--r-- 1 root wheel 10485760 Nov 19 18:18 random1 | |
| root@r730-04:/tmp # | |
| dvl@r730-04:~ $ zpool status test-pool | |
| pool: test-pool | |
| state: ONLINE | |
| remove: Removal of vdev 0 copied 10.5M in 0h0m, completed on Wed Nov 19 18:21:45 2025 | |
| 384 memory used for removed device mappings | |
| config: | |
| NAME STATE READ WRITE CKSUM | |
| test-pool ONLINE 0 0 0 | |
| mirror-1 ONLINE 0 0 0 | |
| /tmp/12.raw ONLINE 0 0 0 | |
| /tmp/13.raw ONLINE 0 0 0 | |
| errors: No known data errors | |
| dvl@r730-04:~ $ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment