safe and clean shutdown with zfs

Hello,

I have a zfs-pool with a few filesystems on top of four HDDs with a geli layer. What is the "correct" way to shutdown the server to prevent data loss?
Do I have to perform zpool detach and / or zfs export commands manually before system shutdown or is that not necessary?

I would perform a clean shutdown like that. Is that correct?

Code:
# zfs unmount -a
# zpool export       <--// necessary? -->
# geli detach /dev...
# poweroff

Of course I read the man page zpool(8) but I am a little bit confused. What is the difference between

# zpool export
# zpool detach
# zpool replace
# zpool remove
# zpool offline


Can somebody give a few examples in what situation I have to perform those command?

thanks and greets
yyag
 
Using a normal shutdown, none of these are needed.
On shutdown the system will flush buffers and unmount the ZFS filesystems automatically.
All the 'zfs' commands you mention are used for replacing failing drives, moving the zfs pool to a different server etc.
 
Just do a shutdown -p now.

I'm pretty sure the ZFS man pages give good information on what all the commands do, but here's the quick version

Code:
zpool export
Removes the pool from the system (but the pool is still intact). You will usually only do this when you want to move the pool to another system. Do not do this just to reboot the computer.

Code:
zpool attach/detach
These commands allow to to attach or detach devices from a ZFS mirror. If you build a ZFS pool with a single disk, you can attach a second disk to make it a mirror. You can then attach a third to make a 3-way mirror if you want. detach does the opposite and lets you remove disks from a mirror. A mirror is the only type of vdev that allows this. You *cannot* attach or detach disks from RAID-Z.

Code:
zpool replace
Fairly obvious. Used to replace a disk in the pool with a new one.

Code:
zpool remove
Removes a disk from the pool. As mentioned you cannot remove disks from RAID-Z, you can only remove disks from a mirror, and you use detach to do that. This command is only used to remove cache or log devices.

Code:
zpool offline
Takes a disk offline, so it's still part of the pool but temporarily unused. Obviously you must have redundancy to do this and ZFS will use the redundancy to keep the pool running. Most people will only use this rarely. Sun/Oracle say the following:

ZFS allows individual devices to be taken offline or brought online. When hardware is unreliable or not functioning properly, ZFS continues to read data from or write data to the device, assuming the condition is only temporary. If the condition is not temporary, you can instruct ZFS to ignore the device by taking it offline. ZFS does not send any requests to an offline device.

Another use mentioned by Sun/Oracle is to allow you to move disks around in the server (or between disk shelves in a large system) without any downtime. For instance if you attached a new disk shelf to a system, you could offline the disks one-by-one, move them to the new shelf, then bring them online again.
 
Back
Top