ZFS: Unterschied zwischen den Versionen

Aus Info-Theke
Zur Navigation springen Zur Suche springen
Zeile 26: Zeile 26:
# Quota:
# Quota:
zfs set quota=10G meinPool/FS1
zfs set quota=10G meinPool/FS1
zfs get atime
# readonly: available compressratio creation guid mounted snapshot_count type used written
zfs set compression=zlib-3
# rw: atime checksum compression dedup mountpoint quota readonly relatime utf8only
</pre>
</pre>



Version vom 15. Januar 2022, 10:21 Uhr

Links

Kommandos

# RAM-Belegung von ZFS Anzeigen:
echo $(( `cat /proc/spl/kmem/slab | tail -n +3 | awk '{ print $3 }' | tr "\n" "+" | sed "s/$/0/"` ))
# RAID1 einrichten:
zpool create my-samsung-mirror1 mirror /dev/sda1 /dev/db1
# RAID10 einrichten:
zpool create my-samsung-mirror2 mirror /dev/DISK1 /dev/disk/DISK2 mirror /dev/DISK3 /dev/DISK4
# RAID5 einrichten:
zpool create meinRAIDZ raidz /dev/disk/by-id/DISK1 /dev/disk/by-id/DISK2 /dev/disk/by-id/DISK3

zpool list
zpool status
# Pool testen:
zpool scrub

# ZFS-Dateisystem einrichten:
mkdir -p /media/db/mysql /media/db/pg
zfs create -o acltype=posixacl -o compression=zstd-3 -o dnodesize=auto -o normalization=formD -o relatime=on -o mountpoint=/media/db/mysql db/mysql
zfs create -o acltype=posixacl -o compression=zstd-3 -o dnodesize=auto -o normalization=formD -o relatime=on -o mountpoint=/media/db/pg db/pg
zfs list

# Quota:
zfs set quota=10G meinPool/FS1

zfs get atime
# readonly: available compressratio creation guid mounted snapshot_count type used written
zfs set compression=zlib-3
# rw: atime checksum compression dedup mountpoint quota readonly relatime utf8only 

Mounten

zfs get mountpoint meinPool/FS1
zfs set mountpoint=/media/meinPool_FS1 meinPool/FS1
# Wenn man mount/umount verwenden will:  Legacy-Einhängepunkte
zfs set mountpoint=legacy meinPool/FS1
  • ZFS-Dateisysteme können nur mit Legacy-Dienstprogrammen verwaltet werden (indem Sie die Eigenschaft „mountpoint“ auf „legacy“ setzen)
  • Dann sind die Befehle mount und umount sowie die Datei /etc/vfstab relevant.
  • ZFS hängt Legacy-Dateisysteme beim Systemstart nicht automatisch ein, die ZFS-Befehle zfs mount und zfs umount funktionieren nicht!

Snapshots

zfs list -t snapshot
# Sortiert nach Name, Erzeugung
zfs list -t snapshot -o name,creation -s creation
# Erzeugen:
zfs snapshot -r meinPool/FS1@snapshot1
zfs rollback -r meinPool/FS1@snapshot1
zfs destroy meinPool/FS1@snapshot1
zfs diff meinPool/FS1@snapshot1 meinPool/FS1@snapshot2
  • im normalen Mountverzeichnis gibt es den unsichtbaren Ordner .zfs. Auch wenn dieser Ordner auch mit ls -la nicht sichtbar ist, so kann dennoch hinein gewechselt werden. Dieses Verhalten ist praktisch damit tools wie rsync nicht versehentlich snapshots mitkopieren.

Snapshots übertragen

# Initial:
zfs send meinPool/FS1@snap1 | ssh root@$Zielhost zfs recv meinBACKUPPool/FS1
# Ändern:
dd if=/dev/zero bs=1024000 count=1024 >> /meinPool/FS1/test2
# Snapshot anlegen:
zfs snapshot -r meinPool/FS1@snap2
# Snapshot inkrementell senden (lt. ifconfig werden 1G übertragen):
zfs send -i meinPool/FS1@snap1 meinPool/FS1@snap2 | ssh root$Zielhost zfs recv meinBACKUPPool/FS1

ZFS Clones

Ein ZFS clone ist eine schreibbare Kopie eines Snapshots. Der Snapshot kann so lange nicht gelöscht werden wie der Clone besteht.

zfs snapshot -r meinPool/FS1@snapshot1
zfs clone meinPool/FS1@snapshot1 meinPool/FS2

ZFS Volumes

Statt Dateisystemen kann ZFS auch volumes anlegen, das sind Blockgeräte die z.B. in virtualisierten Gästen verwendet werden können.

Aufruf ist wie beim Dateisystem anlegen, nur zusätzlich mit dem Parameter „-V $Größe“:

zfs create -V 2G tank/volumes/v2

Das Volume steht dann unter /dev/tank/volumes/v2 zur Verfügung und kann normal wie blockdevice verwendet werden.

Konfiguration

  • /etc/modprobe.d/zfs.conf
# RAM auf 8 G beschränken:
options zfs zfs_arc_max=8589934592

Fehlerfall

zpool detach mypool /dev/BADDISK
zpool attach mypool /dev/GOODDISK /dev/BADDISK  -f