-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate ZFS data
mvgijssel edited this page Mar 7, 2020
·
1 revision
Install tools
apt-get install -y pv screen
Get disks for new pool
ls -la /dev/disk/by-id
lsblk
Create new pool
zpool create -o ashift=12 new_data disk1 disk2 disk3
Configure the new pool
zfs set compression=lz4 new_data
Start a screen to run the migration in the background
screen
Create a snapshot on the old pool
zfs snapshot -r tank0@migrate
Send the snapshot to the new poool
zfs send -vR tank0@migrate | pv | zfs receive -u new_data
Destroy the migrate snapshot of the migrate dataset
zfs destroy new_data@migrate
zfs unmount old pool
zfs unmount tank0
Update the old pool mountpoint
zfs set mountpoint=/old_data tank0
Update the new pool mountpoint
zfs set mountpoint=/data new_data
Mount the new filesystem
zfs mount new_data
Create a snapshot of the new pool
zfs snapshot -r new_data@initial
Create data sets for docs, media and downloads
mv -v /data/docs /data/docs2 # temporary rename
zfs create new_data/docs # create new dataset
screen # start a screen
rsync --info=progress2 -avz /data/docs2/ /data/docs
rm -rf /data/docs2
Enable NFS sharing on ZFS datasets
zfs set sharenfs=on new_data/docs
Remove drive from stripe
zpool remove new_data ata-TOSHIBA_HDWN180_89E3K14GFAVG
Add removed disk to existing disk
zpool attach new_data ata-TOSHIBA_HDWN180_89E5K11IFAVG ata-TOSHIBA_HDWN180_89E3K14GFAVG
After resilvering scrub the tank to check for errors
zpool scrub tank
Add mirror to existing mirror (Use -n to get dry run information)
zpool add -n new_data mirror ata-TOSHIBA_HDWN180_Y9PPK11BFAVG ata-TOSHIBA_HDWN180_Y9SAK1FCFAVG
zpool add new_data mirror ata-TOSHIBA_HDWN180_Y9PPK11BFAVG ata-TOSHIBA_HDWN180_Y9SAK1FCFAVG