Sunday, 2 August 2020

Home NAS part 1: Biting the Bullet

After many years of wanting and putting off getting a dedicated Network Attached Storage, I have finally ordered a Synology DS720+. Literally just ordered it and it's not here yet, so this will briefly by about the "why".

Cloud storage is great including Google Photos to hoover up pictures and Microsoft OneDrive for shared files especially MS Office documents. Definitely the best if the free or paid tiers work for you but for me it was going to be too costly. I've been trying other ways like running a file share on an old computer but its too loud and takes too much space or hooking up a USB drive to my Asus RT-AC86U but it's SMB1 and acts weird. So a NAS - a dedicated device that will be compact, quiet, power efficient, feature rich and upgrade-able. 

Synology, QNAP, and others make a plethora of products and I rely on Dong Knows Tech and also on write-ups like this one on the whole current Synology + series on NAS Compares. I've used both Synology and Qnap at #dayjob and Synology I think is more for tinkerers and I do like to poke things with sticks.. 

How big a NAS? It really came down to that I know I will want to upgrade the hard drives in the future so I want the fewest possible and that I can get the capacity I want on a 2 bay unit. 

And then the model comparison - if you go on Synology's site and look at their products even limiting to 2-bay models only they have 8 current products. What the great mother of Fridays? It came down to that I will heavily use a NAS and the price differences were relatively small to go right to the DS720+. 

Alternatively, for something for backups and basic file sharing, people frequently sell their old NAS on Craigslist / FB Market. I wouldn't buy drives secondhand, they're the only components that routinely fail and every year someone else used them is a year less life they have. Otherwise, yeah buying a NAS second-hand would be great get a couple new drives, awesome. 

Time to go check my shipment status again...

Ciao


Tuesday, 7 July 2020

Windows Terminal Is The Best

Only been using Windows Terminal for 10 minutes and already it's clearly the best! I heard it from Kayla Cinnamon on RunAsRadio Podcast and right away installed it from the MS Store.

Tabs? Yes
Launches PowerShell? Yes
Does "cmd.exe" sux? Yes

RunAs Radio Windows Linux Subsystem with Tara Raj and Sarah Cooley also put me onto WSL which I now always advocate rather than running a VM (unless you really need one) or Cygwin (nobody needs Cygwin). The slick thing with Terminal was that it dynamically added a profile for WSL after I installed it!



Between these couple utilities, WSL and Terminal, many of us can shed all our Linux stuff; virtual machines, Cygwin, Putty, Term, WinSCP, etc. And be better for it.

Ciao 😎

Tuesday, 31 March 2020

Outlook Archive Button

What do you do if your Outlook Archive button is stuck sending messages to your old custom folder and your mobile is sending messages to the "Archive" folder and there's no option anymore in your Outlook to change this?

You change your Language.

I did this in Outlook Web Access and the one thing it will have to do is rename your "Archive" folder (archive-old or whatever) before changing the language settings.

https://support.microsoft.com/en-us/office/change-the-time-zone-and-language-settings-in-outlook-on-the-web-65239869-12e7-4a9d-bca1-76b0ad7ce273

That's a pretty well buried solution, even by Microsoft standards, and frankly I doubt anyone will ever see this post because if you search Online for "Outlook Archive change folder" or whatever, you'll get plenty of hits for the old Outlook so not really an easy way to look up this solution. But maybe, just maybe, this post will find a way to someone

Outlook has this "Archive" button - it's in Outlook, Outlook Web Access, Outlook mobile app, and it only does one thing - it puts the selected email message(s) into a folder called "Archive". It's a very quick way to file email because you also have short-cuts for it - the Backspace key in Outlook or a swipe gesture on mobile.


But what it used to do was used in an earlier version was ever so slightly different in that you could pick a folder for it - a folder with any name. After my Outlook was upgraded, it was still working and sending email to my custom named "All Mail" folder but my mobile started sending messages to the "Archive" folder, and Microsoft removed the option to pick what folder you used from Outlook. I haven't been able to figure this out for a long time which is why I'm posting this at all...

...

So yeah, that's the fix. Change your Outlook from English to French which renames all the stock system folders, Inbox, Sent, etc... and the Archive folder. Then move all your messages from "archive-old" or whatever you used and move them into Archive.

Ciao!

Sunday, 20 October 2019

Python Logging

For those of us that start a program with "print" statements to get our bearings, the Python logging library is a drop-in replacement. After creating the logger, you can replace "print" statements with logger.debug('same text as before') or use suitable levels from debug, info, warning, error, and critical. You quickly get logging that can be configured to different levels you can use from debugging during development and clear output for the program running. There's also a built-in handler on logging exceptions to cleanly log exception info during exception handling. The library and cookbook are both clear and illustrative so check these links out:

Python 3 Library - Logging

Python 3 Logging Cookbook

I mentioned shell logging last time here:

I'm a Logger and I'm Okay

The other tool I use all the time in Python is the "assert" call which raises an error with message given. For example to sanity check the resulting size of a blob is matching your file size:

# sanity check the resultant blob is the same size as what's in the database
assert (os.path.getsize(outpath) == len(imgblob)), "File size %d does not match blob size %d for image %d in %s saved to %s" % (os.path.getsize(outpath), len(imgblob), imgid, args.table, args.archivepath)
There's every opportunity to properly handle program output and errors.

Ciao


Sunday, 3 March 2019

I'm a [logger] and I'm OK!

The "logger" command can send a text string to the syslog. #why-didn't-I-know-that-already

http://manpages.ubuntu.com/manpages/xenial/man1/logger.1.html

localadmin@mypc:~$ logger Mark
localadmin@mypc:~$ sudo tail /var/log/syslog
Oct 31 15:23:40 mypc systemd[16714]: Listening on GnuPG cryptographic agent and passphrase cache (restricted).
Oct 31 15:23:40 mypc systemd[16714]: Reached target Timers.
Oct 31 15:23:40 mypc systemd[16714]: Listening on GnuPG network certificate management daemon.
Oct 31 15:23:40 mypc systemd[16714]: Listening on D-Bus User Message Bus Socket.
Oct 31 15:23:40 mypc systemd[16714]: Reached target Sockets.
Oct 31 15:23:40 mypc systemd[16714]: Reached target Basic System.
Oct 31 15:23:40 mypc systemd[16714]: Reached target Default.
Oct 31 15:23:40 mypc systemd[16714]: Startup finished in 44ms.
Oct 31 15:23:40 mypc systemd[1]: Started User Manager for UID 1000.
Oct 31 15:23:46 mypc localadmin: Mark 
In other news I updated my page on useful PC tools



Ciao

Tuesday, 30 October 2018

Working with DNS settings in systemd-resolved in Ubuntu

In troubleshooting some DNS name resolution issues I started to get more familiar with systemd-resolved in Ubuntu. Specifically if you look at the traditional /etc/resolv.conf file it says something like this:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.
nameserver 127.0.0.53
Hah hah! Subtly clever for any old hands in networking because "53" is the standard DNS port so 127.0.0.53 is a little clue to look for something specific.

Go ahead though - run "systemd-resolve --status", it doesn't require root, and it shows you a lot of info (the IPs of name servers have been change to protect the innocent...)
localadmin@ca-yvr-adm2:~$ systemd-resolve --status
Global
         DNS Servers: 10.1.1.11
                      10.2.2.12
          DNS Domain: sub.example.com
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      <snip>
                      local

Link 1 (eno1)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

The config file is easily found in "/etc/systemd/resolved.conf" and it's quite short and simple and it should look familiar if you have used other systemd configurations before. The configuration out-of-the-box will be blank with all options commented out. I wanted to add additional search domains to the Domains line, in the same space-delimited way you would traditionally do the search line in your resolve.conf.
[Resolve]
#DNS=
#FallbackDNS=
Domains=sub.example.com example.com example.local
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes

Restart the same as you would any other systemd tool, and then re-check your resolved status
sudo systemctl restart systemd-resolved.service 
systemd-resolve --status

OR check your /etc/resolve.conf file because if your only change is to modify the search domains, it also appears there for the resolver to work normally.
Global
         DNS Servers: 10.1.1.11
                      10.2.2.12
          DNS Domain: sub.example.com example.com example.local
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      <snip>
                      local

Normally you would be done... Here's a couple bonus tricks that may arise.

You can modify DNS settings by interface - furthermore this is handy for testing DNS changes and reverting before making the change in the config file. Check out systemd-resolve --help 

The multicast service may conflict with a .local domain. The symptom I had was that I could resolve a short name like "pc" but could not resolve an FQDN like "pc.example.local". If you are using .local and finding odd DNS resolution results, edit your nsswitch.conf  and move "dns" earlier than the mdns (keep it after "files" though to avoid breaking your hosts file).

I've tried to make this a quick and useful blurb on how to use systemd-resolved and get pointed in the right direction because the documentation available wasn't simple for simple cases - there is certainly a lot of tuning you can do with the resolver tools.

Ciao

Wednesday, 3 October 2018

Archiving Files (E.g. Deleting Stuff) is My Super Power!

This week one of the things I was working on was archiving a lot of files on a file in order to prune it down ahead of migrating that share to a new location.

In particular this share while only ~100GB has > 3M files on it! Any basic operations like checking folder sizes, applying ACLs, etc are very slow on xM files. Looking at the share with WinDirStat I found that there's a large number of folders each with 20-50K files in each. Furthermore the majority of these files were old (years) and not actively used so we decided to Archive (e.g. Delete) the contents of these folders.

I started by using 7-Zip and there's an option on the Add to Archive screen to "Delete files after compression":


And that's pretty good! ... But not if you've got hundreds of folders to process.

Instead, with a bit of PowerShell, we invoke 7-Zip from a script and use the -sdel switch to remove files after they've been archived. This PS we used to simply to stuff each sub-folder into an archive.

Get-ChildItem . -Directory |  ForEach-Object  {
 $Archive = $_.Name + ".zip"
 $Folder = $_.Name + "\"
 &"C:\Program Files\7-Zip\7z.exe" a $Archive $Folder -sdel
}
Pow!

Popular Posts