I have a ZFS mirror with 2x4TB drives. Recently I bought a 3rd 6TB drive. I would like to upgrade to a RAIDz1 with 3x4TB and be able to use the 2TB from the 6TB drive. I found a few useful blog posts that helped me:

1: https://tentacles666.wordpress.com/2014/06/02/freenas-creating-zfs-zpools-using-partitions-on-mixed-sized-disks/comment-page-1/

2: https://web.archive.org/web/20151017154015/https://blogs.oracle.com/zhangfan/entry/how_to_turn_a_mirror

Partitioning

First create a 4TB partition on the new disk equal to the existing ones. Check the current partition size with fdisk /dev/sdx and press P to print the partition table.

root@proxnas:~# fdisk /dev/sda

Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/sda: 3.64 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model: WDC WD40EFRX-68W
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 32A72C39-8093-9B45-BB80-07DB920BA3BE

Device Start End Sectors Size Type
/dev/sda1 2048 7814019071 7814017024 3.6T Solaris /usr & Apple ZFS
/dev/sda9 7814019072 7814035455 16384 8M Solaris reserved 1

Note the sector size of /sda1: 7814017024.

Now we’re creating a new partition on the 6TB drive with fdisk /dev/sdd , make a new GPT scheme, and then add a new partition with N.

First sector 2048, last sector 7814019071. Add a 2nd partition if you like for the remaining free space and write changes to disk with W.

Create a sparse file

Multiply the sector size of your partition with the logical sector size of 512: 512*7814017024=4000776716288

dd if=/dev/zero of=sparsedisk.img bs=1 count=0 seek=4000776716288

Check the size of the sparse file with du -h --apparent-size sparsedisk.img
3.7T sparsedisk.img

Now mount the sparse disk by running

losetup -f --show sparsedisk.img

The output should give you the loop device, in my case /dev/loop0.

The ZFS part

First, detach a disk from the mirror pool.

zpool detach mypool ata-WDC_WD40EFRX-68WT0N0_WD-serial

Now create a RAIDz1 by typing:

zpool create rusty raidz /dev/disk/by-id/ata-WDC_WD40EFRX-68WT0N0_WD-xxxxx-part1 ata-WDC_WD60EFZX-68B3FN0_WD-xxxx-part1 /dev/loop0

Where rusty is the name of the pool, followed by 2 physical disks and finally the ‘fake’ disk.

Please do not write data to this pool as it will fill up the sparse file, that’s not what you want.

Bring the loop device offline: zpool offline rusty loop0

Now copy your data from the mirror to the new pool.

Categorieën: LinuxProxmoxTech