2019. november 21.

Recent linux on 20+ years old unix machine 2.

What is BTRFS? Why BTRFS? What do I love about BTRFS?

Well, it a file system, much like any other one. You can format a disk partition with it, and put files, read files, etc... It is quite new also, compared to f.e. ext2, or FAT32. The gotcha is: it knows much more, than just keeping files on disk. Elsewhere you can read a lot about it, but in a nutshell:
- You can create snapshots of your filesystem
- You can make software raid easily, on the the fly
- You can ship snapshots, and even differential snapshot from one machine to another

I especially love the snapshot, and snapshot shipping feature of it. If you think about it: it makes life much easier in several ways. During making a system wide backup, moving to an other machine, using to chroot into it, update it, restoring it in case something goes wrong... etc.

I found it particularly useful BTRFS in the Qemu scenario, since I was able to copy the ready system to the actual hardware, and also send changes back under Qemu, to do more install work on it (which means compiling).

Apart from being an awesome distro, Gentoo has a nice feature: you can actually build binary packages (yourself). This makes installation much faster on slower machines. For that, I used NFS to share ready built packages from Qemu host system to the PWS, and also distfiles, and the whole portage.

First gotcha: sharing the binary packages over a read-write manner (f.e. over nfs) is a must, since as we will see, there are packages, which can only be built on the real hardware itself. However, they are dependencies for other packages, so even the build machine needs binary packages from time to time, to be able to proceed with other builds.

What I also like about Gentoo, is it's great documentation. I used mainly this article to set up user mode qemu system. A very quick overview on what you can achieve with it: make your system recognize Alpha CPU targeted binary files, and use user mode qemu to translate it to x86 instructions in real time. And you do it, in a chroot environment, which is practically the way, how you install Gentoo to a new system. Nice, and sound! :) So I chrooted into an Alpha stage3 filesystem, carefully created on a BTRFS subvolume (to make it easily portable later on), and... almost nothing worked. Actually bash worked, so at least I had a command line, running on virtual Alpha CPU.

Second gotcha: on all sites, the bin format misc magic header's mask is incorrect. You have to modify to this one:

# echo ':alpha:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x02\x00\x26\x90:\xff\xff\xff\xff\xff\xfe
\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:
/bin/qemu-alpha:' > /proc/sys/fs/binfmt_misc/register

Do you see the red bold part, it is originally FF everywhere I saw. Without it, more modern linux elfs are not working, only SYSV compatible ones. An other hard to find hint: if you
if you echo /proc/sys/fs/binfmt_misc/status, 1= enable, 0=disable, -1=clear

The last one is not very much documented anywhere, however if you need to give a new path, you can now clear the binfmt_misc registrations to make it happen.

Third gotcha: Gentoo uses python a lot, since it's packaging system is written in it. It also has at least two different version of it on every system as of now: v2.7 & 3.6. The v3.6 throws exceptions all around, so building is not working. However if you eselect python set , it works like charm, and you are good to go, and emerge (install/compile) some packages. Well, at least almost, 'cause you will soon find out, still nothing works.

Fourth gotcha: emerge is getting more and more secure. It drops privileges while compiles, creates sandbox, network sandbox, stc around the compiling and installing process. However, there is still some missing functions in qemu (v4.1) kernel bridge, which prevents to use such things, so you have to add to your /etc/portage/make.conf some FEATURE definitions:
FEATURES="-sandbox -pid-sandbox -network-sandbox -ipc-sandbox"
Actually this disables some feature. Removing those features, starts to work! And you can build binary packages, to make it later available for your native hardware.

Fifth gotcha: if you compile in the chroot big packages, like gcc, kernel, etc, you should set in the shell before chrooting into it:
# ulimit -n 15000
Not to get such errors, like "too many open files"... when only just a little would have needed to complet the many hours package compile.

Sixth gotcha: anything, that is dependent on cmake, or cmake itself, fails to compile with Illegal Instruction. There must be some bug in qemu. Actually I found some other programs causing unexpected errors, like subversion client, which segmentation faults, but unlike cmake, it is not required to build packages. To still make building happen: you have to build cmake dependent packages on your native machine. Fortunately, with the help of equery command it is quite easy to collect those packages which are directly dependent on cmake. I even wrote a script, which creates a @cmake set for me, to be able to issue such command on the native machine:
# emerge --update --newuse --oneshot --buildpkgonly @cmake
Which builds/updates only the cmake dependent packages, doesn't install those yet (since could cause conflicts), but creates a binary package out of those. On the qemu system, when I update @world, those will be install from binary, et vois la! emerge dependecy graph is satisfied. Later, when all builds are ready, the native system just need to install binary packages. Actually, this is why nfs is a good idea to store/share binary packages between host (I use kerberized NFS4 with integrity check).


2019. november 16.

Recent linux on 20+ years old unix machine 1.

I have made an excursion to the Unix realms recently, with the help of a Compaq PeronalWorkstation (PWS) 500au. It was a dream machine back in '96 when it hit the market, with 500MHz EV56 Alpha CPU, 512 MByte of RAM, built-in SCSI, USB, sound card, and IDE. My machine also contains an old school, high-end graphical card: Intergraph Intense 3D.

Tru64 runs like charm on it, and uses the display card well. Windows 2000 also has a driver for it (I haven't tried it out yet). But I wanted to give a shot with a modern desktop OS as well, and here came Linux to save me.

I thought there are many recent distros supporting alpha architecture, but it turned out my only practical choice can Gentoo be, all others have long ago dropped their support. So Gentoo let it be! What you need to know about Gentoo, is practically you have to install everything from sources, which means compiling. A lot of compiling... and even more!

You also need to know, that this old machine, with it's single 500MHz CPU takes it's time when it comes to compiling such big things, like Linux kernel... more than 18 hours! That much. So, compiling X, and all of it's dependencies, and a media player, and configuring everything, was out of reach practically.

I also wanted to keep the nice, big, expensive graphic card in there, to use Tru64, and later even Windows 2000. However, since it was a high-end (and very expensive) card back at it's days, it unfortunately lacks any linux support and drivers. But this in itself a complete story of it's own right.

What I choose to do, is set up Qemu user land emulation of Alpha (AXP) CPU on mu laptop (x86-64, 4 cores, 16GByte RAM), put this stage3 Alpha tarball into my other Gentoo disk, chroot into it, install and configured everything I wanted to have a starting system on the PWS, then copied the image to it, and boot up. It's quite simple to say, but I had some headache during the process, bumping into barriers here and there.

In the end, I ended up with a recent Linux, with a recent kernel (Linux snow 4.19.66-gentoo-snow-09 #8 Sat Nov 16 09:35:25 CET 2019 alpha EV56 Miata GNU/Linux), with Xorg running in 1024x768 with LXDE, with all working peripheries: sound, display, IDE, SCSI, Lan, and more...

In the next chapters, I will describe the gotchas till I got here.