Some thoughts on Rust

Some backstory

I have needed a tool to manage my local Ubuntu and Debian mirrors. Aptly is probably the best tool available to do the job right now. However, none of the available tools are actually great. Most are in varying degrees of non-maintenance or throw out hordes of errors because they look for every file variation even though the Ubuntu and Debian mirror creation tools only release 1 or 2 variations.

Why the new tool?

Since I run several physical and virtual machines on my local network, I need a local software mirror. I am also packaging a few updated or tweaked Debian packages, so I need a storage location for those packages. As a result, I am mirroring the stable and testing versions of Debian, and all the versions of Ubuntu back to the current LTS, Focal Fossa. Add to those a few extra repositories I mirror, PPA’s basically, and my maintenance scripts are getting ridiculous. I am getting tired of directly modifying that massive pile of shell scripting every time a new distro release happens. To help with that, I have released a new tool that will create the non-PPA chunk of the shell scripts from scratch.

Why Rust?

After trying to build the same piece of software in Go, PHP, and actual proper shell, this time, I decided to try Rust. The result was pretty interesting. Importing dynamic data structures from any configuration file sucks. While I spent about 12 hours figuring out that the TOML would take longer than I originally wanted to implement. The hard-coded configuration took about 16 hours to build and test. You can get a copy from https://github.com/rrbrussell/aptly_manager.

I would describe using Rust so far as enjoyable frustration. I use a code, run, evaluate, repeat development cycle. While cargo build is not as fast as go build, it is quick enough that I can work at a fairly productive rate. When I understand the language in front of me. The completion of the first sub-command to the final v0.1.0 took about one, maybe two hours. I rapidly completed the last part compared to the fourteen or fifteen hours I spent bumbling around parsing command lines and figuring out Rust’s borrow checker.

Again Why Rust?

I am more familiar with Go, PHP, Java, and C# now than with Rust. However, even accounting for the learning curve, I prefer Rust. First off, it integrates better into Linux than C# or .NET. This would not be a big issue, except I like using one language for most tasks, and it appears to be easier to get Rust and GTK working on Windows than C# and GTK working on Linux. There are a couple of larger projects that I have on the back burner. My options for those projects boil down to three options

  • using PHP for the back end, with a .NET UI,
  • use .NET for both the front and back ends,
  • use Rust for both the front and back ends.

Go unfortunately does not work for any of the options because it does not support dynamically loaded plugins or have a useable GUI library available. Rust may not fully support dynamically loading plugins, but it is probably as safe and idiot-proof as Go and supports generics. Rust supports C’s foreign function interface natively, so the worst case is I may write the plugin management code in C and everything else in Rust.

Hawaii – Going To

I flew with family on Southwest. We took three flights. The first was from Tulsa International Airport in Tulsa, Oklahoma, to McCarran International Airport in Las Vegas, Nevada. The airport actually is in Paradise, Nevada. Flight SWA1746 was 2 hours and 40 minutes long. The second was from McCarran to Norman Y. Mineta San Jose International Airport in San Jose, California. Flight SWA974 was 1 hour and 15 minutes long. We picked up the last party member in San Jose. Then we flew from San Jose to Ellison Onizuka Kona International Airport at Keahole. Flight SWA768 was 5 hours and 43 minutes long.

The planes were a Boeing 737 Max 8, a Boeing 737-700, and a Boeing 737-800. Of the three planes, the 737-700 is too small. The 737-800 was too small for the five-hour flight to Hawaii. All of the flights were full or nearly full.

Photos will be in a separate post.

Lenovo Thinkpad X120e – Windows 10 Pro

First, a surprise. It actually works. I do not mean that it barely works. It runs reasonably well. As least as well as Xubuntu 21.04 did. It is still slow. The X120e has 4GB of DDR3 memory, and it has a dual-core 1.6GHz processor. It was never going to win any performance awards. Right now, my biggest complaint is the screen size and resolution. I want a 15.6-inch 1920×1080 display on it. The 11.6-inch 1366×768 display on here is way too small for doing a lot of work.

Update To Reasonable Options For Backing Up A NAS In 2021

As I mentioned in the previous post, the options boiled down to tape or an external hard drive. I chose to use an external hard drive. So far, that option is working okay if I ignore the fourteen to fifteen-hour-long initial syncs of the drives.

At a sustained write speed of one hundred and fifty-two megabytes per second, the entire NAS pool takes nearly fourteen hours to sink initially. I doubt I can get sustained write speeds much higher without spending several thousand dollars. I am not even sure if they make seven Tebibyte SSDs.

A Tebibyte is the base two version of a Terabyte. Excluding storage device sizes Tebibytes and Terabytes are identical. However, the difference is why a formatted storage device is always smaller than its listed capacity. The formated capacity is given in Tebibytes, but the listed capacity is in Terabytes.

That one hundred and fifty-two megabytes per second write speed translates to a wire speed of 1.275 Gigabits per second on the USB 3 bus, which is pretty reasonable for a mechanical hard drive using the full performance options available on USB 3.

Current thoughts on PHP 8.0 and WordPress.

Right now, I am testing this blog on PHP 8.0;

So far, migration hasn’t been that big of a problem. Well, save some issues with passwords. I am not sure if the PHP native hash plugin, PHP 8.0, or a combination of the two is the issue.

I have got it fixed, however. So far, I am enjoying using WebAuthn instead of the normal login procedure. But I will probably do a separate post over it.

New Phone

After four years of good service, the battery on my iPhone 8+ finally got to the point it needed replacing. After reviewing the options and expecting my new phone to survive for four more years. I decided to get the 256GB iPhone 12 Max.

The bigger screen is excellent. However, it is taking some adjusting to.

Reasonable Options for Backing Up A NAS in 2021

What are your reasonable options for backing up a 16TB NAS in 2021?

External Hard Drive?

Pros:

  • Interface Portability. You do not need any new software or hardware.
  • Ability to reuse older hardware: Assuming you have a used drive large enough to hold all your backups.

Cons:

  • Interface instability: USB3 drives especially are bad at this. The adapters are usually not designed to handle the multiple hours of uptime necessary to complete backing up multiple terabytes of data.
  • Transfer speeds: Most USB3 drives are not designed for performance. Even custom enclosures with reasonable drives in them usually struggle to keep a sustained write speed of 100MB/s.

Tape?

Pros:

  • Very reliable: Most tapes will probably outlast the drives that created them.

Cons:

  • Expensive: LTO-4 drives are several grand apiece, including used models. LTO-5 or LTO-6 is even more expensive, and LTO-5 or LTO-6 will be needed for most users with a NAS.

Matomo: Impressive and Useful

I discussed migrating from Google Analytics and Jetpack to Matomo in a previous post. However, I haven’t used it for a significant amount of time. I am finding it very useful.

There are two ways you can self-host Matomo. As a plugin for WordPress or as an independent web application. The WordPress plugin is the most accessible and most straightforward option for analytics on one WordPress installation. However, if you administer more than one website, the dedicated web application is a better option.

The only real difficulty I ran into was getting GeoIP working. That is due primarily to a lack of Debian packages for the correct PHP extension and no clear subheadings for system managed updates of the GeoIP databases.

#Assuming Matomo installed at /var/www/html/matomo
#Assuming geoipupdate places the databases in /usr/share/GeoIP/
cd /var/www/html/matomo/misc/
for DB in `ls /usr/share/GeoIP/*.mmdb`
do
ln -s /usr/share/GeoIP/$DB ./
done
#All .mmdb databases are now linked to the system databases updated by geoipupdate.

–Robert