Technology

Linux Post Install Clean-Up

So, now that I’ve returned to Linux again, I’ve come across several sort of, clean-up tasks that needed to be completed to get things working fully.  A lot of my activities are, by design, machine agnostic.  That is to say, they run off “the cloud”, either through a service or something I am hosting.

One big one I use is One Drive.  I don’t NEED one drive running locally, but it’s convenient and nice to have.  Aside from just syncing and backing up all my writing through it, I also use it to do things like, sync blog graphics files and screen shots.  I’ve found this One Drive Linux Client, which seems promising, I’ve gotten it set up easily enough, but I have not quite worked out how to get it fully working with a selective sync.  I don’t need everything off my One Drive, and don’t have the drive space for that anyway.  So this one is pending a bit.

That hasn’t really slowed me down, I already also use GitHub for a lot of my writing as a secondary place with versioning, etc.  I made sure everything was up to date in Windows, then did a pull from the three remote repositories I care about, my Journal, my Digital Notes library, and my Web Clips library.  I made a few updates and made sure I had the workflow down for keeping things synced.  This also prompted the creation of a simple script to push everything at once.

#!/bin/bash  
git add -A  
git commit -m "Updated via Simple CLI Push"  
git push

I thought about adding the option to add a custom commit message, but these are all private repositories so I don’t really care about what the commit messages are. I also added this to the shell so I can just run it with “gitpush” from anywhere.

This also meant properly setting up SSH keys in Github, so I could actually pull the libraries. I also realized I would need to set up my SSH Keypairs for my web server space, which wasn’t hard but was mildly inconvenient because account based SSH is disabled. The simple solution was to reenable it using the Digital Ocean console, add the keys, then disable it again.

Probably the biggest hassle I had was getting the two NTFS partitions, one on the old primary Windows Drive, and a second on the same physical secondary drive as the system. I mostly use this drive for “working files”. Ebooks to read, monthly file dumps off my phone, programming projects, etc.

It’s just files.

I could manually mount both drives when I started, but any reboot would unmount them. I went out and looked up the fstab settings to use, and had no luck. In fact, I had the opposite of luck because at one point, I couldn’t mount the secondary storage drive at all in Linux. Only in Windows. I tried many options in both OSes, and finally just, backed everything up and wiped the partition in favor of a native ext4 format.

Since I had all this space now anyway, I remapped my /home/ folder to it, which is kind of good practice anyway, then copied everything from the old working files drive into a folder in my own home folder.

This ended up being a weird hassle too, because at one point I had “pre copied” the working files, before the migration, only to discover they had vanished when the /home/ folder was moved. I think what was happening, was they were not part of the encrypted blob, so the system simply, ignored them. So I had to unmount everything, reboot, which failed because now there are no user settings, drop to a recovery console, move the files OUT of the personal home folder, remount it all, then copy the files, again, from inside the OS, so they would receive the proper encryption and show up properly.

What a hassle, but it’s done.

The only real missing element here is that my copy of Affinity Photo is only licensed for Windows, so I’ll need to buy the Linux version. I don’t mind, I have been meaning to upgrade to version 2 anyway. I think Version 2 even has a new sytle liscence that is OS agnostic.

Another last one I’d like to do is automount the network shares from my NAS and file server on boot, if present. I don’t always use the laptop at home though, which means this could be weird when it can’t access them. But I also have an Open VPN tunnel to get to my home network, so there is probably a way to set it up in a way that connects through that always.

Linux, Again

So, I am back on Linux again. On my laptop at least. I never really STOPPED using Linux, I use it on Raspberry Pis and my Webserver and in the Windows Subsystem for Linux all the time.

Just for the record, I just went with boring Mint Linux.

But I have moved back to using it full time again on my laptop. I still have the Windows partition for now, but I seriously doubt I am ever going to go back to it again. And FWIW, I have previously used only Linux on laptops in the past. The concept is not at all alien to me.

I have wanted to make the switch back for a while but was a bit hobbled. I had been using an app to tether connectivity off my phone over USB. I could never get it to reliably work in Linux. I discovered recently that my cell plan now just includes regular WiFi based hotspotting, so I can just connect via WiFi when needed.

This was literally the only hurdle.

Another motivation though is the end of life for Windows 10 coming next year. I really feel like this is going to get pushed out because Windows 10 is really going strong still. But just in case, I need to get off of it.

Side note, Microsoft is really over estimating just how often people upgrade their PC hardware with their push of Windows 11 from 10. The blocking factors of the upgrade are extremely arbitrary and most of the PCs that can’t be updated to Windows 11, still function just fine for 90% of use cases for “regular people.”

Anyway, I plan to keep using my laptop for the foreseeable future. So moving to Linux is the best option.

I also want to use it as a bit of a test bed for migrating my project PC to Linux as well, mostly I have questions relating to Docker and the easiest solution will just be to test it.

Anyway, the migration itself was surprisingly smooth. Most of my workflow has been shifting to be very “floaty”. Almost all my writing for example, is Joplin and local files, which are in a private Github repository.

Joplin just worked, and then I set up Git and pulled the repository down. Visual Studio Code has a Linux option, I think it was even pre-installed I think. I already have been using it as a txt editor so I am familiar with the best ways to set things up.

The real missing piece is OneDrive syncing, but its something I can work around, especially since these folders already sync via my Synology.

Most everything else I use on the Laptop was just a matter of making a list in Windows and then downloading them in Linux. Mostly I just use the thing for writing and for sorting image files off my phone.

NAS Recovery

What a fun time it’s been with my Synology NAS lately. And before I get going here, I want to make it clear, nothing here is a knock against Synology, or WD for that matter. The NAS I have is like ten years old, if it had failed, I was already pricing out a new, up-to-date, Synology. Heck, I may still get one anyway.

But for now, it seems to be working fine again.

As I mentioned, it’s been like ten years or so. I ran on one 4TB WD Red drive for a long time. Eventually, I did add the second drive to make things RAID and redundant. Sometimes last year, my original WD drive died on me, I ordered a replacement and swapped it out, and everything was fine.

Sometime, maybe a month ago now, I received an error about a drive failure. The newer drive was already showing bad. I made up an RMA request with Western Digital, wiped the drive, and then sent it in. They sent me a replacement.

A short time before the replacement arrived, I found another error, “Volume has crashed”. It showed that the, at the time, one drive was “Healthy”, and I could still read all of my data. This was starting to feel a bit suspect. I have everything important backed up online to OneDrive, but just in case, I started pulling things off to other storage as a secondary backup. This basically involved eating up all the spare space on my project server (temporarily) and using a USB enclosure and an old 2TB drive that, seems to be failing, but would work well enough for short-term storage. The point was, if I had to rebuild things, I would not have to download mountains of data off OneDrive. USB transfer is much easier and faster.

With everything backed up, I received the replacement for my RMA drive. My hope was, I could attach the replacement drive, and whatever was causing this Volume to show as crashed would clear itself out. Unfortunately, I could not really interact with the volume at all.

After several attempts at various workarounds, I gave up on recovering the Volume. I had the data, that is what matters.

I pulled the crashed drive out, which allowed me to create a new volume using the new drive. I then recreated the set of shared network folders, Books, Video, Music, Photo, General Files, as well as reestablished the home folders for users.

Fortunately, because I kept the same base names, all of my Network Mapped drives to the NAS, just worked. Fixing my own connections would be easy, hassling with connections on my wife and kids’ laptops, would be a pain. They get all annoyed when I do anything on their laptops.

Unfortunately, the crashed volume seems to have killed all of the apps I had set up. This is not a huge loss honestly, I don’t actually use most of the built-in Synology apps anymore beyond Cloud Sync and the Torrent client. The main one I need to reconfigure is the VPN client. I may just move that to a docker instance on my project PC. Fortunately, last year, I pulled both my email and blog archives off of the NAS. All my email is consolidated again in Outlook, and my blog archive is in a Docker container now. This means I can just remove all of these apps instead of reinstalling them.

I did find that I had failed to do a fresh local backup of my “Family Videos” folder, but I was able to resync that down from the One Drive backup. Speaking of which rebuilding all those sync connections was a little tedious since they are spread across two One Drive accounts, but I got them worked out and thankfully, everything recognized existing files and called it good. While I didn’t put everything back on the NAS, I have a few things that are less important that I’m just going to store on the file server/project server, I somehow gained about 1.5TB of space. I’ve repeatedly checked and everything is there as it should be. I can only speculate that there was some sort of residual cruft that had built up over time in logs or something somewhere. I also used to use Surveillance station, so it’s possible I had a mountain of useless videos stored on it.

In general, it’s actually been a bit of an excuse to clean up a few things. I had some folders in there that used to sync my DropBox and Google Drive, neither of which I use anymore, for example.

I am 99% sure everything is back in working order, and the last step I keep putting off is to whip the drive from the crashed volume (it still reads healthy) and read it to the current, new volume.

It’s been a hassle, but not really that bad. The main hassle is because it’s large amounts of data, it often means starting a copy and just, letting it run for hours.

Recovering Files with Runtime Software’s GetDataBack

I like to think I am fairly decent at data recovery, or I used to be, though I have not really had a need in more recent times, and being “fairly decent” is mostly, “Knowing where to find what tools to use.” It’s not like I am out here replacing drive power boards or, I don’t know, manually laser imaging disc platters or something. I used to use a piece of software called R-Studio. I am not sure it even really exists anymore. Whatever the case, the key I have for that is from a version from the mid-2000s.

It’s… Like 20 years old…

Fuck I am old.

….

Anyway, my experience with R-Studio was pretty great, I mostly used it in my old office IT job. We bought a copy when one night the automation system we used to run the TV station had a drive failure. Reprogramming it would have been a bitch (but doable). I pulled the PC out, we thought about our options and went with this data recovery route. The drive was able to be reimaged onto a good drive and the system was up and running again.

Yay.

Over the years I used it pretty regularly to recover crashed laptops from coworkers. Generally just the Documents and PST files in those cases though. It was also useful for my own drives and drives of people I knew.

The years, however, made me a bit jaded about being IT Support for everyone I had ever met. There are quite a few jokes about this around online, and it’s true. These days, I basically will just “play dumb” because if you fix one problem for one neighbor, now you will be fixing everyone’s PC issues.

And let me tell you, that is often self-inflicted on what those issues are, which is worse than dealing with real technical problems. Sorry I can’t recover your Pentium, no I can’t make it run Facebook Faster, it’s just too old.

Anyway, at one point I lost some family photos when an external drive crashed on me. This caused two things to happen. One, I will never ever buy a USB drive again, or at least not trust them with important data. I am talking about things like those Seagate drives that have a TB or more that plug into the wall and your PC. It doesn’t help that they also are designed in a way that the plastic housing can’t be removed easily and often requires DESTROYING the housing to recover them. Two, it caused me to get serious about backup, and the cloud. I have used a few different services over the years, but for a long time, I have been at the point where my entire house could burn to the ground and my data would be safe and recoverable.

I have a cloud-synced backup with some versioning and the whole “recycle bin” option in One Drive and I keep an incremental backup on a hard drive in a static bag in a fire safe in the house. Plus all the data is in a RAID on my NAS.

But I don’t back up EVERYTHING. That would be too much data because I am a bit of a data hoarder. And a lot of the non-essential stuff gets stored on an assortment of “dodgy drives” that I have collected over the years from a variety of places. For example, I am currently using my previous “Degraded per Synology” NAS drive as a base to build a PLEX server. I mean, it didn’t technically fail, Synology just didn’t like it, and so I replaced it in the NAS, and now it’s a 4TB drive that, is probably mostly still sort of good.

Anyway, I had one of those USB drives that I mentioned above as having sworn off that was previously working for this task. My wife goes to a LOT of estate sales as part of her business and I often tag along. At one I found this drive stuck buried on a bookshelf, so I bought it for like $5. I figured it was probably good, and it worked, for a bit. But as they usually seem to do, this sucker decided to die on me.

I tried to see if I could get it to read with some Linux tools, but I had little luck. I went online looking for data recovery tools and remembered using straight search is a bad idea for this because it’s going to be 99% “articles” from companies recommending their own software. So I went to Reddit, and had GetDataBack suggested.

I downloaded it and it managed to detect the drive and files. I decided to bite the bullet and paid for the full version, which is not cheap at $80, but I have some other drives I could run through this and it’s a “lifetime license” so I will eventually feel like I am getting my money’s worth.

And it’s working just great. The only real problem I am having is that it won’t recover to a network drive and my PC’s internal drive does not have 2TB of space on it, so I have to recover things in chunks, then copy it over to its final storage place. Well, that and the normal issues that come with a failed/failing drive where sometimes things get hung up and just don’t recover. The interface is straightforward and nice as well, though not super pretty.

Like I said, I am sure I will get my money’s worth. I have a drive that was my brother’s somewhere that I can try to recover. I also have some NVME drives that I will need to get a USB hook up for, but I wouldn’t mind trying to get data back off of those.

Dead Memory Cards and Using Docker

More often that it feels like it should, something in technology breaks or fails. I find that this can be frustrating, but often ultimately good, especially for learning something new, and forcing myself to clean up something I’ve been meaning to clean up. I have a Raspberry Pi I’ve been using for a while for several things as a little web server. It’s been running probably for years, but something gave out on it. I’m not entirely sure it’s the SD card or the Pi itself honestly, because I’ve been having a bit of trouble trying to recover through both. It’s sort of pushed me to try a different approach a bit.

But first I needed a new SD card. I have quite a few, most are “in use”. I say “in use” because many are less in use and more, underused. This has resulted in doing a bit of rebuild on some other projects to make better use of my Micro SD cards. The starting point was a 8 GB card with just a basic Raspbian set up on it.

So, for starters, I found that the one I have in my recently set up music station Raspberry Pi is a whopping 128gb. Contrary to what one might thing, I don’t need a 128gb card in my music station, the music is stored on the NAS over the network. It also has some old residual projects on it that should really be cleaned out.

So stuck the 8GB card in that device and did the minor set up needed for the music station. Specifically, configure VLC for Remote Control over the network, then add the network share. Once I plugged it back into my little mixer and verified I could remote play music, I moved on.

This ended up being an unrelated side project though, because I had been planning on getting a large, speedy, Micro SD card to stick in my Retroid Pocket. So I stuck that 128GB card in, the Retroid and formatted it. This freed up a smaller, 32GB card.

I also have a 64GB that is basically not being used in my PiGrrl Project I decided to recover back for use. The project was fun, but the Retroid does the same thing 1000x better. So now it’s mostly just a display piece on a shelf. Literally an overpriced paperweight. I don’t want to lose the PiGrrl configuration though, because it’s been programmed up to work with the small display and IO Control Inputs. So I imaged that card off.

In the end though, I didn’t end up needing those Micro SD cards though, I opted for an alternative option to replace the Pi, with Docker on my secondary PC. I’ve been meaning to better learn Docker, though I still find it to be a weird and obtuse bit of software. There are a handful of things I care about restoring that I used the Pi for.

  • Youtube DL – There seem to be quite a few nice Web Interfaces for this that will work much better than my old custom system.
  • WordPress Blog Archives – I have exported data files from this but I would like to have it as a WordPress Instance again
  • FreshRSS – My RSS Reader. I already miss my daily news feeds.

YoutubeDL was simple, they provided a nice basic command sequence to get things working.

The others were a bit trickier. Because the old set up died unexpectedly, The data isn’t easily exported for import, which means digging out and recovering off of the raw database files. This isn’t the first time this has happened, but its a lot bigger pain, which isn’t helped by not being entirely confident in how to manipulate Docker.

I still have not gotten the WordPress archive working actually. I was getting “Connection Reset” errors and now I am getting “Cannot establish Database connection” issues. It may be for nothing after the troubles I have had dealing with recovering FreshRSS.

I have gotten FreshRSS fixed though. Getting it running in Docker was easy peasy. Getting my data back, was… considerably less so. It’s been plaguing me now when I try to fix it for a few weeks now, but I have a solution. It’s not the BEST solution, but it’s… a solution. So, the core thing I needed were the feeds themselves. Lesson learned I suppose, but I’m going to find a way to automate a regular dump of the feeds once everything is reloaded. I don’t need or care about favorited articles or the articles contents. These were stored in a MySQL database. MySQL, specifically seems to be what was corrupted and crashed out on the old Pi/Instance because I get a failed message on boot and i can’t get it to reinstall or load anymore.

Well, more, I am pretty sure the root cause is the SD card died, but it affected the DB files.

My struggle now, is recovering data from these raw files. I’ve actually done this before on a surver crash years ago, but this round has lead to many many hurdles. One, 90% of the results looking up how to do it are littered with unhelpful replies about using a proper SQL dump instead. If I could open MySQL, I sure as hell would so that. Another issue seems to be that the SQL server running on the Pi was woefully out of date, so there have been file compatibility problems.

There is also the issue that the data may just flat out BE CORRUPTED.

So I’ve spun up and tried to manually move the data to probably a dozen instances of MySQL and MariaDB of various versions, on Pis, in Docker, on WSL, in a Linux install. Nothing, and I mean NOTHING has worked.

I did get the raw data pulled out though.

So I’ve been brute forcing a fix. Opening the .ibd file in a text editor gives a really ugly chuck of funny characters. But, strewn throughout this, is a bunch of URLs for feeds and websites and well, mostly that. i did an open “Replace” in Notepad++ that stripped out a lot of the characters. Then I opened up Pycharm, I did a find and replace with blanks on a ton of other ugly characters. Then I write up this wuick and dirty Python Script:

# Control F in Notepad++, replace, extended mode "\x00"
# Replace "   " with " "
# replace "https:" with " https:"
# rename to fresh.txt

## Debug and skip asking each time
file = "fresh.txt"
## Open and read the Log File supploed
with open(file, encoding="UTF-8") as logfile:
    log = logfile.read()

datasplit = log.split(" ")
links = []

for each in datasplit:
    if "http" in each:
        links.append(each)

with open("output.txt", mode="w", encoding="UTF-8") as writefile:
    for i in links:
        writefile.write(i+"\n")

Which splits everything up into an array, and skims through the array for anything with “http” in it, to pull out anything that is a URL. This has left me with a text file that is full of duplicates and has regular URLs next to Feed URLS, though not in EVERY case because that would be too damn easy. I could probably add a bunch of conditionals to the script to sort out anything with the word “feed” “rss”, “atom” or “xml” and get a lot of the cruft removed, but Fresh RSS does not seem to have a way to bulk import a text list, so I still get to manually cut and paste each URL in and resort everything into categories.

It’s tedious, but it’s mindless, and it will get done.

Afterwards I will need to reset up my WordPress Autoposter script for those little news digests I’ve been sharing that no one cares about.

Slight update, I added some filtering ans sorting to the code:

# Control F in Notepad++, replace, extended mode "\x00"
# Replace "   " with " "
# replace "https:" with " https:"
# rename to fresh.txt


## Debug and skip asking each time
file = "fresh.txt"
## Open and read the Log File supploed
with open(file, encoding="UTF-8") as logfile:
    log = logfile.read()

datasplit = log.split(" ")
links = []

for each in datasplit:
    if "http" in each:
        if "feed" in each or "rss" in each or "default" in each or "atom" in each or "xml" in each:
            if each not in links:
                links.append(each[each.find("http"):])

links.sort()

with open("output.txt", mode="w", encoding="UTF-8") as writefile:
    for i in links:
        writefile.write(i+"\n")