Title photo
frugal technology, simple living and guerrilla large-appliance repair

Regular blog here, 'microblog' there

Many of my traditional blog post live on this site, but a great majority of my social-style posts can be found on my much-busier microbloging site at updates.passthejoe.net. It's busier because my BlogPoster "microblogging" script generates short, Twitter-style posts from the Linux or Windows (or anywhere you can run Ruby with too many Gems) command line, uploads them to the web server and send them out on my Twitter and Mastodon feeds.

I used to post to this blog via scripts and Unix/Linux utilities (curl and Unison) that helped me mirror the files locally and on the server. Since this site recently moved hosts, none of that is set up. I'm just using SFTP and SSH to write posts and manage the site.

Disqus comments are not live just yet because I'm not sure about what I'm going to do for the domain on this site. I'll probably restore the old domain at first just to have some continuity, but for now I like using the "free" domain from this site's new host, NearlyFreeSpeech.net.

Fri, 13 Oct 2017

How to back up your /home directory in the Windows Subsystem for Linux without losing permissions before killing your old WSL and installing a new one from the Windows Store

The Windows Subsystem for Linux - which is no longer being referred to officially as "Bash on Windows" - has grown up.

You no longer need to put your Windows 10 system into Developer Mode to use the WSL.

And now there are three different WSLs: Ubuntu, openSUSE and SUSE Linux Enterprise Server. Fedora is supposed to be on the way, but I haven't heard anything about progress toward that happening in a long time.

According to Microsoft, you can copy your current Ubuntu files to /mnt/c/tmp/WSL-backup, or a similar directory, and then use lxrun /install from the Windows command line to remove the old WSL. Then you can install a new WSL and move your files back after that.

Fellow Redditors suggested that I create a tar archive of my files, stow it anywhere, and then unpack it in my new /home directory when I remove the old WSL and install the new one via the Windows Store.

The only thing keeping me from doing it is what always keeps me from switching Linux distros: The need to re-install all of my packages.

The other thing keeping me from making this move is that my laptop hasn't yet received the Windows 10 Fall Creators Update. To successfully install the new WSL, your Windows build needs to be 16215.0 or higher. According to my About Windows 10 page, I'm on 15063.674. So not only can I wait, unless I opt to get the updates early (and I'm sure there is a way to do this), I must wait. And honestly, that doesn't bother me one bit.

Update: (July 4, 2018): Here is my Independence Day update to these instructions. The "original" instructions should work fine, but the "new" ones are better:

The original instructions

Originally I created the tar archive of my home directory in my home directory:

$ tar -zcvf steven.tar.gz /home/steven
$ cp steven.tar.gz /mnt/c/Users/steve/OneDrive/Documents/linux_backup/

And to open it up when your new WSL is set up, go to your home directory:

$ tar -zxvf /path/to/steven.tar.gz

Then you'll have a home directory within your home directory (i.e. for me /home/steven/steven, and you can copy what you want from one to the other). It's better not to overwrite everything in your "new" Linux /home directory because it might handle things in your dot files differently, and I can see conflicts arising from npm modules, ruby gems and whatever else you happened to install in the course of working in your Windows box's Linux side.

I'm not sure how much of a problem it is, but creating the tar archive while in your home directory causes tar to throw the following error:

tar: Removing leading `/' from member names
... (lots of output)
tar: Exiting with failure status due to previous errors

There are explanations of what this error message means on the Internet, but they didn't really help me understand it.

So I did things a different way. If you just want to know how to make the backup and restore it, start here:

The new instructions

First, on the Windows side, create a directory in which to hold this backup. I created one called linux_backup in my OneDrive Documents directory.

Then go into your WSL, which will put you in your home directory on the Linux side (which for me is /home/steven).

From there, to avoid the error message I go up one directory and do the tar operation from there. I use pwd a couple of times to confirm where I am in the filesystem, and I use chown to make sure the restored archive belongs to my Linux user and group.

Note: in all of these instructions, things after a $ are things you type at the command line. Lines that don't begin with a $ represent output in the terminal (and you don't have to type them).

Here is what my terminal session looks like:

$ pwd
/home/steven
$ cd ..
$ pwd
/home
$ sudo tar -zcvf steven.tar.gz steven
$ ls
steven steven.tar.gz
$ chown steven:steven steven.tar.gz
$ sudo cp steven.tar.gz /mnt/c/Users/steve/OneDrive/Documents/linux_backup/

Now you have your tar archive on the Windows side.

After you set up your "new" WSL, you can copy the tar archive from the Windows side into your new Linux /home directory. As before, I use a couple of pwd command to confirm where I am in the Linux filesystem. (And remember, use YOUR home directory and Windows path to your tar archive, not mine):

$ pwd
/home/steven
$ sudo cp /mnt/c/Users/steve/OneDrive/Documents/linux_backup/steven.tar.gz steven.tar.gz
$ sudo chown steven:steven steven.tar.gz
$ tar -zxvf steven.tar.gz
$ ls
steven
$ cd steven
$ pwd
/home/steven/steven

Now you have your "new" home directory at /home/steven, and your "old" files at /home/steven/steven. Copy what you want from old to new, and you should be ready to go.

Once you confirm that all your files are in there, you can blow away the old WSL and use your new one. And you should still have a copy of the tar archive on your Windows filesystem if anything goes wrong.

Before going forward, it's a good idea to read up on how to make a tar.gz archive.

My question (and maybe yours): Why do this from the Ubuntu/WSL shell when you could just copy/paste from the Windows file manager, or why not just copy the files via the Ubuntu shell to the Windows portion of the disk?

Answer (and I did test this): In both cases, even when using Bash to do the recursive cp of all the files, you lose your Linux file permissions. In my case, all of my rw-r--r-- files turned into rwxrwxrwx, which is NOT what you (or I) want.

Update on 4/23/18: This entry was written last October but not published until now. It kind of got lost, and I just found and finished it. Though the new WSL is out, and you can now install Debian (which I would) or SUSE (probably not), I'm leaning toward sticking with Ubuntu because it's working so well, though I'm a longtime Debian fan and user (though not so much lately).

Whatever I do, I probably need to move to the "new" WSL, though I haven't done it yet. Everything is working, so it's hard to muster the motivation to mess with what until now has been a successful installation of Ubuntu in Windows 10.

Update on 7/4/18: The new instructions for making an archive of the /home directory are more detailed and a little more roundabout. But they should work, and tar won't throw any errors.

Also, I still haven't moved to a new WSL. The current Ubuntu WSL is still on 16.04 LTS, and that's the same version as my "old" WSL. When the Ubuntu WSL moves to 18.04 LTS, then it'll be time to make the change.

Sun, 24 Sep 2017

I'm thinking about OpenBSD again

I received an email recently from Ewa Dudzic of BSD Magazine asking to interview me. I demurred because I'm barely using Linux right now, let alone a BSD. My "intense" BSD period was around 2008-09 when I had a laptop that wouldn't boot from CD, and OpenBSD's floppy image (you heard right) allowed me to get it up and running.

I blogged a lot about it. I had a lot of fun with OpenBSD, and I tried a couple of others with endings both catastrophic (FreeBSD, where updates puzzled me and broke the system) and anticlimactic (DragonFlyBSD, where too many applications didn't work).

I've done a few sporadic OpenBSD tests since then, but circumstances at both my work (needing Citrix) and personally (not so interested in operating systems or free software as a movement, seeing overall interest in free software wane considerably since Windows 7 came out, and my growing interest in programming) led me to the point where I was running Fedora on my "old" laptop and Windows 10 with the Windows Subsystem for Linux on my "new" laptop.

I'm still very much involved in programming, using Ruby, Java, the Bash shell and a little bit of Perl.

And in my day job, I can mostly leave my Citrix-delivered system behind in favor of a whole lot of WordPress.

And -- yes there is another and -- these days I mostly use an old Roku (with USB input) for video, so my laptops don't double as entertainment machines.

Could I set up my old laptop as a development machine using OpenBSD?

The one difference in favor of this is the JDK being available as a package. Installing the Java Development Kit back in 2009 was far from easy. I can't remember if I was even able to do it.

Adding Ruby and Node seem easy. Will Ruby gems and npm packages work? That's something I'll have to investigate as I go.

Whenever I look at the OpenBSD website, documentation and, more importantly, extensive list of available packages, I get hopeful about the system working for me.

I'm not afraid of a little maintenance, and the new syspatch utility promises to make updating the base system quicker and easier than ever before. Being OK with the same non-base packages for six months is potentially unsettling, but for a sane system that just works (just works is very, very important to me these days), I could be OK with it. What I don't want is problem after problem after problem with basic functionality (display, WiFi, sound, CPU heat, suspend/resume). I'm cautiously ... cautious.

I have learned that there are OpenBSD communities on Reddit and Facebook and probably in other places (obviously including openbsd.misc).

I've already started collecting links (mined from Reddit) to help me get an OpenBSD system installed and configured:

Since my old laptop (HP Pavilion g6 from 2010) has easily swappable drives, I can put test OSes on their own drive and not worry about partitioning or blowing out a production system.

I just got an OpenBSD 6.1 image on a USB drive using Win32 Disk Imager in Windows 10, and I'm ready to do the installation.

So am I a good candidate for a BSD-focused interview? I'm not an OS developer, or a serious sysadmin. (I do play at being a sysadmin, don't get me wrong. I run a CentOS system on the live Web, though I do have help when the going gets tough.)

I'm just a user, but I have blogged plenty about what I do with the software I use, and that's not as common as you'd think (and seeming to be out there alone did push me away from my steadfast commitment to open-source operating systems). So the answer is "maybe," and maybe in the days ahead I'll have something to say about OpenBSD in the late 2010s.

Updates (newest first):

  • I have done two OpenBSD 6.1 installations on my HP Pavilion g6. The internal Atheros WiFi doesn't work, so I'm using the wired network and an old Realtek-based USB WiFi stick. I blew up the first installation, and now I'm working on the second. I still can't believe that it's so easy to get the JDK installed and running (add the package, add the path to the JDK binaries -- /usr/local/jre-1.8.0/bin -- to your path in .profile ... and that's it).
Sun, 17 Sep 2017

Building a Twitter clone with Meteor

From The Meteor Chef:

Tue, 12 Sep 2017

How do I make this program?

I want to create a program that helps me quickly write up a blog post -- especially a "social" blog post based on a link -- and upload that post as a file to a flat-file-driven blogging system.

In case it isn't obvious, I'm not a professional developer. The whole "hey, let's learn to code just because" thing doesn't work so well for me. Tutorials aren't my thing. I need a project. Then I'm compelled to learn what I need to make that project happen, at least in some fashion. The first thing to do is come up with something doable and not so difficult that I can't even get close.

Hence my idea: a flat-file blog posting machine. It's not too complicated. It would be geared mostly for "social" posts, which I stash in a dedicated category directory-driven category on my blog and let IFTTT (and formerly dlvr.it scrape and then send to Twitter. Why do I do this? Because I feel better about "giving" Twitter my free content to promote their business when I have that same content on my website that is wholly owned and operated by me and not them.

Back to the program: I want to be able to enter a URL from a post/story/page that interests me into a box and then have that box generate a title, post body, file name and actual file with the ability to make changes in any of these fields -- all with as little required input from me as a "regular" Twitter post. The program would then upload the file it creates to my web server, also taking care of whatever back-end housekeeping is needed to make that post appear on the blog. And if I could figure out the Twitter API, I could also trigger the social post itself and eliminate the need for IFTTT or dlvr.it.

Read the rest of this post