ZFS cleanup of snapshots

Just a small note for this oneliner to cleanup snapshots

First list all snapshots with a given pattern.
(This eaxmple searches 12m)

zfs list -t snapshot | grep -F '12m' | cut -d " " -f 1 | xargs -L 1 echo zfs destroy

Remove the word echo to perform a cleanup

zfs list -t snapshot | grep -F '12m' | cut -d " " -f 1 | xargs -L 1 zfs destroy

Explanation:

zfs list -t snapshot
List all zfs snaphots

grep -F '12m'
Only match the lines containing the string 12m

cut -d " " -f 1
Only fetch the first column of the output. (This is the snapshot name)

xargs -L 1 zfs destroy
Execute the command ‘zfs destroy’ for the found lines
The option -L 1 means it calls ‘zfs destroy’ per item
without it, xargs wills supply multiple items to 1 call. (Which isn’t support by zfs destroy)

Share

Installing Freebsd 11 via USB error 19

Today I tried to install FreeBSD 11.0
FreeBSD booted from the USB stick. When mounting the install image I received error:

Mounting from ufs:/dev/ufs/FreeBSD_Install failed with error 19.

I couldn’t figure out why I constantly got this error.

After tweaking bios etc. Using an USB2 port I finally gave up an though my USB stick was broken..
But then creating the second stick I found the problem.

The first time I created my memory stick like this on Mac OS X

sudo dd if="FreeBSD-11.0-RELEASE-amd64-memstick.img" of="/dev/disk2s1" bs="10240"

Look at the wrong /dev/disk2s1 path.. (that’s wrong!! )

The second attempt I used the following command. (I needed tot unmount /dev/disk2s1 in DiskUtilty first
)

sudo dd if="FreeBSD-11.0-RELEASE-amd64-memstick.img" of=/dev/disk2 bs=1m conv=sync

Now it works :D

Share

Adding a raw mail-file to the postfixqueue

Today I had an issue that I needed to resend quarantined emails.
You can simply execute the following command to inject the mails to postfix


sendmail -t < name_of_the_raw_email_file

Source:
Thanks Wietse (Author of Postfix)
http://postfix.1071664.n5.nabble.com/best-way-to-send-quot-raw-quot-email-files-td45960.html

Share

Simple acces to your HTTP(s) services via SSH and a SOCKS Proxy

I didn’t know this trick:
https://www.gypthecat.com/using-ssh-as-a-socks-vpn-on-mac-os

This blog entry describes how to use your normal SSH connection as a SOCKS proxy for web requests.
Just connect to the SSH server with the -D option on port 8080

ssh -D 8080 -p [port number] [username]@[IP address or hostname]

On Mac OS X just enable the socks proxy in the Advanced tab of your network/wifi card:
And enter as SOCKS proxy server 127.0.0.1, on port 8080

Screen Shot 2016-07-04 at 08.15.04

But for a full vpn attempt over SSH, maybe I should look at this:

https://github.com/apenwarr/sshuttle/

Share