简体   繁体   中英

ZFS how to make 'receive' create the filesystems?

I'm running a ZFS NAS on OmniOS in conjunction with NappIt UI. In order to upgrade the capacity I was planning to exchange the disks one by on. But that was impossible since the new disks have 4096 bytes blocksize, but the pool has ashift=9

So I went to sending the content (zfs send), destroy the old pool, create a new one and restore the data (zfs receive).

I set up a virtual machine to test the process. Made a snapshot of the pool using

zfs snapshot -r zpool@backup

Then exported the snapshot using

zfs send -Rv zpool@backup > my_backup-file

Destroyed the pool and created a new one and received the content via

zfs receive -F -d zpool < my_backup_file

That went pretty fine. Except no filesystems of the old content have been created. The data however is there. When I list the directoy /zpool all the folders that represented the filesystems are present and contain all the data. Just like in the original state. But listing the filesystems withe 'zfs list' does not show any of the original filesystems. It just shows the pool.

Of course due to lack of the filesystems all of their attributes are missing (NFS shares, ACLs,...)

In a second attempt I first created the filesystems before receive and everything was fine. But I had to set all the attributes by hand of course.

Is there a way to send/receive an entire ZFS and make it restore the filesystems and attributes as well?

Thank you!

Lothar

Short summary: I tried to snapshot the ZFS pool, send and receive it as shown in the description above.

Expected: A full copy of the original pool and all contained filesystems including their attributes.

It's essential to make snapshots of the pool itself and every single filesystem before zfs send -R of the pool. Assuming the pool is named zpool and contains the filesystems data and media , the process is the following:

zfs create zpool@now
zfs create zpool/data@now
zfs create zpool/media@now
zfs send -R zpool@now > <my_data_file>

Then on the new, empty pool a

zfs receive -F -d zpool < <my_data_file> 

restores the entire data and also the filesystems.

Keep in mind: If some of your filesystems are compressed, the datafile may be much bigger than the sum filesystem sizes shown in zfs list , because the data is uncompressed before sending. To take care of that the -c option of the zfs send command can be used.

zfs send -R -c zpool@now > <my_data_file>

That will generate a compressed data file. It can be received the same way as an uncompressed data file. No special options needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM