Archive for January 2016

Mapping iSCSI disks in VirtualBox

To add iSCSI disk to already made VirtualBox machine do the following from a terminal/Command Prompt
VBoxManage storageattach MyVirtualMachineNameOrUUID --storagectl "SATA" --port 0 --device 0 --type hdd --medium iscsi --server --target "" --tport 3260

MyVirtualMachineNameOrUUID = The Name of your Virtual Machine. Use quotes if your VM name has spaces
–storagectl “SATA” = Name of the controller under the storage tab in VirtualBox
–port 0 = Port Number. If you already created a virtual disk connected to the SATA controller, probably want to select a different virtual sata port.
–server = ip address of the iSCSI server
–target “” = Full target name
–tport 3260 = iSCSI server port number.

Using nslookup to add allow entries for PeerGuardian Linux

I use PeerGuardian Linux to block IPs as extra layer of protection my servers. Because I block more than I need, I wanted a way to quickly add IPs to the allow.p2p file by their hostname. Below is the contents of my “Add_Allow_IPs” script.
nslookup $1 | sed -e '1,4 d' -e '$ d' -e 'N;s/\n/ /' -e 's/ Address: /:/g' -e 's/Name:\t//g' >> /etc/pgl/allow.p2p
sudo pglcmd reload
sudo pglcmd restart

So now if I run:
It will take out all the ipv4 addresses from nslookup output and make them line items in the allow.p2p file. It dose not work for IPV6 and CNAME results.

Windows previous versions for ZFS backed Samba shares

If you want ZFS’s snapshots to show up as previous versions in Windows File Shares you need to have ZFS backed, samba data set with 1 or more snapshots. My zfs data set is tank in my examples. A snapshot can be made manually or automatically. The easy way to manage automatic snapshots is to use ‘zfs-auto-snapshot’ that is bundled with zfsonlinux. Example for hourly snapshots of the tank.
zfs-auto-snapshot -l hourly tank
Or you can use cron to do hourly snapshots for you.
5 */1 * * * zfs snapshot tank@`date +%F-%H%M`
Also cron can clean up old snapshots. (Careful with this one. Verify zfs list -H -o name -t snapshot -r tank | head -n 24 output first)
30 0 * * * zfs list -H -o name -t snapshot -r tank | head -n 24 | xargs -n1 sudo zfs destroy

Lastly to have samba to use ZFS snapshots you’ll need shadow: format, vfs objects, shadow: sort, and shadow: snapdir added to your samba share. Here is example config with if using zfs-auto-snapshot hourly.

shadow: format = zfs-auto-snap_hourly-%F-%H%M
vfs objects = shadow_copy2
shadow: sort = desc
path = /tank
comment = ZFS dataset with Previous Versions enabled
writeable = yes
public = yes
shadow: snapdir = .zfs/snapshot