# CentOS 7 workstation

CentOS used to be an acceptable stable distribution, especially before the 2020 changes by RedHat, which was itself acquired by IBM, and then moved EOL for CentOS 8 backwards, from 2029 to 2021. I used OpenSUSE before, and Debian after (see Debian 11 workstation), but the time on CentOS was fine, and here are my notes on its usage.

## Preparation

1. Prepare some space in the beginning of one of disks, or prepare to reconfigure the existing loader.
2. Export OpenPGP keys.
3. Save playlist in some easily editable format (e.g., xspf; though xspf will lose .cue information, but I have not found a way to preserve it; it is best to not rely on it, and to split the tracks).

## Initial installation

1. Download CentOS: I downloaded the "LiveGNOME" version, to poke it before installation, and to leave it as a rescue USB stick afterwards.
2. `dd if=CentOS-7-x86_64-LiveGNOME-1503.iso of=/dev/sde`, where `sde` is an USB stick.
3. Reboot, boot from the stick.
4. Poke it, install.
5. Reboot, boot from the target disk (or set it in an old loader).

There is a nice graphical tool for partitioning during installation, where Btrfs and encryption are supported. The installer itself is nice and easy to use.

### Bootloader/ESP

When multiple systems are installed on a machine, it is nice to have them on separate disks and with separate bootloaders, so that they can be used independently, and a single disk failure will not affect more than one system. Unfortunately system installers seem to choose an EFI system partition (and MBR in the past) at random (well, following some undocumented rules that look like random and pretty hard to deduce from installer sources), so care should be taken to ensure that a correct one is used, which may involve fixing it after installation, or going for a more involved/manual installation at once (sometimes it's easier to set things cleanly, rather than to cleanup the automatic mess afterwards). `efibootmgr`, `grub-install`, and `update-grub` are helpful here (it's useful to ensure that the correct EFI system partition is mounted in `/boot/efi/` before running `grub-install`), but one may also have to cleanup directories on a EFI partition manually if excessive ones were created.

## Fixing

### Sound

The first problem I've noticed was sound: apparently it was because of a glitchy jack detection, and solved by changing HD to AC97 in UEFI settings.

Apparently sometimes Firefox mutes Clementine somehow (likely via pulseaudio). The only way I've found to fix it is to restart Firefox. If it becomes very silent, the problem may be in pulseaudio per-application sound settings.

Pulseaudio is used in the default installation, so some things should be fixed there – like disabling flat volumes in `/etc/pulse/daemon.conf`. Though sometimes changing the volume still doesn't take effect at once; sometimes it's needed to wait a bit, and/or to change it a few times.

To suppress static noise from a microphone, the following should be added in the end of `/etc/pulse/default.pa`:

    set-default-source echoCancel_source
    set-default-sink echoCancel_sink
    load-module module-echo-cancel use_master_format=1 aec_method=webrtc aec_args="noise_suppression=1" source_name=echoCancel_source sink_name=echoCancel_sink
    set-default-source echoCancel_source
    set-default-sink echoCancel_sink

### Video

> Don't Buy From ATI - enemy of your freedom – RMS

> Nvidia, Fuck You! – Linus Torvalds

I have GeForce GTX 660 here, so it's about Nvidia. Initially I was going to try nouveau (it is installed by default), but then I had to reset the computer a few times, because of strange and visual glitches; turned out that they were caused by nouveau. Installing the proprietary Nvidia driver helped.

Warning: once the kernel is updated, it is required to rebuild the driver as well; otherwise there will be the "oh no!" message after boot (update: apparently they happen randomly, even with a rebuilt driver), with related errors in the Xorg log. I'm finding it more handy to boot without X all the time, and rebuild the driver when required (an updated kernel should be used on driver update); here's how to boot without X.

Though h-node.org lists it as working with free software, so either I tried it with software versions where it is buggy, or it's not well-tested on h-node.org.

The drivers should be recent in order to be compatible with kernels, and it's tricky to get them without X and a graphical web browser with JS – so better to download the latest ones before each update.

### GNOME

While there are many nice projects that are parts of GNOME, the resulting GNOME DE is a bloated monster that lags, and freezes, and crashes, and apparently becomes worse over time even in a stable distribution. But its compositor works relatively well. Though occasional white flashes and screen tearing of other compositors may be preferable to all the GNOME bugs.

As a non-technical note, in 2019 the Executive Director of the GNOME Foundation contributed to the pressure for RMS to resign from FSF, during some sort of a witch hunt (along with SFC and a bunch of other organizations; see also: Hacker News thread: Richard M. Stallman resigns, In Defense of Richard Stallman + corresponding HN thread, Joint statement on the GNU Project). As well as RedHat (which was later acquired by IBM) controlling GNOME, introducing a systemd dependency, pushing plenty of other awkward/"enterprise" software into the Lignux infrastructure; along with all the technical issues, it may be a good reason to avoid this. Apparently later Drew DeVault joined in, with some deception.

#### Start menu

GNOME's "app menu" dies from time to time. It is a known bug (1, 2), but apparently it's not going to be fixed soon (it's there for 4 months at the time of writing).

Updating line 77 in `/usr/share/gnome-shell/extensions/apps-menu@gnome-shell-extensions.gcampax.github.com/extension.js` by replacing `event.get_time()` with `-1`, followed by Alt+F2 and "restart" to restart gnome shell and reload that extension. Though probably it's not a good idea to use a DE that relies on buggy JS at all.

#### Keyboard layouts (update, June 2016)

After the recent update, GNOME is quite unfriendly to alternative keyboard layouts: you either enjoy things like left arrow key, but give up on keyboard shortcuts in some programs (not sure why they work in some and don't in others), or set the layout with xmodmap and back to qwerty in GNOME.

#### Tracker

Tracker is a weird thing that loads CPU and disk I/O, and is supposed to track files. tracker-preferences is supposed to help to disable it. Alas, it gets killed with no error message when trying to remove indexes with it, but it can change some settings, at least, and mostly disable that thing – though a bunch of processes would still hang. `tracker-control -r` helps to kill its currently running processes, and to cleanup the indexes (probably that's how tracker-preferences kills itself).

Apparently it runs via `/etc/xdg/autostart/` (along with a bunch of other useless things), so it should be disabled using that autostart functionality.

#### GVfs

Nautilus is somewhat convenient in combination with GVfs if you don't bother to fill `/etc/fstab` manually and to mount USB sticks with `mount(1)`, but apparently gvfs makes it to lag (or at least did in 2014; actually that solution didn't seem to work on CentOS later). I don't know how to solve that, apart from just using `fstab` instead of it.

#### Sound control

For a while I thought that it's one of the few things that work properly and nicely, but it's not. The fancy control that allows to change sound level with a mouse wheel would just jump sometimes if you are trying to control it with a wheel (and makes sounds when you click), making the sound very loud (or quiet, but that's not that bad – unexpected loud sound is far worse). I guess the hardware equivalent of that would be giving random electric shocks to users. Or just catching fire.

A workaround is to use `alsamixer` instead. A mechanical knob on speakers is another working alternative.

I also suspect that GNOME freezing (unresponsiveness to input) is related to sound control (or just to interaction with gnome-specefic parts) while there's a relatively high CPU load.

#### Broken input

Sometimes it ceases to pass input events to programs. I'm not aware of a solution apart from reboot; attempts to restart gnome-shell only seemed to make things worse.

#### Animations

Animations are more annoying and laggy than useful; they can be disabled with the gnome tweak tool.

#### Mouse gestures

They are very annoying, but I haven't found a way to disable them yet.

#### SSH agent

GNOME replaces `ssh-agent` with its `gnome-keyring-daemon` that doesn't support ECDSA. Apparently it can be disabled by adding `X-GNOME-Autostart-enabled=false` into `/etc/xdg/autostart/gnome-keyring-ssh.desktop`, though merely "replacing" gnome-keyring after that doesn't have much effect: it should be killed, and `ssh-agent` should be restarted after that. Though then there's an issue with running `ssh-agent` properly, and environment variables should still be set. Those are fixable in various hacky ways on CentOS, though probably it's not worth adding hacks that will likely break on the next update.

GnuPG connections get hijacked and partially broken by it too, see GnomeKeyring on GnuPG wiki.

#### Background and other colours

If background is not always covered with windows, it's quite unpleasant and distracting to work at night with some bright image or colour on background, while GNOME GUI only provides bright colours to choose from. `gsettings set org.gnome.desktop.background primary-color "#000"` fixes that, though maybe it's possible to find non-distracting wallpapers as well (or just draw those).

There's also messy CSS (both in formatting and in structure) in `/usr/share/gnome-shell/theme/gnome-classic.css`, which can be tweaked. Though one should be careful, since a typo in CSS easily bricks gnome-shell and kills running applications on an attempt to restart it.

#### Window management

Apparently since gnome-shell 3.28.3 window resizing is also partially broken.

### DNS

Network worked fine out of the box here (as it usually does with Ethernet), but my default (ISP's) DNS are rather slow. `/etc/resolv.conf` is managed/rewritten by NetworkManager here by default, so alternative name servers can be set via GUI: in "Network Settings", with "automatic" turned off.

A somewhat better approach, which I've started using later, is to set `bind` locally (`yum install bind` and `systemctl enable named` to enable it): by default it's caching (hence name resolution is often faster) and uses root name servers. It's handy to control the DNS server you are using, particularly for development.

`OPTIONS="-4"` is useful to add into `/etc/sysconfig/named` if there's no working IPv6 available – otherwise it'd fail often and would fill the logs with error messages (which is an instance of IPv6 brokenness).

### Pre-login-prompt errors

Right before a login screen, one may observe a pyudev error akin to RHEL #1263363. The issue of which it is a duplicate is hidden. It doesn't seem to be critical (if you don't care about the looks of it), and doesn't appear in logs: only shows up before a login prompt.

## Strategy

I considered to group software into the base system, things I use as tools or dependencies, and things I'm interested in (the ones I build from source repositories, following changelogs and such), and then install those from different sources ("base" and "epel" CentOS repositories, language-specific ones, Nix/Guix, building manually), hoping to get a stable system, but newer versions of some programs, to which I'm paying more attention.

That didn't quite work, since occasional newer software version requires newer dependencies, while CentOS lags even behind Debian stable. Then I didn't get along with Nix on top of another system, and there are things like this:

    > @cpan
    <centbot> Using CPAN on CentOS is a wonderful way to wreck your
    system. CPAN does not play nicely with the packaging system. Please
    use EPEL or other trusted repos to install packaged PERL
    modules. Please see
    http://wiki.centos.org/AdditionalResources/Repositories for more
    information on 3rd-party repos.

So, after a few years it wasn't a particularly neat system, even though I'm trying to avoid software that can't be installed nicely.

## Initial software and configuration

### NTFS

`ntfs-3g` provides NTFS support, just installing it from the repositories.

### Emacs

In order to complain in IRC during the installation, one of my first goals was to install Emacs. It's one of those programs which I'm building manually; most of the dependencies (except for a gif library) are available from standard repos, so it's relatively easy.

Not going to describe Emacs packages installation and configuration here, but nothing in the system appears to interfere.

### Various other things

Git, bitlbee, and other common programs are in repositories, too (update: the git version is old, 1.8, while magit only works with 2+ nowadays – so that should be installed manually). In epel, if not in base.

I've used `ktorrent` before, but tried `transmission` this time. It's fine, though doesn't provide much of information on what's going on (apparently a trend around GNOME and GTK, to hide details from a user, which is quite annoying when you are interested in those).

It seems that not many music players support/handle .cue, but Clementine does. Clementine comes from the nux-dextop repository, and something goes wrong in dependencies (yum complains on `update`) if it's installed together with amarok (or maybe the problem is just in amarok + nux; anyway, it helps to remove amarok together with its dependencies: `clean_requirements_on_remove=1` in `/etc/yum.conf`).

If static pages appear to move a little in Firefox, it might help to turn smooth scrolling off. If parts of pages blink after loading, and/or scroll jumps sometimes – there is a solution, too. Then FF just lags a bit, instead of that flickering; also, smooth scrolling can be enabled again with it.

Firefox color overriding is semi-broken for years, so if one uses it, they should override background for inputs and similar things in `$HOME/.mozilla/firefox/YOUR_PROFILE/chrome/userContent.css` (with `!important`). Though user CSS (possibly with the Stylus extension) seems to work better.

### Media

How to setup multimedia on CentOS 7.

## Xmonad, almost

One of the new things I was going to try is Xmonad: poked it a bit before, tiling WMs are nice, and it could be configured and extended in Haskell, which is neat.

So, another thing I gave up on – to build Xmonad in a sandbox, in a way that would allow to `--recompile` it. It should be possible, but, again, depends on familiarity + patience + motivation, none of which I had enough, and ended up installing it without a sandbox; probably will regret later.

### GNOME 3

I have not used GNOME much before, just switched to it this time, after KDE's leaking `kded4` and crashing `plasma-desktop`. It was possible to integrate Xmonad into GNOME before, reusing GNOME panels, but replacing its WM, but apparently isn't now. It also might be tricky to provide a "session" choice for xmonad, but here is a working solution I've found by trying different ones (the "alternatively" part). So, here's my `/usr/share/xsessions/xmonad.desktop`:

    [Desktop Entry]
    Encoding=UTF-8
    Name=xmonad
    Comment=This session starts xmonad
    Exec=/home/defanor/.cabal/bin/xmonad
    Type=Application

### Related software

Installed xterm, dmenu, xorg-x11-apps from system repositories. Probably will install xmodbar after.

#### Xterm customization

Here's a nice theme. To set nicer fonts, add:

    XTerm*faceName: DejaVu Sans Mono
    XTerm*faceSize: 11

Update: I've put some things, including an xterm theme, into a dotfiles repository.

### Postponing

A few weeks later, I had too many things open to kill the session, and switching to xmonad and back leads to glitches, so it's for some other time.

### Update: i3

Using i3 on my netbook now, perhaps will use it on desktop someday. It's nice, and a working/usable WM is better than a nicely configurable but not used one. Though the text colors are poor there (apparently hardcoded RGB value for red, on black background in its bottom panel, i3-bar).

### Update (December 2017): other WMs and xmonad again

2.5 years later, I still have the same system on this machine, but grew too annoyed by GNOME misbehaving. i3 still has the issue with colors and with default key bindings conflicting with Emacs, ratpoison in nicer wrt keys, and colors are configurable there, but it leaves some space below emacs and xterm windows (probably those get fitted by the number of columns), what probably can be configured, but I decided to try xmonad once again. It's quite awkward to configure a poorly configured WM while using it, by the way.

Installed `xmonad` with `cabal insall` (into `.cabal/bin`), along with `xmonad-contrib` and `xmobar` from Hackage. I had an xsession file left from before (see above), as well as dmenu and some other utilities. As the other WMs, it's ugly and violates accessibility guidelines by default, and as most of the others, it shadows default Emacs key bindings. Fortunately, it is configurable/hackable, so both those can be fixed. Even fancier things like changing workspaces with mouse scroll on xmobar are not hard to get, and the #xmonad channel on Freenode/Libera.chat is helpful. I've pushed my xmonad and xmobar configurations for that into my dotfiles repository.

But as mentioned in comments in the xmonad.hs file there, I haven't found a way to make `compton` work nicely, or to otherwise avoid screen tearing and white flashes. I quite like xmonad, but for now switched back to GNOME, and reading about some X11 stuff/ICCCM (#xmonad was helpful with pointers to it, too). Well, it's not about xmonad in particular, but rather about compositors, and probably that goes deeper, into video drivers (since supposedly on some machines compton works properly; though somehow GNOME handles it fine here, so should be possible to solve in a compositor).

Could try to check how GNOME deals with it, and perhaps learn more about X11 (I have very little experience with it; always avoided because it seemed huge, old, and boring) to debug it, but I spent almost a whole weekend on it already, and quite tired now. Someday later, perhaps; will have to continue using GNOME for now.

A week later, tried it again, with "full composition pipeline" enabled in nvidia settings: it has helped with screen tearing in FF (even without compton), but only with that, and then a new issue popped up instead: some kind of a phantom mouse cursor.

So, I guess I'll stay on GNOME a bit longer – until I'll feel like digging deeper, or will get a new video card, or perhaps something like Wayland will be used in CentOS (or I'll just try to switch to it manually, though given that there are all these issues even with mainstream software, I don't expect it to be particularly smooth). GNOME is pretty bloated and buggy in many other aspects, but somehow manages to draw things on a screen without visual glitches. Wayland actually seems promising and nice, but xmonad is very attached to X and not going to support it – though there's a few other WMs.

## TeX Live

Manual installation is straightforward. An older version (2012, the current is 2014) is present in the repositories, but it's old and could lack some packages.

I'm using the `minted` package, which requires Pygments, and there's an old Pygments version in repositories. But I'm using Python for work anyway (update: yay, not using it anymore), so installed it manually, and then `pip3 install Pygments`.

Don't forget to cleanup old cache, if it is present, and then everything works.

### Ghostscript

Somewhat related: for a while ghostscript (used in particular by auctex's preview-latex) worked fine, but then ceased to after another update. So, I've built it manually, too; it still reports version 9.07 (and I can't remove that one because too many things depend on it), but works, and preview-latex in emacs does too.

## Further updates

It is important to check CentOS release notes for known issues on each minor version bump: they are listed with solutions/workarounds, what lowers the chance of wrecking a system during an update.

### 7.4 to 7.5 update

After the update, I've failed to get into a graphical environment with `init 5`, and found the following in `journalctl -p 4`:

    Jul 19 21:53:41 dws initial-setup[879]: kickstart parsing failed: The following problem occurred on line 37 of the kickstart file:

    btrfs subvol requires specification of parent volume
    Jul 19 21:53:41 dws initial-setup[879]: Initial Setup startup failed due to invalid kickstart file
    Jul 19 21:53:41 dws initial-setup[1341]: Initial Setup failed, keeping enabled
    Jul 19 21:53:41 dws systemd[1]: Failed to start Initial Setup configuration program.
    Jul 19 21:53:41 dws systemd[1]: initial-setup.service failed.

`initial-setup` and `kickstart` are anaconda-related things, the kickstart file is `/root/anaconda-ks.cfg`. Apparently there's not much of textual documentation (man pages and such), making it easy to get stuck for a couple of hours in 80*25 mode. The line it complained about had `btrfs / --subvol --name=root` on it, and just commenting it out helped to get through that.

#### Firefox 60

FF 60 abandons XUL, and the new extensions have to use UI that is affected by color overriding with all its bugs (which don't get fixed) and limitations. There doesn't seem to be, for instance, a usable tab tree extension now: the choice is between awkward borders + invisible favicons, and illegible (nearly invisible) titles.

uBlock Origin UI was affected as well, and sometimes it gets just unusable: there's only the "default" policy choice that is visible/available. One option is to finally abandon built-in color overriding and use a global CSS theme, such as Stylus with Midnight Surfing, or ShadowFox. There are extensions such as Dark Reader (somewhat similar to what I've tried in the UI colours note, so I like the approach), though that one seems to kill contrasts too often, even with the highest contrast setting.

Another prominent FF change is that occasionally it ceases to render pages now. On my system only restarting it helped, but heard that for others it was sufficient to reload a page. Though in some cases reloading a page helps. Other times it doesn't, but it helps to open a page in a new tab, and then it gets rendered.

## System freezing

In addition to more apparent GNOME failures/hangups, something else freezes the system occasionally (to the point where "power" button doesn't work and I have to "reset" it), possibly at the same time of day (about 06:31 local time, 03:31 UTC), and I suspect it has something to do with updates (the last logs I see are DNS queries to repository hosts). Maybe it's still GNOME when yum asks it to show notifications, or maybe it has something to do with PackageKit, or yum itself.