Skip to content

tool - zfs and zpool - command overview

Just a quick overview about some zfs and zpool commands. $tank is used as zpool name.

  • zpool create $tank mirror c6t0d0p0 c8t0d0p0 | creates zpool in mirror by using two devices. Use -m to add a mountpoint.
  • zpool create $tank/dataset1 | creates a dataset in zpool $tank
  • zpool add $tank c11t0d0p0 | adds device to $tank (storageplace increased)
  • zpool destroy $tank | destroy a zpool
  • zpool destry $tank/dataset1 | destroy dataset1 in zpool $tank
  • zpool rename $tank/foo $tank/bar | renames dataset foo to bar
  • zpool replace $tank c8t0d0p0 c11t0d0p0 | replaces device c8t0d0p0 with c11t0d0p0
  • zpool offline $tank c8t0d0p0 | take device c8t0d0p0 offline
  • zpool detach $tank c8t0d0p0 | detach device c8t0d0p0 from zpool
  • zpool attach $tank c11t0d0p0 | attach device c11t0d0p0 from zpool
  • zpool history -i $tank | shows history of $tank
  • zpool get all $tank | returns all properties from $tank
  • zpool get option $tank | get option from $tank
  • zpool set option=value $tank | set option with value to $tank
  • zpool iostat [$pool $intervallInSeconds] | i/o performance monitor
  • zpool import $tank | imports $tank into system. Use -a to import all available zpools
  • zpool status [$tank] | status monitor
  • zpool export $tank | export $tank from system (importent if you want to use this tank in an other environment)
  • zpool scrub $tank | verify integrity of every blog of a data in $tank. Use -s to stop scrubbing.
  • zfs list [-t (type), -r (recursive)] | list available (imported) zpools
  • zfs snapshot $tank@backup | creates snaphot "backup" from $tank
  • zfs rollback $tank@backup | return $tank to dataset $backup
  • zfs destroy $tank@backup | destroy snapshot "backup"
  • zfs send -R $tank@backup | zfs receive -d $backuptank | creates backup zpool

callbacks, anonymous or lambda functions - the differences

It just took me a while to really understand the differences between this three. But hopefully (never say never ;-), now i got it. A callback simple describes, that a function awaits another function as parameter. This functions can be an existing one or a "on the fly created on" with the power of create_function.

A lambda function is a function without a function name. The reference is stored in a variable. You can use this variable to handle it over to methods like usort. As everybody i will use a sorting lambda function for showing what i mean.

$lengthOfStringTwo) { $sorter = 1; } elseif ($lengthOfStringOne < $lengthOfStringTwo) { $sorter = -1; } return $sorter; }; $names = array( 'Brian W. Kernighan', 'Dennis Ritchie' ); usort($names, $mySorter); echo xdebug_var_dump($names); ?>
It is also possible to define the $mySorter directly in unsort as second parameter like
usort($names, function($stringOne, $stringTwo { ... });
if you like that.

A closure is a function that surrounds (i do not want to use the word enclose ;-)) the lambda function. That has the sideeffect that the closure itself conserves their own context. An easy example is a simple logger.

setMessage($message); $myDatabaseInfoLogTable->setTimestamp(mktime()); $status = $myDatabaseInfoLogTable->save(); break; case 'error': $myFileErrorLog = new ErrorLog(); $myFileErrorLog->addMessage(mktime() . "\t" . $message); $status = $myFileErrorLog->save(); break; } return $status; }; } $infoLogger = myClosureLogger('info'); $errorLogger = myClosureLogger('error'); $infoLogger('This is a info log'); $errorLogger('This is an error log'); ?>
The positiv thing about closures is, that the code footprint can be reduced (you even can use closures inside objects - even as static if you do not need to access on the object itself with $this). The negativ thing is, that you can not use interfaces which implies a lose of security.