Tag: linux

  • Container Linux Distributions

    A short list of the perceived active ones in alphabetical order:

    Honorable mentions (not a container distro):

    Personally, I’d start with CoreOS, and exclude Bottlerocket (too AWS, not “for the public” although open source 😉

  • Configure static IP address on Debian systems

    I have now two home servers in two locations, and they should be “identical”. Both have a static IP address, which is surprisingly hard to configure, since there are actually four different ways in doing it:

    • netplan (Ubuntu only it seems)
    • ifup/down
    • NetworkManager
    • systemd-networkd

    I am using the last one, systemd-networkd. This is how it’s done:

    1. uninstall network-manager: apt-get remove network-manager
    2. make sure the only configured interface in /etc/network/interfaces is lo
    3. create /etc/systemd/network/10-static.network (contents below)
    4. enable (do not start!) systemd-resolved: systemctl enable systemd-resolved
    5. enable (do not start!) systemd-networkd: systemctl enable systemd-networkd
    6. convert /etc/resolv.conf to a symlink: ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
    # FILE: /etc/systemd/network/10-static.network
    
    [Match]
    Name=enp*                   # match the name of your hardware eth interface
    
    [Network]
    Address=192.168.10.10/24    # your IP including netmask
    Gateway=192.168.10.1        # your default gateway
    DNS=8.8.8.8                 # your dns server
    Domains=mi.casa             # your domain search paths
    

    If you plan to run a DNS server on the same host, do this:

    1. Use DNS=192.168.10.10 in the file 10-static.network (point to the same host)
    2. Add DNSStubListener=no to the file /etc/systemd/resolved.conf

    … otherwise you’ll run into port troubles, cause both systemd-resolved and your DNS server want to own port 53.

    Now REBOOT.

  • Unattended upgrades in Debian/Ubuntu

    If you want to automatically install package upgrades on a Debian/Ubuntu server system – there’s an app for that. First, install the package:

    apt-get install unattended-upgrades apt-listchanges
    

    Then configure the package by editing (Ubuntu) /etc/apt/apt.conf.d/50unattended-upgrades:

    // /etc/apt/apt.conf.d/50unattended-upgrades without comments
    // my version
    Unattended-Upgrade::Allowed-Origins {
            "${distro_id}:${distro_codename}";
        "${distro_id}:${distro_codename}-security";
        "${distro_id}ESMApps:${distro_codename}-apps-security";
        "${distro_id}ESM:${distro_codename}-infra-security";
        "${distro_id}:${distro_codename}-updates";
    };
    Unattended-Upgrade::Package-Blacklist {
    };
    Unattended-Upgrade::DevRelease "false";
    Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
    Unattended-Upgrade::Remove-Unused-Dependencies "true";
    Unattended-Upgrade::Automatic-Reboot "true";
    Unattended-Upgrade::Automatic-Reboot-Time "02:00";
    

    Apparently in Debian there are a couple more ways to achieve the same goal, this one works pretty well for me.

  • Add swap space in Ubuntu

    My DigitalOcean Droplet started dropping containers while kswapd ate up CPU cycles like Pacman. Time to add a swap space, or rather a swap file cause I did not want to add a dedicated volume.

    # swap usage check - swapon: no output, no use; free: should read "0"
    sudo swapon --show
    free -h
    
    # as root: create swap (make sure you have enough disk space available)
    fallocate -l 4G /swapfile
    chmod 600 /swapfile
    mkswap /swapfile
    swapon /swapfile
    echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
    
    # reboot and check (see first two commands) if swap is available
    reboot
    

    Optinonally you can also tune swappiness and cache pressure settings. Both is described in this article’s source (DigitalOcean).

  • Ubuntu update procedure

    Brain dump.

    # from here: https://askubuntu.com/a/862799/870970
    apt-get update && apt-get --with-new-pkgs upgrade
    
    # restart
    reboot
    
    # do it again
    apt-get update && apt-get --with-new-pkgs upgrade
    
    # remove shit
    apt autoremove
    
    
    #
    # UPGRADE
    #
    
    do-release-upgrade
    
    
    # done.
    
  • Win10 & Veracrypt & systemd-boot

    There are some things seemingly nobody does. For example, …

    • double-booting Win10 and Linux
    • on an UEFI System
    • while the Win10 Partition is encrypted using VeraCrypt.

    Yes, it’s a complex scenario, but since MS in all of his (money-grabbing) wisdom does not include BitLocker in Win10 Home, this is a necessary precaution. I’ll not go over the installation of both systems (pretty straightforward, and Arch Linux has – as always – a nice Wiki entry about it).

    Unfortunately, Win10 likes to break its own boot manager on updates, which is very scary (“Your Windows partition is damaged”), and super annoying, but I think I got the solution now.

    So, the Linux-based (of course) solution for Windows 10 and VeraCrypt is:

    # esp partition - /loader/entries/winvera.conf
    title Windows 10 VeraCrypt
    efi /EFI/VeraCrypt/DcsBoot.efi
    

    This is in fact all you need to do. Now, if Windows fucks up its own boot loader, it seems systemd-boot just ignores everything, loads the correct VeraCrypt bootloader (as it is supposed to be), and all is well.

    It can happen though that Windows places its own boot manager back in front of systemd-boot again, so it’s used as the default one. Then use one of the methods described here, and you should be fine. (This did not happen to me, it always used the correct boot manager but fucked up Windows boot)

  • Arch followup actions

    Updates:

    • 2022-06-23 | add networking, update packages, add GDM

    Overview

    Once you’ve installed Arch Linux, a couple of things are … nice. But very basic. Let’s get out of basic 😉 .

    Set up networking

    Just do the same as described in the installation post.

    Then, we set up IWD as backend for NetworkManger (NOTE: experimental!).

    ### FILE: /etc/NetworkManager/conf.d/wifi_backend.conf ###
    [device]
    wifi.backend=iwd
    

    Create user

    If you didn’t do it yet, create your user.

    useradd -m -G wheel USERNAME
    passwd USERNAME
    

    You should have sudo installed, so do this:

    # if you are really lazy and insecure
    echo "%wheel ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers.d/wheel
    
    # use this.
    echo "%wheel ALL=(ALL:ALL) ALL" >> /etc/sudoers.d/wheel
    

    Now log in as this user and check if you can become root by typing sudo -i.

    CLI packages

    Some CLI “apps”:

    pacman -S ack dnsmasq git ripgrep vim zsh git base-devel man-db man-pages
    

    Install yay (AUR helper)

    Remember: Do this as your “normal” user!

    mkdir /tmp/yay
    cd /tmp/yay
    
    # from here stolen from yay's github page:
    # https://github.com/Jguer/yay#source
    git clone https://aur.archlinux.org/yay-bin.git
    cd yay-bin
    makepkg -si
    

    Install UI

    And here it goes for UI and UI-related things:

    pacman -S gnome gnome-extra gnome-control-center \
              cups network-manager-applet \
              firefox
    

    Now some AUR packages:

    yay -S vscodium-bin
    

    Configurations

    For network manager, I prefer dnsmasq as the tool of choice, especially when using VPN connections:

    ### FILE: /etc/NetworkManager/conf.d/dns.conf ###
    [Main]
    dns=dnsmasq
    

    Enable services

    # enable
    systemctl enable iwd
    systemctl enable NetworkManager
    systemctl enable org.cups.cupsd
    
    # start
    systemctl start iwd
    systemctl start NetworkManager
    systemctl start org.cups.cupsd
    
    # to boot into GNOME
    systemctl enable gdm
    

    Some troubleshooting tricks

    Gnome-terminal does not start

    Set the locale, using “gnome control center”, and then re-login. (Source)

  • Arch linux + yubikeys

    To use “ykman” for arch linux, you do this:

    $ yaourt -S yubikey-manager pcsclite                 # THESE PACKAGES
    [...]
    $ systemctl start pcscd                              # START SERVICE
    $ ykman info                                         # TEST
    Device type: YubiKey NEO
    Serial number: 0123456
    Firmware version: 3.4.3
    Enabled connection(s): OTP+U2F+CCID
    
    Device capabilities:
        OTP:    Enabled
        U2F:    Enabled
        CCID:   Enabled
        OPGP:   Enabled
        PIV:    Enabled
        OATH:   Enabled
    $ _
    

    Sounds easy? Still had to google the things.

  • Ugly ligatures in Linux

    Unfortunately boohomil went off grid. I still haven’t replicated his config fully. And it still sucks.

    One more step was fixing those super-ugly ligatures in Linux. Works at least in LibreOffice (just restart the app to see changes).

  • crontab and nano

    Ever used update-alternatives to switch everything to vim and … crontab -e still used nano?

    Well, I had this. I found the answer:

    select-editor