# ZFS Replacing 512b drives by 4k drives?



## kisscool-fr (Feb 5, 2012)

Hi,

For the context, I have a home server running FreeBSD 8.2 AMD 64 on a Supermicro motherboard with integrated Atom D510 CPU and 4 GB of RAM. It serves essentially as as file server with some jails. The storage part is on a zfs raidz pool with 4 2,5" 320 Gb WD blue drives and the pool is practically full. I want to replace the 4 320 GB drives with 4 640 GB, 750 GB or 1 TB drives. 

The actual drives are normal drives (not advanced format) and there is a high probability that the new drives are 4k drives. 

The question is can I replace the drives and insert the new ones as advanced format drives (with gnop)? 

I remember someone already ask this but can't find the post. Also, I searched this forum and google but can't locate informations for my question. 

What is the right method to replace my drives by new drives? 

Thanks,


----------



## phoenix (Feb 6, 2012)

The *ashift* property determines the smallest allocation unit (sector) size of the vdev (and thus of the disks that make up the vdev), and it is set when the vdev is created.  It cannot be changed afterward.  The only way to change the *ashift* property of a vdev is to delete and recreate the vdev.  Since it's not possible to remove a vdev from a pool, the only way to change the *ashift* property of a vdev is to destroy and recreate the pool.

An *ashift* of 9 means 512 B sectors.  An *ashift* of 12 means 4096 B (4 KB) sectors.  You can check the value via `# zdb storage | grep ashift`

Thus, it's generally a good idea to create all new pools using gnop(8) to create vdevs with *ashift=12*.  You can use 512 B disks in an *ashift=12* pool without any issues. But using 4 KB disks in an *ashift=9* pool will cause lots of problems.

For your situation, if it's possible to add all the disks to the system at once, you can create a new pool using the new disks, then use "zfs send" to transfer the data from the old pool to the new pool.  Then remove the old disks and carry on using the new pool.

If you can't connect all the drives, then you'll need to backup, create new pool, restore.


----------



## kisscool-fr (Feb 9, 2012)

Thanks for the explanation. It confirmes what I was afraid of. I can't just replace the drives with new onces in advanced format without any issue. 

There isn't enought free ports to connect four new drives to the motherboard. I'll check if I can't find a sata card to plug in the pci-e slots. 

Just wonder, is it as simple as 

[CMD=""]zfs send storage | zfs recv storage2[/CMD]

to copy all the datas from storage pool to storage2 pool ? With all mount points ? Volumes ? 

And then, 
[CMD=""]zpool import storage2 storage[/CMD]
import storage2 pool with all mount points/volumes to restore it to the original place ?


----------



## phoenix (Feb 9, 2012)

Yes, it is as simple as send/recv, although you'll want to read the man page to see what all the options are for passing along all the filesystem properties, creating filesystems on the receiving end, etc.


----------

