Establish ZFS highly reliable file storage system in sinox2014
Hanao sinox2014 can be installed with a relatively small solid state drive, and the file system can be stored in ZFS.
Prepare some hard disks, such as three SCSI hard disks: da0, da1, and da2.
Start now
Add the following line to your/etc/rc. conf file.
# Echo 'zfs _ enable = "yes" '>/etc/rc. conf
Use raidz1 to create a zpool named Tank
# Zpool create tank raidz da0 da1 da2
At this time, the zpool will be automatically mounted to/tank, and we can access it.
Set Disk Quota
Create a directory/tank/home and set its limit to 10 GB
# ZFS create tank/home
# ZFS set quota = 10G tank/home
# ZFS get quota tank/home
Name property value source
Tank/home quota 10g local
Set reserved space
Create a directory/tank/home/reserva and set 5g to reserved space under/tank/home
# ZFS create tank/home/reserva
# ZFS set reservation = 5G tank/home/reserva
# ZFS get reservation tank/home/reserva
Name property value source
Tank/home/reserva reservation 5g local
SET COMPRESSION
Set a directory to use compression. You can simply enable compression or specify the compression method. The optional methods include gzip, lzjb, and gzip-[1-9].
# Zfs set compression = on tank/home
# Zfs set compression = off tank/home/reserva
# ZFS get-r compression tank/home
Name property value source
Tank/home compression on local
Tank/home/reserva compression off local
Snapshot, rollback, and clone
Zfs provides the snapshot function. Theoretically, you can create a snapshot of 2 ^ 64 to the power of your file system and restore the file system through these snapshots.
Here we create some test files, create snapshots, delete them, and then restore these files.
# Mkdir/tank/home/reserva/test/tank/home/reserva/TT
# Dd If =/dev/Zero of =/tank/home/reserva/aaaa bs = 1024 COUNT = 100000
# ZFS snapshot tank/home/[email protected]
# ZFS list-T Snapshot
Name used avail refer mountpoint
Tank/home/[email protected] 0-97.7 m-
# Rm-fr/tank/home/reserva /*
# ZFS rollback tank/home/[email protected]
Clone one copy from the created snapshot.
# ZFS Clone tank/home/[email protected] tank/clone
# ZFS list
Name used avail refer mountpoint
Tank 5.00g 129G 30.6 K/Tank
Tank/clone 0 129G 97.7 M/tank/clone
Tank/home 5.00g 5.00g 28.0 K/tank/home
Tank/home/reserva 97.7 M 9.90g 97.7 M/tank/home/reserva
Tank/home/[email protected] 0-97.7 m-
Zfs snapshots make data recovery very easy.
Now, you can allocate directory links such as/usr/,/var, And/tmp to ZFS files as needed.