Here’s a very short post on the FreeBSD top command, mostly because I was using it the other day and it was um…, top of mind (sorry).
The table of processes or “top” command can be used to display information on your FreeBSD system’s CPU(s) and running processes. By default top lists the processes based on their CPU usage, and will update the list every second. Here are a few of the top options I find handy:
-h Summarizes the options available for top
-a Displays the command name and its full path, rather than just its executable name.
-H Display each thread for a multi-threaded process individually. By default a single summary line is displayed for each process.
-I Toggles the display of idle processes. By default, top displays both active and idle processes.
-m Display statistics based on either I/O or CPU usage. The default is CPU.
-S Display system processes. Normally, system processes such as pagedaemon and clock are not shown.
With the Corona-19 virus curbing my outdoor activities I decided to have another go at playing Fallout: New Vegas on PC. For this play through I bought the game anew from GOG.com. GOG has done an excellent job of fixing most of the bugs, crashes and other problems that continue to plague the version of the game available from Steam. One intermittent problem that remains, however, is an an infinite loading screen. When this happens the actual game will not launch and game play cannot continue. Very annoying.
A simple work-around for this problem is to start a new game. Note that you’ll want to retain any saves you may have to this point. You’ll wake up Doc Mitchell’s house where you’ll once again be guided though creating your character. It doesn’t matter whether you create the same character or not. When Doc Mitchell is done with you and you’ve regained control of your character create a hard save at this point. Now, next time you encounter a loading screen that goes on forever, restart the game and load that save. Once in the game you can simply reload one of your old saves.
Here’s a simple little Bourne shell-compatible script I wrote to create and delete rolling ZFS snapshots on a small home server running the FreeBSD operating system. Sure there’s ports/packages available in FreeBSD to accomplish this, but there’s something to be said for keeping it simple and having one less piece of software to update and maintain.
As currently configured, the script recursively creates a daily snapshot of /pool_0/dataset_0. The name of each snapshot consists of the word “snap,” followed by the date and time the snapshot was taken (e.g., snap-202002102300). Snapshots are retained in pool_0/dataset_0/.zfs/snapshots. The script will then destroy any snapshot older that 90 days and log what its done to the file cronlog located in my home directory. A typical ~/cronlog entry looks like the following:
To use the script, I save it as zfssnap.sh in ~/bin, where I keep most of my helper scripts, and make it executable:
1
chmod+x~/bin/zfssnap.sh
Then I delegate some ZFS permissions to user iceflatline so snapshots can be created and destroyed without becoming the root user. However, this command is issued as the user root:
Note that I’ve set permissions at the zpool level, which means that all datasets under pool_0 will inherit these settings. Alternatively I could have applied the permissions just to dataset_0.
Then I make the snapshots retained in pool_0/dataset_0/.zfs/snapshots. Here too, the command must be issued as the user root:
1
zfs set snapdir=visible pool_0
Here again, I’ve applied applied this setting at the zpool level so when additional datasets are created in pool_0 they will inherit this setting. And here too, I could have applied this setting just to dataset_0.
Finally I configure a cronjob in the crontab for user iceflatline so that the script runs daily at 23:00:
1
2
3
4
### DAILY
# Run backup scripts every day at 2300
023***/home/iceflatline/bin/zfssnap.sh
If you’d like to use the script as is then simply modify the variable src_0 to reflect the name of your zpool and dataset. Else, modify the script to suite your needs.
Prefer to run the script more frequently than daily? Modify your cronjob. Here are couple of examples for running the script more frequently:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
### HOURLY
# Run snapshot script every 15 minutes
#*/18 * * * * /home/iceflatine/bin/zfssnap.sh
# Run snapshot script every 30 minutes
#*/33 * * * * /home/iceflatine/bin/zfssnap.sh
# Run snapshot script at the top of every hour
#3 * * * * /home/iceflatine/bin/zfssnap.sh
# Run snapshot script every three hours at the top of each hour
#3 */3 * * * /home/iceflatine/bin/zfssnap.sh
# Run snapshot script every six hours at the top of each hour
#3 */6 * * * /home/iceflatine/bin/zfssnap.sh
Don’t like the snapshot naming convention. No problem, just modify the variable snap_prefix.
Prefer to have more or less than 90 snapshots? Modify the retention variable.
Want to add other zpools and/or datasets? Add them to another variable (e.g., src_1), then modify the remainder of the script to recognize and take action on them.
Prefer to have the script log its output to a different location? Modify the log variable.
You get the idea.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
### BEGIN INFO
# PROVIDE:
# REQUIRE:
# KEYWORD:
# Description:
# This script is used to create zfs snapshots and remove older snapshots.
# The number of snapshots to retain is defined in the variable retention.
# Author: iceflatline <iceflatline@gmail.com>
#
# OPTIONS:
# -v: Be verbose
### END INFO
### START OF SCRIPT
# These variables are named first because they are nested in other variables.
snap_prefix=snap
retention=90
# Full paths to these utilities are needed when running the script from cron.
UPDATE: Okay, I think I like this theme. It’s called Noto Simple and as you can see it has a bright, fresh look with only minimum stylings. Works well on mobile devices too. Quite a departure from the dark theme that anchored this site for many years. Let me know if you encounter any issue with it.
Bear with me as I experiment with a new theme or two for the site.
The MikroTik RouterBOARD 1100 AHx2 (RB1100AHx2) is 1U rackmount gigabit ethernet router with a dual core CPU. It can reach up to a million packets per second and supports hardware encryption. This post describes how to access the MikroTik 1100 AHx2 using FTP (File Transfer Protocol). FTP access is desirable in order to update the RouterOS software or perform other activities. The FTP client FileZilla will be used to describe the steps necessary, but you can use any FTP client.
The versions of software discussed in this post are as follows:
Windows 10 Pro
RouterOS 6.42.10 (long-term)
Filezilla client 3.39
Lets get started…
Start by downloading and installing the FileZilla client. Once installed open the Filezilla client and navigate to File -> Site Manager, select “New Site” and create a name for the entry (e.g., “MikroTik”). Set the Protocol to “SFTP – SSH File Transfer Protocol” and the Logon Type to “Normal”. Enter the user name and password. If you have not changed these on the MikroTik 1100 AHx2 then the user name will be admin and the password field should be left blank (See Figure 1).
Figure 1
Select “Connect” and you should be connected.
That’s it. A couple of minutes with the venerable FileZilla FTP client and you have FTP access to the MikroTik 1100 AHx2.