ZFS Send Volume Receive to File

I wanted to take and send a snapshot of a ZFS volume which contains a user home dir to a freshly installed laptop.

mr@server:~$ zfs snap tank/myvol@wednsday

mr@server:~$ zfs list -t snapshot 
NAME			USED  AVAIL	REFER	MOUNTPOINT
tank/myvol@wednsday	22.6M	-	61.0G	-

Ok we know its 61G, I’m going to make an empty file a little bigger just in case. Then make a zfs pool out of it:

root@laptop# dd if=/dev/zero of=/zfsfile bs=1G count=80 
root@laptop# zpool create zfspool /zfsfile 

Now to send it:

root@server:~# zfs send tank/myvol@wednsday | ssh 172.16.0.236 zfs recv zfspool/myvol

RushWorx 2010

I noticed the archive now lists ten years

screenshot of rushworx.net archives going from august 2024 back to may 2014

But actually if you look on the wayback machine, this site has existed since 2010

old screenshot of rushworx.net from 2010 showing articles about running Debian on a Zipit, contemplating hosting X11 on windows server, virtualbox vm physical disk access, booting usb media without bios support, dashboard flocking, fujitsu lifebook E8110 bluetooth.

I should go scrape the old articles and re-add them, not like it would be hard. Why? For street cred and getting to claim this blog is 14 years old instead of 10!

[Top]

Terminator Workspace-in-a-box

This is related to Tmux workspace-in-a-box in my general effort to be productive with a bunch of linux terminals open at once

Preamble bitching nonsense

When things are all the same color, I work slower, if I get any work done at all. I noticed this in college taking a course in structural design. It was the kind of class that took up a three ring binder. Of course it wasn’t all notes, it had at least a hundred pages of the American Institute of Steel Construction. In that monster of a notebook I could not find a goddamn thing! That is, until I got a bunch of different colored pens, highlighters, flags, etc.


Same thing with computers, I stare at a bunch of black terminals and its just all runs together I can’t do shit. In fact, it even seems like every game now has the same stupid fucking flat black and white menus. Certainly true for Halo Infinite, MechWarrior 5, and HBS Battletech.

replace this with a new one
screenshot of halo settings menu
replace this with a new one
screenshot of mechwarrior 5 settings menu
replace this with a new one
screen shot of battletech settings menu

Identify which is which, I dare you.

Terminator

No, not ahhhhnold. Not even grizled, gray haired ahhhhnold. I can’t say terminator is the best gui terminal emulator, but I use it because I can easily make it different colors. It also has a nice human readable config file, as god intended. You don’t have to edit it by hand, but for some reason the gui is slow when I edit the colors and I don’t care to find out why.

screenshot of basic black terminator window showing profile selection and my custom profiles

I try to use the same color terminal for the same remote host when I am working on a bunch of them at the same time. Here are some examples:

WWW

There is not much for the blue - www profile the config file ~/.config/terminator/config really just the background color.

[profiles]
  [[blue - www]]
    background_color = "#001654"
    background_darkness = 0.8
    cursor_color = "#ffffff"
    font = Monospace 10
    foreground_color = "#ffffff"
    show_titlebar = False
    scrollbar_position = hidden
    use_system_font = False
screenshot of terminator, dark blue for www

Nextcloud

Despite my proclivities for dark computer screens, I need more color choices so here is a light blue one. I had to change the color palette since the color schemes that come with terminator don’t work on light backgrounds. It is by no means complete, maybe I will actually come back and update this later accordingly.

[[lt blue - sky]]
background_color = "#62a0ea"
cursor_color = "#aaaaaa"
font = Monospace 10
foreground_color = "#000000"
show_titlebar = False
scrollbar_position = hidden
palette = "#000000:#aa0000:#00aa00:#aa5500:#0000aa:#aa00aa:#005b5b:#aaaaaa:#555555:#ff5555:#55ff55:#ffff55:#5555ff:#ff55ff:#55ffff:#ffffff"
use_system_font = False
screenshot of terminator, light blue for nextcloud
[Top]

Tmux Workspace-in-a-Box

The idea here is when I work on a system, I want to open tmux and have it automatically open all the windows I always open. This will save me manually doing all that, and give me consistency of what window is where so I can build muscle memory and quit flapping around looking for the right window.

For reasons beyond my comprehension, instead of just issuing the usual tmux, you actually need to tmux attach. I guess that is a good thing regardless, as if the main tmux session is already open I would just want to reconnect.

Anyway, here are some tmux.conf examples:

WWW

Here is an apache web server, called www.

mr@www:~$ cat .tmux.conf 
new -s www -c	/etc/apache2		#create new session for www
rename-window	/etc/apache2/		#rename first window
new-window -c	/var/log/apache2/	#make a second window
rename-window	/var/log/apache2/	#rename second window
new-window -c	/var/www/rushworx.net/	
rename-window	rushworx.net

mr@www:~$ tmux attach

screenshot of dark blue terminator terminal for www

shows tmux with three windows /etc/apache2/, /var/log/apache2/, and /var/www/rushworx.net/

Nextcloud

A nextcloud server

mr@nextcloud:~$ cat .tmux.conf 
new -s nextcloud -c /home/nextcloud_data #create new session for nextcloud
rename-window   /home/nextcloud_data/   #rename first window
new-window -c   /var/log/               #make a second window
rename-window   /var/log/               #rename second window
new-window -c   /home/mr/
rename-window   /home/mr/
  
screenshot of light blue terminator window for nextcloud

shows tmux with three windows for /home/nextcloud_data/, /var/log, and /home/mr

Sources

This github gist helped me figure out some of the odd tmux config usage
https://gist.github.com/Muzietto/325344c2b1b3b723985a85800cafef4f

, , ,
[Top]

Move, move!

Move, move, he said. And I did. I moved exactly onto into the plasma grenades he was warning me about. And this fucking guy managed to boost his ass off the sinking ship even!

[Top]

PHP file upload limit

the venerable php hammer. 

a hammer with two claws
the php hammer

For some reason the defaults in php will remain tiny forever and ever, amen. So you always gotta do this if you want to upload a pic or clip larger than the default upload_max_filesize of 2MB:

root@www:~# cat /etc/php/8.2/fpm/php.ini  |egrep "upload_max|post_max"
post_max_size = 400M
upload_max_filesize = 200M
root@www:~# systemctl restart php8.2-fpm.service

, ,
[Top]

Mitigate Denial of Service on Apache with mod_evasive

The original Apache logo
The original Apache logo

Mitigating attacks within the web server itself appears tidy and convenient but there are limits to what can be accomplished without incurring excessive load in the process. Let’s set up mod_evasive for that purpose however it can also be integrated with firewalls and routers.

apt-get install apache2-utils
apt-get install libapache2-mod-evasive

Check that the module is loaded:

root@www:~# apache2ctl -M |grep evasive
 evasive20_module (shared)

And the config file:


nano /etc/apache2/mods-enabled/evasive.conf

GNU nano 7.2                             /etc/apache2/mods-enabled/evasive.conf                                      <IfModule mod_evasive20.c>
    DOSHashTableSize    3097
    DOSPageCount        2
    DOSSiteCount        50
    DOSPageInterval     1
    DOSSiteInterval     1
    DOSBlockingPeriod   10

    #DOSEmailNotify      [email protected]
    #DOSSystemCommand    "su - someuser -c '/sbin/... %s ...'"
    DOSLogDir           "/var/log/apache2/mod_evasive"
</IfModule>

This is the default config per the github but I think it might be older than dirt so expect to change it! Also I am definitely not sending email. DOSSystemCommand is how you are going to integrate with external edge devices to block there rather than on the web server itself. I am putting my log in the debian apache dir. You could use that to hit an API at your web host to add IPs to their anti DDoS system. Or, probably could use it to hit CloudFlare’s API or similar external service.

, ,
[Top]

Quickly change sound device in Windows with SoundSwitch

I should have done this a long time ago. Swapping between speakers and headset in windows sucks ass. Somebody solved that problem with a thing called SoundSwitch that lives in your system tray and lets you do it with a press of a button or even a goddamn hot key. Sick.

https://soundswitch.aaflalo.me

screen shot of soundswitch system tray app
screen shot of soundswitch system tray app
soundswitch settings
[Top]

WordPress Caching with W3 Total Cache and memcached

There is much on this topic, this is just one solution.

W3 Total Cache is a well known performance plugin for WordPress, and it can use memcached.

memcached should already be listening on loopback, not on a public ip!, on a tcp socket:

root@www:~# netstat -lnp --tcp |head -3
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN      681/memcached

Going to need the php extension to connect to the memcached server:

apt install php8.2-memcached

After which, the main things in W3TC we are looking for are object cache (php), page cache, and database cache and all three are working so we are all set.

[Top]

Apache MPM Event with PHP-FPM on Debian 12

Apache by default comes with an old crusty style of doing things which includes MPM prefork and mod_php. I am going to instead use the threaded event multi-processing module.


apachectl -M | grep 'mpm'

root@www:~#  apachectl -M | grep 'mpm'
mpm_prefork_module (shared)


root@www:~# a2query -m |grep php
php8.2 (enabled by maintainer script)

a2dismod php8.2
a2dismod mpm_prefork
a2enmod mpm_event

apt install php-fpm

Creating config file /etc/php/8.2/fpm/php.ini with new version
NOTICE: Not enabling PHP 8.2 FPM by default.
NOTICE: To enable PHP 8.2 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php8.2-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Created symlink /etc/systemd/system/multi-user.target.wants/php8.2-fpm.service → /lib/systemd/system/php8.2-fpm.service.
Setting up php-fpm (2:8.2+93) ...
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for php8.2-fpm (8.2.20-1~deb12u1) ...
NOTICE: Not enabling PHP 8.2 FPM by default.
NOTICE: To enable PHP 8.2 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php8.2-fpm
NOTICE: You are seeing this message because you have apache2 package installed.


apt install libapache2-mod-fcgid
Uses unix socket.
		
a2enconf php8.2-fpm		
a2enmod proxy
a2enmod proxy_fcgi

apachectl configtest
Syntax OK

systemctl restart apache2

apachectl -M | grep 'mpm'
mpm_event_module (shared)
 
[Top]