meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
linux:fs:zfs:shrink [2021/11/07 20:37] – created niziaklinux:fs:zfs:shrink [2024/02/16 07:49] (current) niziak
Line 1: Line 1:
-====== ZFS shrink pool ======+====== ZFS: resize zpool ======
  
-Shrink zpool is not possible, but trick with 2nd device (or even file) works:+===== extend pool ===== 
 + 
 +Get device name used in pool: 
 +<code bash> 
 +zpool status nvmpool 
 +</code> 
 + 
 +<code bash> 
 +# resize /dev/nvme0n1p3 
 +parted /dev/nvme0n1 
 +</code> 
 + 
 +<code> 
 +resizepart 3 
 +End ? [X.XGB]? 
 +quit 
 +</code> 
 + 
 +<code bash> 
 +zpool online -e nvmpool nvme0n1p3 
 +</code> 
 + 
 +====== ZFS: shrink zpool ====== 
 + 
 +Shrinking of zpool is not possible, but trick with 2nd device (or even file) works:
   * add 2nd device to zpool (can be smaller - only to fit data)   * add 2nd device to zpool (can be smaller - only to fit data)
   * remove 1st device - zpool will copy all data to another device.   * remove 1st device - zpool will copy all data to another device.
-  * to create mirror, use ''attach'' not ''add'+  * to create mirror, use ''attach'' not ''add''
  
  
 <code bash> <code bash>
 +zpool list rpool -v
 zpool offline rpool /dev/disk/by-id/SECOND-part3 zpool offline rpool /dev/disk/by-id/SECOND-part3
 zpool detach rpool /dev/disk/by-id/SECOND-part3 zpool detach rpool /dev/disk/by-id/SECOND-part3
 </code> </code>
  
-Resize /dev/disk/by-id/SECOND-part3 to smaller size.+Resize ''/dev/disk/by-id/SECOND-part3'' to smaller size.
  
 <code bash> <code bash>
Line 19: Line 44:
 </code> </code>
  
-Resize /dev/disk/by-id/FIRST-part3 to smaller but equal to SECOND-part3 size.+Sometimes ZFS refuse to remove device with 'out of space' error (but second device is capable to handle all data). To solve it, add more temporary devices to ''rpool'' 
 +<code bash> 
 +zfs create -V 64gb nvmpool/t1 
 +zfs create -V 64gb nvmpool/t2 
 +zpool add rpool /dev/zvol/nvmpool/t1 
 +zpool add rpool /dev/zvol/nvmpool/t2 
 +</code> 
 + 
 +Resize ''/dev/disk/by-id/FIRST-part3'' to smaller but equal to SECOND-part3 size.
  
 <code bash> <code bash>