ZFS: auto-snapshots and Windows shadow copies with Samba

ZFS: auto-snapshots and Windows shadow copies with Samba

With ZFS snapshots and Samba’s shadow_copy2 module, you can expose snapshots to Windows clients as shadow copies.

First, install zfs-auto-snapshot on Debian:

apt-get install zfs-auto-snapshot

Default configuration for zfs-auto-snapshot uses specific labels like daily, weekly etc. This is incompatible to samba’s expected snapshot format. As a good workaround, instead of using text labels, I’ve changed the labels to numbers:

31: for daily snapshots
05: for 5 minute interval snapshots
24: for hourly snapshots
12: for monthly snapshots
52: for weekly snapshots

read more

ZFS: txg_sync stuck at 100% while copy large dataset with rsync

ZFS: txg_sync stuck at 100% while copy large dataset with rsync

While transfering a large dataset (2TiB) via rsync from ext4 to zfs, rsync hangs at some time and txf_sync stuck at 100% cpu.

It was a fresh system and zfs was set up just a few minutes ago. After some research, I found out that this problem is related to ARC.

I’ve changed the zfs_arc_min parameter while trx_sync stuck and the system immediately responses.

echo 1073741824 » /sys/module/zfs/parameters/zfs_arc_min

This sets the minimum size (hard limit) for ARC to 1 GiB.

References

https://github.com/zfsonlinux/zfs/issues/3409#issuecomment-283551036

read more

ZFS: Create pool with missing devices

ZFS: Create pool with missing devices

ZFS on Linux has no support for creating pools with missing vdevs. Thats a benefit of mdadm which accepts a missing keyword in a list of devices.

But there is a workaround:

First, check the size of an existing device (all devices must have same size). In my case, each disk has 2000398934016 bytes. I’ve used fdisk to check the size but you can use whatever you want.

Now create parse file(s) with the given size.

read more

ZFS: Why is L2ARC hit ratio so low?

ZFS: Why is L2ARC hit ratio so low?

Using an additional SSD disk as a second level cache for ARC - called L2ARC - can speed up your ZFS pool. But if you analyze how often the cache is used you find a very low hit ratio. To understand why the hit ratio is low you should know how the L2ARC works.

ZFS uses a primary cache - the ARC - which takes some space of your available RAM. Until the ARC is really full, no noteworthy data is written to the L2ARC. Thus, until the ARC cache is warm, the L2ARC cache isn’t used. But even it is not used, a read request triggers a lookup in ARC and then in L2ARC. Because both caches are cold after a reboot, you can see a lot of cache misses.

read more

Samba: Enable SMB multi-channel

Samba: Enable SMB multi-channel

Starting wie Samba 4.4.0, it comes with multi-channel support as a new experimental feature. This is still marked as unstable in current 4.5.0 release, but if you’re crazy, you can enable it easily with a new smb.conf parameter.

Microsoft has introduced a new feature called SMB multi-channel into SMB 3.0 (available since Windows Server 2012). With multi-channel, you can share a SMB connection across multiple NICs to increase throughput and implementing fault-tolerant connections.

read more

Fan speed control on C2750D4I/C2550D4I Asrock boards

Fan speed control on C2750D4I/C2550D4I Asrock boards

The Asrock C2750D4I and C2550D4I boards provides multiple 4-pin PWM connectors. PWM configuration is available in the BIOS hardware monitoring section, but you can not change any parameters through the hwmon interface in /sys/class/hwmon. Asrock uses a Nuvoton chip (nct6776 compatible) for monitoring hardware sensors but the fans are not connected to this chip. Instead, they are handled by the onboard BMC.

You can get the current state of the sensors with impi-sensors:

read more

Fix badblocks on a hard drive

Fix badblocks on a hard drive

At first, we run a read-only badblocks scan on the device to find the corrupt blocks.

% badblocks /dev/sda
55575184
55575185
55575186
55575187
55575188
55575189
55575190
55575191
55575192
55575193
55575194
55575195
55575196
55575197
55575198
55575199

Now we know that block 55575184 - 55575199 are dead. If there are only a few blocks, it’s possible to replace these.

read more

Rename network interface

Rename network interface

Using udev

Change the interface name in /etc/udev/rules.d/75-persistent-net-generator.rules

Using ip utility

ip link set eth1 down
ip link set eth1 name wan0
ip link set wan0 up

read more

Rescan PCI for new virtio devices

Rescan PCI for new virtio devices

I want to extend a running KVM Linux guest system with a physical hard drive. I’ve connected the new disk via

virsh attach-disk my_vm /dev/sdf vdc

to connect sdf to vdc, but inside the guest, nothing happens.

The solution is simple: attaching a new disk requires a new virtio block controller which is a PCI device. The trick is to rescan the PCI bus system to detect the new controller:

echo 1 > /sys/bus/pci/rescan

Now lspci shows the new controller and dmesg shows the new vdc block device.

00:08.0 SCSI storage controller: Red Hat, Inc Virtio block device

Update:

Simply load the both modules

acpiphp pci_hotplug

then you don’t need to rescan the PCI bus.

read more