Saturday, October 22, 2016

On making OpenSUSE LEAP and Tumbleweed My Main At Home Working OS

For the last few months I have been using OpenSUSE Tumbleweed as my main home pc operating system. I  love setting up my system with a pragmatic combination of command line tools, plus having YAST and the nice Gnome and KDE Plasma desktops and the QEMU/KVM based virtualization system, which I have been running a Windows VM inside of.

Windows and Linux Guy Goes Linux Only (With Dual Boot for the Kids)

Because I work professionally with Windows, and periodically wish to maintain some of my side projects which run on Windows, I have been running VMs with various Windows versions, lately mostly Windows 10. Why? Because it's the most convenient place for me to run the set of modern Windows development tools I want to run including Visual Studio 2015.  What's terrible about Windows 10 is that it's a real bloated pig of a thing and unlike Windows 7 you can't shut off the bits that want to take over your disk and your CPU at will. It feels entitled to update or scan, or cache giant downloads, whenever it wants. It feels entitled to use all my disk I/O bandwidth to do silent updates whenever it wants. It feels it's okay to run 100 system services and then tell me that even when I'm the local administrator (a former equivalent of Linux root user)  that I don't really have root level access to my machine. My machine belongs to Microsoft.  That is at the heart of why I relegate windows to a VM. I don't trust it, and I don't trust Microsoft.   Prove me wrong, Satya Nadella.  Prove me wrong.  Recently I read the Microsoft has opened up centers to allow governments to look at the code of Microsoft Windows to see if Windows is spying on them.  My take on that is that it's a show.  Even if Microsoft wanted to prove that it's not spying, how can it do so? The very closed source nature of Windows, and its ability to deliver new stuff quickly behind the scenes means that even if Microsoft is not currently spying on you (and most likely they're actually not), that could change without any notice to you.  KB31359719 that introduces wide area surveillance by the NSA is only a windows update cycle away.    In fact, at a company the size of Microsoft I'd be surprised if there weren't things going on inside Windows that even Raymond Chen and Mark Russinovich don't know is going on, let alone say Satya Nadella.

So yeah. I still have a windows VM.  Because my kids like to play windows games, I also have a second hard drive with a native Windows 10 install that has a large library of Windows games (via Steam) that I can boot into by a secret hand-signal.  The secret hand signal is pressing F12 to get to my bios boot device selection menu (as opposed to putting this into grub).  If you press F12 you can select drive 3, of the three drives I have installed, and boot direct to Windows 10.   I feel this is a good penalty box to place Windows in, but I feel nervous about it.  In the past Microsoft has decided that it should be the only operating system on any box that Windows 10 runs on, and if they decide to roll out a windows update that upgrades (again) the partition schema, they don't seem to feel the need to tell anybody else out there about it, and might "upgrade" even other drives. That's a paranoid fear, I hear you telling me that.  No, it's not paranoid. It's just a well known phenomenon in human psychology called the "unknown unknown".  I don't think that in Microsoft's giant test laboratories that they have a machine with multiple operating systems set up just like mine. I just don't think they do.

Three Drives / No Splitting Drives between Linux and Windows

Right now I have three operating systems on three drives. One per drive.  I used to put multiple operating systems on partitions on the same drive, but I have come to think that's a bad idea.   Drive 1 (/dev/sda) is an SSD with  OpenSUSE LEAP.  Drive 2 (/dev/sdb) is a regular 2tb 7200 RPM hard disk with Windows 10 on it, and Drive 3 (/dev/sdc) is a regular 4tb 7200 RPM hard disk with OpenSUSE Tumbleweed and a large pile of QEMU/KVM  VMs on it.  The most recent time I installed OpenSUSE I actually detached all the sata cables I didn't want to get written to by the install.   This seems like a prudent step to me.  If I install an operating system and it decides to rewrite partition tables, or update a boot block, and moves things around, it's not guaranteed that all operating systems on that disk will agree about those changes.  Strange things like partitions disappearing (because there isn't only one agreed upon way of partitioning disks) can happen.  Better not to let operating systems try to share drives, these days, when you run as many different operating systems as I do, and when it doesn't seem that anybody can really feasibly test all these combinations.  Back in 1996 when I would be dual booting Red Hat Linux 4.0, and a DOS+Windows95 system, things were a bit more rational. Some of the newer formats for partitioning disks that we have now did not exist. My first installation of Tumbleweed, I made the mistake of allowing it to write the bootblock on my first disk, which was at the time, a windows 10 boot disk, that was installed with whatever defaults Windows 10 chooses when it owns the whole of the only disk that PC has.  I don't think it uses DOS 6 era partitions anymore. But I'm not sure.

In the old days when I wanted to see a "snapshot" of my storage devices and their mount points I would often use mount but these days the output of that, if you followed OpenSUSE LEAP's automatic partitioning/mounting suggestions is quite huge.  Instead I use my new favorite ls-family command, lsblk:

> lsblk
sda      8:0    0 931.5G  0 disk
├─sda1   8:1    0     2G  0 part [SWAP]
├─sda2   8:2    0    40G  0 part /boot/grub2/x86_64-efi
└─sda3   8:3    0 889.5G  0 part /home
sdb      8:16   0   1.8T  0 disk
├─sdb1   8:17   0   3.7M  0 part
├─sdb2   8:18   0 983.8G  0 part
└─sdb3   8:19   0 878.9G  0 part
sdc      8:32   0 931.5G  0 disk
├─sdc1   8:33   0     1M  0 part
├─sdc2   8:34   0     2G  0 part
├─sdc3   8:35   0    40G  0 part
└─sdc4   8:36   0 889.5G  0 part
sr0     11:0    1  1024M  0 rom 
And then, to get my free space, df -h

Nice.  Much easier to read than the jumble of junk that comes out of the mount command, because on OpenSuSE, there is a btrfs root filesystem, with a lot of subvolumes. When you type mount the output feels to me (linux old timer) like a bit much to digest and comprehend.  And did you ever notice that the output of mount skips over the root filesystem on some Linux systems? On OpenSUSE though, it's in there, embedded  not in there. I'll be honest, I didn't need to know about all the btrfs subvolume mounts, and I would like to know where my root filesystem maps. If anybody knows a command to dump all the mountpoints, omitting subvolume mounts, please do let me know. What I'd like to know that the above lsblk obscures is that my root filesystem is mounted SOMEWHERE inside sda2, that is to say sda2 is not a 40gig partition used only for grub boot efi files .   Everything except /home is mounted on btrfs subvolumes inside /dev/sda2, and root (/) is also a subvolume under sda2.  To find the root dev the following could be put into a shell script or an alias, and I'd call it rdev because busybox and some linux shell utils packages used to contain just such a command:

df | egrep "/$" | cut -d " " -f1
That's better than what I came up with, which is just to grep one line out of mount:

mount |grep " / "

 Thank you to jcsl on #suse channel on, for the above df idea.

In an upcoming post I'll talk more about the snapper tool and the subtleties of the btrfs journaling filesystem.  Yes, OpenSUSE uses btrfs and it's awesome.  It really is a "better" filesystem, and it's quite mature and stable now, it's been around for eight years at this point.

I'll just point out one strange fact at this point; Don't use df to detect free space, it doesn't report the correct values because it doesn't understand how pooling and subvolumes and metadata in btrfs work.   Unfortunately the authors of btrfs have strange ideas about user-interfaces, and they don't tell you "how many gigs are free". You have to subtract A-B yourself:

> sudo /usr/sbin/btrfs filesystem show /dev/sda2
Label: none  uuid: 53ccd989-ad5e-4ef3-aff7-07523c971a2d
        Total devices 1 FS bytes used 6.53GiB
        devid    1 size 40.00GiB used 7.79GiB path /dev/sda2

The above output shows me I have 33 gigs free on a 40 gig btrfs filesystem.  Maybe I'll write my own version of df and make a shell alias for it.  The value above is similar to the output of df / -h but it can be significantly different. Be aware.

The OpenSuSE Installers Are Fantastic  (But give OpenSuSE its own hard drive)

One of my Tumbleweed installs in about July 2016 I let it write  to my main windows 10 system's boot block. It appeared to wipe the partition table information from that boot block that Windows was using.  Windows 10 was rendered inoperable, and as far as I know when OpenSUSE writes the bootblock it doesn't keep a backup anywhere.  I do not recommend allowing OpenSuSE to write to any drive containing a windows 10 boot sector unless you have a full image of that entire physical disk, and also a separate bootblock backup made with dd. The situation is complex, but as I understand it currently,  Windows 10 and OpenSuSE do not share in common an understanding of what goes where in your boot block.  Since one half of that situation (Windows 10) is a closed source operating system built by a company that actually hasn't fully documented how everything works in Windows 10's partition system,  I'd recommend not sharing drives.  I also don't recommend resizing partitions to make Linux fit on your existing drive. If you have a desktop, I recommend you get a second drive. If you have a laptop, everyone (including me) recommends you make a full drive image backup before you try to make a dual boot  windows/linux system.  Resizing partitions and messing around with dual boot is a bit tricky.

Before you allow anything to write to your boot block make sure you back up your bootblock:

   dd if=/dev/sda of=/root/backup_MBR count=1
If you didn't listen to me (and everybody else) and you seem to have wiped your partition tables and lost everything on your drive (like I did), you might want to find out about the amazing gparted tools bootable ISO that you can use to find and recover your data, maybe.  Chastened thus, by my unbridled enthusiasm and disregard for all sane practices, I believe the whole experience of wiping my drive was a good experience.  We need these little setbacks. They can help keep us humble.   Thanks to those awesome people  who make the gparted live boot rescue environment (you can use it on a DVD or USB stick) I didn't actually lose any of the data that I had put on there since my previous data backups.

Installing and Using OpenSuSE LEAP with some nVidia Cards May Still Require proprietary NV X Drivers

OpenSuSE LEAP is a free/open/libre project that also has some non-free bits available.  These non-free bits come in handy for those of us who need to do stuff like use nVidia video cards that the guys at nVidia don't feel like documenting.  All praise to the team behind Nouveau for trying to make the lives of ordinary users better.    I won't be buying any more nVidia video cards. I really should have bought an AMD/ATI card. As a proud Canadian, I'm happy that AMD has kept a lot of ATI-years talent around up here near where I live, and modern AMD/ATI video cards are  a fantastic value, and AMD is a good partner to the OSS world.    nVidia is simply not.   Linus has castigated them on multiple occasions, and while my new self imposed OSS-code-of-personal conduct prohibits me from expressing how I feel about nVidia's actions in the language I would prefer, I will state instead that I am unhappy, and that I intend to vote with my feet and my dollars.   Down with nVidia and down with proprietary binary patent-encumbered blobs.  Up with AMD who somehow lives in the real world and writes both binary patented drivers for their increasingly irrelevant windows desktop share, and who also seems to find a way to document their stuff and collaborate with OSS so that we end users don't have to suffer with broken desktops.  People who go on the OpenSuSE forums and complain about their system not working out of the box with nVidia need to realize that the problem lies with nVidia and not with OpenSuSE or the wonderful folks at Nouveau. For my particular card, the Nouveau driver now works perfectly in Tumbleweed, so my hope is that this driver makes it into the next stable LEAP release.

In LEAP,  My video card (nVidia GeForce GTX 750 series) doesn't work well with Nouveau.  The system boots up to a graphical boot/login screen (even though I told the installer to log in automatically), but logging in and starting the KDE or Gnome session fails, dumping you back at the session-manager login screen.  Switching to the virtual text consoles (Ctrl+Alt+F1) then back to the X11 desktop (Ctrl+Alt+F7) hangs X11, leaving no moveable mouse pointer. It is possible to get back to a text login (Ctrl+Alt+F1) and kill the display-manager service and start it again (service restart display-manager).  The solution is to use YAST or ZYPPER to install the xf86-driver-nv and uninstall xf86-driver-nouveau, which requires also that you use YAST or some editing skills to enable the community nvidia rpm repository.  After doing that, I also need to blacklist the nouveau driver, re-run mkinitrd as root, and reboot. That blocks the nouveau kernel module from loading.   It's necessary on my system, to do this, as root:

echo "blacklist nouveau" >> /etc/modprobe.d/50-blacklist.conf && mkinitrd && reboot

New to Me, and Maybe new to You? journalctl is your friend!

One area of Linux system evolution I have gotten behind on is understanding systemd and what it does, and what journalctl does.   I have learned a new favorite command to go with dmesg and less /var/log/Xyz, and it's this:

sudo journalctl -b

That shows the output of the systemd journal (log) for the current boot up.  This is awesome.  It's like a super-dmesg command.   For example, on my system my kernel is "tainted" by the evil-empire-of-nVidia, and that output has always been visible in dmesg, but it's also in journalctl, which is not limited to the current bootup, and contains more than just kernel log output.

  A fully featured less-style pager appears to be invoked automatically by the above command, so from an interactive terminal, you can type the above command then type > and that gets you to the end of the buffer, and you can then scroll back and you can search with / just like you would if you'd done a less /var/log/foo. I feel a little foolish that I've been using systemd based linux systems for years and never bothered to read the awesome manual

This brings me to the point that OpenSuSE's documentation is fabulous.    No insult to any other community is intended by that.  I'm also quite impressed by the work that the Debian community puts into its distro docs, and the Fedora project is also quite impressive.    Online support on IRC is also important to all three of those communities, and I've hung out quite a bit in the SUSE irc channel, and tried to help a bit.

Minor Annoyances With Workarounds Provided Already

For some reason, since SLES11 (from my googling) the default behaviour of man is insane (displays duplicate pages for almost everything and asks you to pick which one you want).   Who wants this behavior? This might be some "enterprise"-y default that end users don't like. The fix is easy just add the lines below to ~/.bashrc, and is actually reported to you when man does this annoying thing.  I wonder why they left this behavior as the default?

# man brings up annoying duplicates:

The second most annoying thing is that single clicking opens folders in the  KDE Plasma file-explorer (Dolphin).   I find that annoying.    The default behavior in windows actually goes back to the late 1987 IBM Common User Access documents, which describe the standards used in the MS-DOS Executive (Shell), the IBM OS/2 Presentation Manager shell, and which were copied carefully (and with deep understanding) by Microsoft and placed into every version of Windows ever made.  You'll note that even the contrarians at Apple have largely respected many of the CUA precedents. Changing those things is a disaster for usability.  And yet the KDE and Gnome developers (and the Ubuntu more than anyone) seem to periodically get tired of incremental improvements and decide to make whole new user interfaces that wreak havoc on user experience, and verge on user-hostile at times.   But instead of ranting about it, just turn it off, this is Linux, almost everything is easy to change. Click the KDE taskbar icon (equivalent to the start icon in windows), go to the search box and type in  Mouse, and open the mouse window, and change the Single click to open setting to double click.

"Moving In" to a New Linux Box

While I was in there I was amused to read that the default ~/.bashrc has some lines in there that to tell you how to specify your PalmPilot device's baud rate when you connect it with linux. At one time I was a devoted user of my Palm III and Palm V and Palm Vx devices.  I think it's awesome that Linux carries forward its history, but I know that some people periodically whine and wish that someone (not sure who) should go through and delete all our history.  I actually wish openSuSE installed fortune by default, a choice made by the FreeBSD team that I highly approve of.  I like fortune, and install it on all my linux systems:

> sudo zypper install fortune
root's password:

> fortune
One of the chief duties of the mathematician in acting as an advisor...
is to discourage... from expecting too much from mathematics.
                -- N. Wiener

Each time I install Linux on a fresh box, I wish I had thought about a clean way to get my preferred environment settings onto it.  My ~/.vimrc, my ssh keys, all that. If anybody reading has any preferred techniques, I'd love to hear it.  Some people make a "dotfiles" git repo, maybe I should start doing that.  Since I keep private secrets in my dotfiles, I'm not crazy about pushing it all in one git repo.   I don't even feel comfortable keeping all my secrets on a private bitbucket or gitlab repo. What do you folks do?  There has to be something better than my current mess.
Maybe I will go with the .dotfile repo and it will be only for public files, and I'll have a script on there called fetch_secrets that will decrypt and restore my secret-dotfile-bits from a usb key that I carry about with me.  Or maybe there's some better solution.

After setting up dotfiles and basics, I like to get all my development toolage, and a variety of virtual machines.  I use vim, Netbeans, Eclipse, Webstorm (an IntelliJ idea flavor for html5/web), Visual Studio Code,  java jdk and the usual java tooling suspects,  dotnet core, mono,   go, rvm/ruby, gcc, clang, python3, python2, node+npm, and lots more.   I really like Pharo (a modern smalltalk VM) as well, and getting that running on a 64 bit Linux is a bit of a pain as it's a 32 bit only VM right now.

On Using LEAP Daily

I found some problems getting one of the large Ruby/Rails apps I want to work with going on Tumbleweed and have moved to Leap 42.1 as my main OS these days.  About the only thing I notice is that the "Nouveau" open source cleanroom-reverse-engineered X drivers are less advanced in Leap than they are in the bleeding-edge rolling-release Tumbleweed system. I have to use the stable non-open-source proprietary NV (nvidia)  video drivers for X11, but even they have crazy bugs and incompatibilities with my card, a GeForce GTX 750 (rev a2). Last night my X server just crashed on LEAP.  Might be going back to Tumbleweed until I get rid of this heinous heap of video card garbage.

There is something to be said for running a completely open source system, with no magic-blobs of patent encumbered binary sludge on your system.   Next time I buy a video card it will be an AMD one. I'm done with nVidia.   But I'm just getting started with OpenSuSE and loving it.  It's clean, fast, efficient, and has several really great desktops (KDE Plasma and Gnome) and it really is up to you which one you prefer. I find I mostly prefer KDE Plasma.

No comments:

Post a Comment