středa 29. dubna 2026

vynuceni opravy detekce monitoru na NVIDIA karte

 

for i in `pgrep -u $USER gnome-shell`  ; do echo $i: ; cat /proc/$i/environ | tr '\0' '\n' | grep -E 'DISPLAY|XAUTHORITY' ; done

pripadne:

ps -C gnome-shell -o pid=


#
# asi pri vypnutem monitoru:
#
export DISPLAY=:1
export XAUTHORITY=/run/user/$(id -u $USER)/gdm/Xauthority
xrandr --query
xrandr --output DP-0 --off
sleep 2
xrandr --output DP-0 --auto

čtvrtek 5. února 2026

hybrid SDD/HDD raid 1

 Viz https://www.tansi.org/hybrid/

The key is the option "write-mostly" passed to hdd.

 

mdadm --metadata=0.90 --create -n 2 -l 1 /dev/md1 /dev/ssd -W /dev/hdd

For an existing array, add a new ssd (after ssd failure)

mdadm --manage /dev/md0 --add /dev/sda1

--write-mostly is a per-member setting stored in the md metadata for that member device (and also maintained in-kernel while the device is in the array). It should survive on the hdd.

quote: You can enable "write-mostly" for a RAID component in the following way:

echo writemostly >  /sys/block/md0/md/dev-hdd/state

and disable it this way:

echo -writemostly >  /sys/block/md0/md/dev-hdd/state

(nicmene, po pridani noveho ssd disku se ve vypisu vlastnosti /dev/hdd write mostly ukazovalo. Teprve az po echo writemostly > ...)

sobota 29. listopadu 2025

Ubuntu 24.04 postfix + SASL/saslauthd Fix

(napsal GeminAI podle strucnych poznamek)

Quick Fix: saslauthd Failures in Ubuntu 24.04 LTS

Upgraded to Ubuntu 24.04 LTS and saslauthd won't start, preventing Postfix authentication? The daemon is failing because it cannot reliably create its PID file in the default location while also being configured to place the socket inside Postfix's chroot (/var/spool/postfix/...).

The solution is to use a systemd override to force saslauthd to place its PID file in the same, accessible directory as its socket, and ensure it runs with the necessary group permissions.

🛠️ The Systemd Fix

  1. Open the Override Editor:

    sudo systemctl edit saslauthd.service
    
  2. Add the Configuration Stanza:

    Paste this into the editor to specify the correct PID location and the required sasl group:

    [Service]
    Group=sasl
    PIDFile=/var/spool/postfix/var/run/saslauthd/saslauthd.pid
    
  3. Restart Services:

    Save the file, then restart to apply the fix:

    sudo systemctl restart saslauthd
    sudo systemctl restart postfix
    

This simple configuration adjustment resolves the conflict, allowing saslauthd to start successfully and communicate with Postfix inside its chroot.

čtvrtek 27. listopadu 2025

Fixing OpenDKIM Signing After Upgrading Ubuntu 18.04 LTS → 24.04 LTS

 (prispevek zformuloval GPT chatbot na zaklade mych velmi strucnych poznamek)

After a long-planned upgrade from Ubuntu 18 LTS straight to Ubuntu 24 LTS, I discovered that outgoing e-mail was no longer being signed with OpenDKIM. What followed was a small adventure involving masked services, silent failures, and a missing package. Here is the full story for anyone who runs into the same issue.

1. First symptoms: DKIM signing stopped working

Right after the upgrade, outgoing mail lost its DKIM signatures.
A look into /var/log/mail.log showed a clear clue:

postfix/smtpd[153304]: warning: connect to Milter service inet:localhost:8892: Connection refused

Port 8892, where OpenDKIM normally listens, was not responding:

# ss -tuln | grep 8892 (no output)

So the DKIM milter was simply not running.

2. Trying to start OpenDKIM — and finding it masked

My next step was obvious: check the service.

# systemctl start opendkim Failed to start opendkim.service: Unit opendkim.service is masked.

Status confirmed it:

# systemctl status opendkim opendkim.service Loaded: masked (Reason: Unit opendkim.service is masked.) Active: inactive (dead)

Why the upgrade masked the service is unclear, but unmasking is straightforward:

# systemctl unmask opendkim # systemctl start opendkim

This time the service started—at least according to systemd.
But DKIM signatures were still missing.

3. Adding debug logging

To see what was going on, I enabled more verbose logging by adding to /etc/opendkim.conf:

SyslogSuccess yes LogWhy yes

After that:

# systemctl restart opendkim

The service looked healthy, no visible errors... but still no signs of DKIM signing.

4. The surprising discovery: OpenDKIM wasn’t installed (!?)

Running locate gave the final hint:

# locate opendkim opendkim:

It essentially returned nothing.
At this point it became clear: the service files were present, but the actual OpenDKIM binary was not installed (a side effect of the distribution jump).

A quick explicit install solved everything:

# apt install opendkim

And — voilà — DKIM signing immediately started working again.

5. Conclusion

Upgrading directly from Ubuntu 18 → 24 can leave some services in a strange state. In my case:

  • opendkim.service was masked after the upgrade

  • The service files survived, but the binary package was missing

  • Postfix failed to talk to the milter (Connection refused)

  • Installing OpenDKIM manually restored full functionality

úterý 29. července 2025

multi-hop gateway in wireguard (hub and spoke)

https://www.procustodibus.com/blog/2022/06/multi-hop-wireguard/#internet-gateway-as-a-spoke 

routovani default routy skrz wireguard mezi peerama:

on the client, 172.20.24.15 set 

wg0.conf
[Interface] ... Address = 172.20.24.15/32
[Peer] ... AllowedIPs = 0.0.0.0/0 

ip route add wg_server_ip via 192.168.122.1 dev eth0
ip route add default via 172.20.24.10 dev wg0 

 

on the gateway, 172.20.24.10 

iptables -t nat -A POSTROUTING -s 172.20.24.0/24 -o vlan2 -j MASQUERADE
(a mozna i neco z toho:
iptables -t nat -A POSTROUTING -o oet1 -j MASQUERADE
iptables -A FORWARD -i oet1 ...? ) 

(list:  iptables -t nat -S POSTROUTING )

on the hub (wg server) 172.20.24.1 

wg:
wg set wg2 peer rdwrtQdE7Z0SqZcJmoydFD74vXLLTnf+gk9go5pDWRw= allowed-ips 0.0.0.0/0 (namisto 172.20.24.10/24) (klic je klienta gateway) 

routing:
echo "123 wgfrompeer" >> /etc/iproute2/rt_tables #tim se nastavi jen jmeno
ip route add default via 172.20.24.10 dev wg2 table 123
ip rule add iif wg2 table 123 priority 100

(list:  ip route show table 123 , ip rule show )

 

firewall:
# neco z tohodle:
sysctl -w net.ipv4.ip_forward=1 (to uz je zrejme jako default)
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wg2 -s 172.20.24.0/24 -j ACCEPT
iptables -I FORWARD -i wg2 -o wg2 -j ACCEPT

středa 5. března 2025

File browser and file dialogs take a long time to open

 https://askubuntu.com/questions/1341909/file-browser-and-file-dialogs-take-a-long-time-to-open-or-fail-to-open-in-all-ap

 

Fast solution: 

pkill gvfsd-trash

Brute force permanent solution:

mv /usr/libexec/gvfsd-trash{,.bak}

 

úterý 3. září 2024

override ownership of mounted filesystem

 According to How can I mount a filesystem, mapping userids? :

I need to mount image file and share the content in the samba tree.

The thus, I need to remap original "user" to local user "nobody".

 

 

apt install  bindfs
root# mount -o ro /dev/loop1 /mnt/1 
root# bindfs -u nobody -g nogroup --map=user/nobody /mnt/1 /data/samba/tree/mountpoint

pátek 9. srpna 2024

Ansys 57 on 64-bit Debian 12 Bookworm

1. copy old installation tree

2. try it it runs:

 ~$ /ansys_inc/ansys57/bin/xansys57
bash: /ansys_inc/ansys57/bin/xansys57: cannot execute: required file not found

or:

 ~$ LM_LICENSE_FILE=1057@server /ansys_inc/ansys57/bin/ansys57 < inputfile.inp

If this works, change the variable definition: setenv ANSYSLIC_DIR /ansys_inc/ansys57
in /ansys_inc/ansys57/bin/anscript57.ini
and create the license file

echo SERVER=1057@server > /ansys_inc/ansys57/ansyslmd.ini 

3. add missing binaries

# apt install ncompress tcsh
# dpkg --add-architecture i386
# apt-get update
# apt install libc6-i386

ldd command lists missing libraries:

# ldd /ansys_inc/ansys57/bin/linuxia32/xans.e57
....
# apt-get install   libxi6:i386
# apt-get install   libxt6:i386
# apt-get install   libxpm4:i386
# dpkg -L  libxpm4:i386
# ln -s /usr/lib/i386-linux-gnu/libXpm.so.4.11.0 /usr/lib/i386-linux-gnu/libXp.so.6

# The Motif library libXm.so.2 is included in the original tree in a rpm file: extract libraries from

/ansys_inc/ansys57/syslib/OPENMOTIF/openmotif-2.1.30-2_ICS.i386.rpm
/ansys_inc/ansys57/syslib/MESA/Mesa-3.2-1rh61.i386.rpm

into /ansys_inc/ansys57/syslib/linuxia32 folder and create symlink:

cd /ansys_inc/ansys57/syslib/linuxia32
ln -s libXm.so.2.1 libXm.so.2

goto 2.

ansys 2024 "error while loading shared libraries: libXp.so.6: cannot open shared object file" (Debian 12 Bookworm)

ANSYS 2024R1, R2 does not start after installation due to missing libraries:

error while loading shared libraries: libXp.so.6: cannot open shared object file:

actually, the library is present in the installed tree

/ansys_inc/v242/ansys/syslib/ubuntu/libXp.so.6.2.0 

 

The ANSYS startup script anssh.ini adds the correct path to the LD_LIBRARY_PATH only when it detects Ubuntu OS. The check is done by 

grep Ubuntu /etc/os-release

So that it is sufficient to add a line to that file (yes, it is a dirty hack)

echo '# fake id to fool Ansys: Ubuntu' >> /etc/os-release

pátek 8. března 2024

add text to the first page of a PDF file

 1. crop pdf files 

pdfcrop --margins '-30 -30 -10 -20' input.pdf output.odf

margins: left, top, right, bottom


2.

string="this is a string"
tmpfile=$(mktemp) && echo $string | \
enscript -M a4 --margins=::0: -B -f Courier-Bold8 -o- | \
ps2pdf - "$tmpfile" && \
qpdf input.pdf --overlay "$tmpfile" -- output.pdf && \
rm -f  "$tmpfile" 

enscript --margins=left:right:top:bottom

úterý 7. listopadu 2023

remote logging to rsyslog

 

#enable remote access (mind also the firewall)

# provides UDP syslog reception
  module(load="imudp")
  input(type="imudp" port="514")
  
 # provides TCP syslog reception
  module(load="imtcp")
  input(type="imtcp" port="514")

#redirect all expernal traffic to dedicated file

$template remote-incoming-logs,"/var/log/remote/%HOSTNAME%.log"
  :inputname, isequal, "imudp" ?remote-incoming-logs
  :fromhost-ip , !isequal , "127.0.0.1" stop

 

Further reading: here

úterý 10. října 2023

LVM - replace 2-disk LV by a large single drive

The original LV named data/bigdata consists of two separate drives: /dev/sdc1 (6T) and /dev/sdd1 (5T) .

I would like to replace these two disks by the 12T single drive (/dev/sde).

The standard way is using the pvmove commnad. However, I opted to use mirroring approach.

  •  Create mirror:

    pvcreate /dev/sde1
    vgextend data /dev/sde1
    lvconvert --type mirror  -m 1 /dev/data/bigdata 

    lvs -a -o name,copy_percent,devices data

    lvs --all --segments -o +devices

  • remove old disks from the mirror
    lvconvert -m0 data/bigdata /dev/sdc1 /dev/sdd1

Now there is 1PE free space between two segments on /dev/sde1

[root@server ~]# pvs --segments -v
  PV         VG     Fmt  Attr PSize    PFree   Start   SSize   LV      Start   Type   PE Ranges
/dev/sdc1  data   lvm2 a--    <5.46t   <5.46t       0 1430791             0 free
/dev/sdd1  data   lvm2 a--    <4.55t   <4.55t       0 1192326             0 free
/dev/sde1  data   lvm2 a--    10.91t  <5.46t       0 1430791 bigdata      0 linear /dev/sde1:0-1430790
/dev/sde1  data   lvm2 a--    10.91t  <5.46t 1430791 1                    0 free
/dev/sde1  data   lvm2 a--    10.91t  <5.46t 1430792 1192326 bigdata      0 linear /dev/sde1:1430792-2623117


to remove the free space, move  the second segment from /dev/sde1 to the old drive, and than back to /dev/sde1

pvmove /dev/sde1:1430792-2623117 /dev/sdc1
pvmove /dev/sdc1 /dev/sde1

[root@server ~]# pvs --segments -v
  PV         VG     Fmt  Attr PSize    PFree    Start   SSize   LV      Start Type   PE Ranges
/dev/sdc1  data   lvm2 a--    <5.46t   <5.46t       0 1430791             0 free
/dev/sdd1  data   lvm2 a--    <4.55t   <4.55t       0 1192326             0 free
/dev/sde1  data   lvm2 a--    10.91t <929.45g       0 2623117 bigdata     0 linear /dev/sde1:0-2623116
/dev/sde1  data   lvm2 a--    10.91t <929.45g 2623117  237938             0 free

This way the two segments join without further conditions.

pvdisplay -m /dev/sde1
lvs --all --segments -o +devices data
lvs -a -o name,copy_percent,devices datapvs --segments -v

pondělí 31. července 2023

in-place replacement failing drive from md array

failing drive sdd1:

/dev/sdd
 Number  Start (sector)    End (sector)  Size       Code  Name
    1            2048     11721045134   5.5 TiB     FD00  Linux RAID

create temporary replacement virtual drive:
truncate -s $(((11721045134-2048)*512)) fake-sdd1-file
losetup -f fake-sdd1-file
replace the failing drive with the virtual spare space
mdadm --manage /dev/md0 --add /dev/loop0
mdadm /dev/md0 --replace /dev/sdd1 --with /dev/loop0
wait for data replication (see /proc/mdstat), then remove the failed drive
mdadm /dev/md0 --remove /dev/sdd1
eventually, destroy all md data from the drive and delete the partition
mdadm --zero-superblock /dev/sdd1
gdisk /dev/sdd
or use wipefs

úterý 21. března 2023

Rescan sata port (hot-swap)

Short:

First: identify and delete the old drive (identify HCTL, which is Host:Channel:Target:Lun (viz ))

$ lsscsi
[0:0:0:0]    cd/dvd  HL-DT-ST BD-RE  BH10LS30  1.02  /dev/sr0
[1:0:0:0]    disk    ATA      APPLE SSD TS256C 0201  /dev/sdd
[2:0:0:0]    disk    ATA      WDC WD6002FRYZ-0 1M03  /dev/sdb
[3:0:0:0]    disk    ATA      WDC WD5001F9YZ-0 1E03  /dev/sdc
[N:0:1:1]    disk    WDC PC SN520 SDAPNUW-512G-1002__1          /dev/nvme0n1
$ lsscsi -g
[0:0:0:0]    cd/dvd  HL-DT-ST BD-RE  BH10LS30  1.02  /dev/sr0   /dev/sg0
[1:0:0:0]    disk    ATA      APPLE SSD TS256C 0201  /dev/sdd   /dev/sg1
[2:0:0:0]    disk    ATA      WDC WD6002FRYZ-0 1M03  /dev/sdb   /dev/sg2
[3:0:0:0]    disk    ATA      WDC WD5001F9YZ-0 1E03  /dev/sdc   /dev/sg3
[N:0:1:1]    disk    WDC PC SN520 SDAPNUW-512G-1002__1          /dev/nvme0n1  -  
$ lsblk -o NAME,MODEL,HCTL
NAME             MODEL                          HCTL
sdb              WDC WD6002FRYZ-01WD5B1         2:0:0:0
└─sdb1                                          
  └─data-bigdata                                
sdc              WDC WD5001F9YZ-09YUWL1         3:0:0:0
└─sdc1                                          
  └─data-bigdata                                
sdd              APPLE SSD TS256C               1:0:0:0
sr0              HL-DT-ST BD-RE BH10LS30        0:0:0:0

and also:

readlink /sys/block/sdX

To find the physical SATA port number, add one to the given host number.

2:0:0:0 -> H=2, sdb == ata3
 

Or use this command:

# find -L /sys/bus/pci/devices/*/ata*/host*/target* -maxdepth 3 -name "sd*" 2>/dev/null |\
egrep block |egrep --colour '(ata[0-9]*)|(sd.*)'
/sys/bus/pci/devices/0000:00:18.0/ata1/host0/target0:0:0/0:0:0:0/block/sda
/sys/bus/pci/devices/0000:00:18.0/ata2/host1/target1:0:0/1:0:0:0/block/sdb
/sys/bus/pci/devices/0000:00:18.0/ata3/host2/target2:0:0/2:0:0:0/block/sdc
  ...   

As a first step, the old drive has to be deleted (see), and (see):

echo 1 > /sys/block/sda/device/delete

Then rescan the host bus:

echo "- - -" >/sys/class/scsi_host/host<n>/scan

or

for i in /sys/class/scsi_host/host* ; do echo "- - -" > $i/scan ; done

also here.

pátek 3. března 2023

Debian 11

Staticka IP adresa

(pred  systemctl restart networking je obcas nutne rucne smazat IP adresy zarizeni, jinak se zmeny v /etc/network/interfaces neprojevi)


Aktivace rc.local

(podle https://blog.wijman.net/enable-rc-local-in-debian-bullseye/ )

Create a file /etc/rc.local

#!/bin/sh
  # ...
  # By default this script does nothing.
  /etc/rc.firewall
  touch /var/lock/subsys/local
  exit 0
  
chmod +x /etc/rc.local

Then we need to reload the systemd manager configuration:

systemctl daemon-reload

Then we start the rc-local daemon:

systemctl start rc-local

And then we check the status of rc-local to confirm it ran OK:


systemctl status rc-local 

Pokud definice sluzby chybi: (podle https://www.cyberciti.biz/faq/how-to-enable-rc-local-shell-script-on-systemd-while-booting-linux-system/

[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local
 
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
 
[Install]
WantedBy=multi-user.target

anebo delsi a ukecanejsi soubor (ale musi mit sekci [Install]):

  
# /etc/systemd/system/rc-local.service
#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
 
# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target
 
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
StandardOutput=journal+console
StandardError=journal+console
[Install]
WantedBy=multi-user.target
 [Install]
WantedBy=multi-user.target

Iptables firewall

iptables negate: (https://www.cyberciti.biz/faq/iptables-invert-ip-or-protocol-with/) 

Narozdil od starsi implementace, negace se dava pred "option" (viz man iptables): --option ! this is deprecated in favour of ! --option this

--------------

neděle 19. února 2023

LVM - recovery of a temporarily failed disk/PV, missing PV

https://www.golinuxcloud.com/recover-lvm2-partition-restore-vg-pv-metadata/#Step_2_Restore_PV_Physical_Volume_in_Linux

 

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/4/html/cluster_logical_volume_manager/mdatarecover


https://serverfault.com/questions/788202/locked-lvm-logical-volume-in-vg-with-missing-pv

Similar to Can't remove volume group, solved this problem by creating a temporary pv with the same uuid:

UUID="RQr0HS-17ts-1k6Y-Xnex-IZwi-Y2kM-vCc5mP"  # from question
dd if=/dev/zero of=/tmp/tmp.raw bs=1M count=100 
losetup -f
losetup /dev/loop0 /tmp/tmp.raw
pvcreate --norestorefile -u $UUID /dev/loop0   # it has arisen!
killall lvmetad      # so it stops complaining about duplicate uuids (dulezite)
pvremove /dev/loop0  # a clean removal 
losetup -D
pvscan --cache       # to restart lvmetad


https://serverfault.com/questions/894410/cant-remove-volume-group

You cannot use --removemissing or force delete VG if metadata area equal zero as in my case.

Make block device from file and include in $VG:

dd if=/dev/zero of=/tmp/tmp.raw bs=1M count=100
losetup -f
losetup /dev/loop0 /tmp/tmp.raw
vgextend $VG /dev/loop0

After that I have Metadata Areas 1

vgremove --force $VG

and remove pvdevice:

pvremove /dev/loop0

pátek 17. února 2023

compression

 https://linuxreviews.org/Comparison_of_Compression_Algorithms

 https://www.privex.io/articles/which-compression-algorithm-tool/

 

 

Summary - which compression algorithms are best for each usecase?

Fastest compression and decompression: LZ4

Highest overall compression ratio: XZ

Compromise between compression ratio and speed: BZIP2 using LBZIP2

Most widely used / compatible compression algorithm: GZIP

 

My test:     256060514304  linux-sda.raw (239G) (almost empty disk image)

program sizesecs.speedrealusersys
pigz 10457259791  382.226 s 27.4 MB/s  6m22.2s 79m49.8s 10m14.8s
pbzip2 10147770833  511.313 s 19.8 MB/s  8m31.3s 151m19.4s 6m25.3s
lbzip2 10135040141  427.531 s 23.7 MB/s  7m7.5s 65m57.9s 3m23.1s
plzip  28286275683 1033.31 s  8.0 MB/s 17m13.3s 529m13.4s 3m1.4s
xz -T0  8183670908 887.644 s 9.2 MB/s 14m47.9s 339m29.3s 2m40.7s

 

My test 2:     10400825344  tmp.qcow2 (9.7G)

program sizesecs.speedrealusersys
pigz 4452123186 24.9386 s 179 MB/s 0m24.9s 8m52.9s 0m30.6s
pbzip2 4230752746 67.2459 s 62.9 MB/s 1m7.3s 33m10.6s 1m5.4s
lbzip2 4228282477 33.8341 s 125 MB/s 0m33.1s 16m43.6s 0m29.0s
plzip 3808851634 155.09 s 24.6 MB/s 2m35.1s 79m57.5s 0m35.6s
xz -T0 3756465944 156.155 s 24.1 MB/s 2m36.4s 79m7.2s 0m30.9s

Intel(R) Xeon(R) CPU E5-2697A v4 @ 2.60GHz, 16core/32threads, 128G ram