📜 ⬆️ ⬇️

ZFS and KVM. @home


This symbolism is already well known, so it makes no sense to explain in detail what kind of animal it is .


There will be no comparison with LVM , for it is possible, but meaningless, to compare a muscle-car with a jet-truck.
Graphics and comics are also not delivered.
It is, let's say, an unfinished success story, because the upgrade by which it was caused can only be stopped, but not completed.


Prerequisites


Practically in every IT family there are several PCs and / or laptops, for sure there is an HTPC or even a NAS. So we had two PCs, then a large wall monitor was added, and in this situation the birth of the HTPC is a matter of time. When he was born, he was immediately named a proud name - Server. Later it turned out that some of the favorite games can do in Linux - and the Server immediately got a Steam account.

So a few years passed, during which the Server received 16GB of memory, virtuals with gitlab and projects appeared on it ...


And then the understanding came that an upgrade is brewing, and upgrading 3 PCs at once is too expensive; At the same time, there was already a successful experience with PCIE-passthrough and a virtual virtual machine.


A suitable solution was the gradual migration of gaming machines to virtuals. While only one is emigrated, in the future, under the guest, I will mean it.
Of the three processors (i3-3220, i5-3470, i5- 3470K), VT-d supported only the second, and it went to the Server instead of i3. A low-profile 1050Ti was bought to replace the 7970, and the old iron was sold in parts.


The server received the latest UEFI-firmware, Ubuntu 16.04 and the largest SSD available - Crucial M4, 256 GB, under the root pool. The installation was carried out according to this manual , from which the installation script was accumulated in the live system. Then, after a successful download, virt-manager , libvirt-bin , ovmf and xubuntu-desktop were installed. Of course, VT-x and VT-d were included.

By the way, the separation of the binary part of the system from logs, caches and other hamsters more than once helped in the process of vivisection of the system of experiments, allowing you to return the working state to a simple zfs rollback , accessible even from initrd (but there is a feature: if you use a separate datasset for /root , use the parameter kernel init=/bin/sh for emergency boot; sh, unlike bash, will not create garbage at the /root mount point).
To avoid guessing what happened, in /etc/default/grub comment out everything related to HIDDEN_TIMEOUT , obviously set a timeout other than 0 (I have 10), uncomment / add GRUB_TERMINAL=console and be sure to remove quiet splash from GRUB_CMDLINE .


Error-43 and all-all



Using ZFS



We return to the installation wizard, update the disk configuration, select the largest partition created (with which the magic was done) and continue the installation as usual.


What was it?
  ,       64,  Windows ,       ,        -  .  ?  ,       Windows-:    ,  ,   ,   . 

Deduplicate Steam, or where it all began


The easiest way was to get smb or nfs balls and create Steam libraries on them. Regular files are easily and naturally deduplicated, including both exported libraries and the Linux client library, without unnecessary gestures. As always, the most obvious solution turned out to be in principle working, but wrong. SMB in this mode moves with the speed of a notebook hard disk, despite the fact that the files are on the SSD. NFS (and Windows 8.1 supports NFS v3, not 4) moved a little faster, it felt like some kind of "green" desktop drive, but it was still too little for a comfortable game. In addition, all the operating systems from M $ love to lose network drives that are automatically connected when logon, and each time pointing Steam to the location of the library quickly get bored.

ISCSI is the solution. The targetcli was installed on the targetcli , configured by this manual , adjusted for blockio usage and by the form /dev/zvols/<zfs path> . For unmap to work properly, you need to use Windows 8+ (starting with 8, unmap support for the iSCSI initiator is implemented), and set attributes emulate_3pc=1,emulate_tpu=1,emulate_caw=1,emulate_tpws=1,emulate_tas=1 for each block device. If done correctly, then deleting files and formatting should free up space and reduce the size of the zvol.

Now identical files in volumes exported for libraries take up space only once, but the Steam library for Linux still occupies a separate place. Let's create a separate dataset for this library with options -o dedup=on -o recordsize=64K . If the sections in zvol are aligned on the 1MB border, and the cluster size is set to 64KB, then it is logical that you need to share files on the host with the same granularity so that deduplication can find the same blocks.


Effects



Instead of conclusion


Well, my little experiment ended with undeniable success, although difficulties arose on the way. Further, I would like to upgrade to Zen2, 32-64GB of memory, NVME SSD, transfer a second PC to the Server ... but this will be a completely different witch.

Source: https://habr.com/ru/post/339456/


All Articles