Umstellung auf systemd

Hallo an alle,

Ich würde gerne diesen Thread benutzen um Informationen zur Umstellung auf systemd zusammen zu tragen.
Ein Beispiel:
In einem anderen Thread habe ich gelesen das man bei Aktivierung von
systemd-resolved.service das Paket openresolv nicht mehr benötigt.
Stimmt, eben ausprobiert.
systemd-resolved.service hatte ich ja aktiviert aufgrund diverser Meldungen im journal.

 sudo systemctl status systemd-resolved                                                                                          ✔ 
[sudo] Passwort für weingeist: 
● systemd-resolved.service - Network Name Resolution
     Loaded: loaded (/usr/lib/systemd/system/systemd-resolved.service; enabled; preset: enabled)
     Active: active (running) since Sun 2023-01-08 13:59:17 CET; 38min ago
       Docs: man:systemd-resolved.service(8)
             man:org.freedesktop.resolve1(5)
             https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
             https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients
   Main PID: 707 (systemd-resolve)
     Status: "Processing requests..."
      Tasks: 1 (limit: 14193)
     Memory: 6.6M
        CPU: 129ms
     CGroup: /system.slice/systemd-resolved.service
             └─707 /usr/lib/systemd/systemd-resolved

Das das Paket openresolv dann weg kann steht natürlich nirgends.
Unser @megavolt scheint ja auch das Thema automount zu kennen.

systemd-swap.service das habe ich zum Beispiel auch aktiviert.

sudo systemctl status systemd-swap.service                                                                                      ✔ 
[sudo] Passwort für weingeist: 
● systemd-swap.service - Manage swap spaces on zram, files and partitions.
     Loaded: loaded (/usr/lib/systemd/system/systemd-swap.service; enabled; preset: disabled)
     Active: active (running) since Sun 2023-01-08 13:59:17 CET; 32min ago
   Main PID: 819 (systemd-swap)
     Status: "Monitoring memory status..."
      Tasks: 1 (limit: 14193)
     Memory: 22.2M
        CPU: 568ms
     CGroup: /system.slice/systemd-swap.service
             └─819 /usr/bin/python3 -u /usr/bin/systemd-swap start

Jan 08 13:59:17 weingeist-PC systemd[1]: Starting Manage swap spaces on zram, files and partitions....
Jan 08 13:59:17 weingeist-PC systemd-swap[819]: INFO: Load: /etc/systemd/swap.conf.d/myswap.conf
Jan 08 13:59:17 weingeist-PC systemd-swap[819]: INFO: Removing working directory...
Jan 08 13:59:17 weingeist-PC systemd-swap[819]: INFO: Removing files in /var/lib/systemd-swap/swapfc/...
Jan 08 13:59:17 weingeist-PC systemd-swap[819]: INFO: Load: /etc/systemd/swap.conf.d/myswap.conf
Jan 08 13:59:17 weingeist-PC systemd-swap[819]: INFO: Writing destroy info...
Jan 08 13:59:17 weingeist-PC systemd-swap[819]: INFO: swapD: pick up devices from systemd-gpt-auto-generator
Jan 08 13:59:17 weingeist-PC systemd-swap[819]: INFO: swapD: searching swap devices
Jan 08 13:59:17 weingeist-PC systemd-swap[819]: INFO: swapFC: on-demand swap activation at >7772 MiB memory usage
Jan 08 13:59:17 weingeist-PC systemd[1]: Started Manage swap spaces on zram, files and partitions..

Das ist tatsächlich nur für einen dynamisch wachsende Swap-Datei, die erstellt wird, falls benötigt. Eine Swap-Partition braucht keinen Eintrag in fstab mehr mit systemd. Wird voll automatisch erkannt.

Also brauche ich bei Verwendung von systemd-swap.service
diesen Eintrag in der fstab nicht ?

tmpfs   /tmp    tmpfs     defaults,noatime,mode=1777   0 0

Nein, den Eintrag brauchst Du nicht.

Das
(/tmp bzw. tmpfs)
hat aber nichts mit Swap oder systemd-swap.service zu tun.

tmpfs ist ein RAM basiertes “echtes” Dateisystem - Swap ist Auslagerungsspeicher um den RAM zu stützen.

Die Funktion mag ähnlich aussehen - das sind aber zwei unterschiedliche Dinge.

Eine vielleicht etwas bessere Erklärung der Unterschiede:

Difference between tmpfs and swap - Kernel Talks

Ah ok danke @Nachlese

Wenn wir gerade in die fstabschauen in Bezug auf x-systemd.automount

#UUID=2c606cec-cfd4-4179-a786-62218237b2aa   /media/Games     ext4      defaults,noatime,nofail                    0 1
UUID=2c606cec-cfd4-4179-a786-62218237b2aa     /media/Games     ext4      x-systemd.automount,nofail
#UUID=C624E96724E95B47   /media/NTFS      ntfs3     defaults,noatime,prealloc,nofail,uid=1000,gid=1000         0 1                    
UUID=C624E96724E95B47     /media/NTFS      ntfs3      x-systemd.automount,nofail

Wäre das so korrekt ?

Da bin ich überfragt -
wenn’s funktioniert, wird’s wohl richtig sein. :sunglasses:

Meine /etc/fstab ist noch old school - und externe Laufwerke benutze ich nur selten, so daß ich ohnehin keine extra Einträge dafür brauche.

Also ungelogen… es sieht so in der fstab bei mir aus:

$ cat /etc/fstab
UUID=415B-E5F7                            /boot/efi      vfat    umask=0077 0 2
UUID=9b69be67-344b-4f8c-b460-9da1fede5440 /              ext4    defaults,noatime 0 1

Das ist der nowendige Teil im Moment. Efi und root. Bei BIOS reicht nur das Wurzelverzeichnis.

Tmpfs wird auch auf /tmp eingehängt:

$ mount -t tmpfs 
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,inode64)
tmpfs on /run type tmpfs (rw,nosuid,nodev,size=779404k,nr_inodes=819200,mode=755,inode64)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,size=1948512k,nr_inodes=1048576,inode64)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=389700k,nr_inodes=97425,mode=700,uid=1000,gid=1001,inode64)

Und swap ist aktiviert:

$ swapon -s
Dateiname				Typ		Größe		Benutzt		Priorität
/dev/sda9                               partition	10239996	1107992		-2

Hier nochmal in systemd:

$ systemctl list-units --type=mount 
  UNIT                                                              LOAD   ACTIVE SUB     DESCRIPTION                                        
  -.mount                                                           loaded active mounted Root Mount
  boot-efi.mount                                                    loaded active mounted /boot/efi
  dev-hugepages.mount                                               loaded active mounted Huge Pages File System
  dev-mqueue.mount                                                  loaded active mounted POSIX Message Queue File System
  proc-sys-fs-binfmt_misc.mount                                     loaded active mounted Arbitrary Executable File Formats File System
  run-credentials-systemd\x2dsysctl.service.mount                   loaded active mounted /run/credentials/systemd-sysctl.service
  run-credentials-systemd\x2dsysusers.service.mount                 loaded active mounted /run/credentials/systemd-sysusers.service
  run-credentials-systemd\x2dtmpfiles\x2dsetup.service.mount        loaded active mounted /run/credentials/systemd-tmpfiles-setup.service
  run-credentials-systemd\x2dtmpfiles\x2dsetup\x2ddev.service.mount loaded active mounted /run/credentials/systemd-tmpfiles-setup-dev.service
  run-user-1000-doc.mount                                           loaded active mounted /run/user/1000/doc
  run-user-1000-gvfs.mount                                          loaded active mounted /run/user/1000/gvfs
  run-user-1000.mount                                               loaded active mounted /run/user/1000
  sys-fs-fuse-connections.mount                                     loaded active mounted FUSE Control File System
  sys-kernel-config.mount                                           loaded active mounted Kernel Configuration File System
  sys-kernel-debug.mount                                            loaded active mounted Kernel Debug File System
  sys-kernel-tracing.mount                                          loaded active mounted Kernel Trace File System
  tmp-.mount_ShadowbCzfHX.mount                                     loaded active mounted /tmp/.mount_ShadowbCzfHX
  tmp.mount                                                         loaded active mounted Temporary Directory /tmp

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.
18 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
$ systemctl list-units --type=swap
  UNIT          LOAD   ACTIVE SUB    DESCRIPTION   
  dev-sda9.swap loaded active active Swap Partition

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.
1 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

Also swap und tmpfs for /tmp ist bereits unötig. Wenn man jetzt die passenden Flags verwendet (nur GPT, kein MS-DOS), dann kann man, wenn nur ein Linux installiert ist, dann die fstab komplett leer lassen.

Jein, da automount aktiv, ist nofail unnötig. “Games” wird nur dann gemountet, wenn gefunden und das Verzeichnis betreten wird. nofail ist ja für da, dass es beim normalen Einhängen beim Start kein “Abhängigkeitsfehler” gibt, falls die Platte nicht da ist und die in die “Rettungs-Shell” verschoben wirst.

Schau dir doch das mal an:

Also den tmpfs Eintrag habe ich raus genommen. Funktioniert.
Mit nofail wollte ich vermeiden das das System hängen bleibt beim booten wenn mal eine Platte hustet.
Die Platten sind alle intern !
Habe jetzt einmal alle Platten bis auf die Systemplatte ( traue mich nicht ) auf x-systemd.automount umgeschrieben.
Jetzt wird es interessant

Jan 09 18:10:55 weingeist-PC systemd[1]: Set up automount media-C.automount.
Jan 09 18:10:55 weingeist-PC systemd[1]: Set up automount media-Downloads.automount.
Jan 09 18:10:55 weingeist-PC systemd[1]: Set up automount media-FTP.automount.
Jan 09 18:10:55 weingeist-PC systemd[1]: Set up automount media-Games.automount.
Jan 09 18:10:55 weingeist-PC systemd[1]: Set up automount media-NTFS.automount.
Jan 09 18:10:55 weingeist-PC systemd[1]: Set up automount media-ext4.automount.
Jan 09 18:11:00 weingeist-PC systemd[1]: media-Downloads.automount: Got automount request for /media/Downloads, triggered by 1655 (plasmashell)
Jan 09 18:11:00 weingeist-PC systemd[1]: Mounting /media/Downloads...
Jan 09 18:11:00 weingeist-PC systemd[1]: Mounted /media/Downloads.
Jan 09 18:11:00 weingeist-PC systemd[1]: media-NTFS.automount: Got automount request for /media/NTFS, triggered by 1660 (plasmashell)
Jan 09 18:11:00 weingeist-PC systemd[1]: media-FTP.automount: Got automount request for /media/FTP, triggered by 1665 (plasmashell)
Jan 09 18:11:00 weingeist-PC systemd[1]: Mounting /media/FTP...
Jan 09 18:11:00 weingeist-PC systemd[1]: Mounting /media/NTFS...
Jan 09 18:11:00 weingeist-PC systemd[1]: Mounted /media/FTP.
Jan 09 18:11:02 weingeist-PC systemd[1]: Mounted /media/NTFS.
Jan 09 18:11:02 weingeist-PC systemd[1]: media-Games.automount: Got automount request for /media/Games, triggered by 1665 (plasmashell)
Jan 09 18:11:02 weingeist-PC systemd[1]: Mounting /media/Games...
Jan 09 18:11:02 weingeist-PC systemd[1]: Mounted /media/Games.
Jan 09 18:11:30 weingeist-PC udisksd[1533]: Mounted /dev/sdd1 (system) at /media/ext4 on behalf of uid 1000
Jan 09 18:11:32 weingeist-PC udisksd[1533]: Mounted /dev/nvme0n1p2 (system) at /media/C on behalf of uid 1000

Alle Platten bis auf 2 werden automatisch eingehängt.
Laufwerk ext4 und C nicht. Die werden erst bei Zugriff eingehängt. Die hängt auch udisk ein.
Sehr mysteriös.

Wenn ich zwischen den Zeilen lese findest du automount nicht soo doll.

Ich kann jetzt auch nicht sagen, wie “plasmashell” die Einhängepunkte getriggert hat. Es muss wohl versucht haben eine Datei dort zu öffnen und dabei wird es eingehängt.

ext4 und C hast du wohl mit Dolphin eingehängt, statt das Verzeichnis zu öffnen.

Ja, ging am schnellsten :innocent:

Ok das war der richtige Wink mit dem Zaunpfahl.
Im Terminal mal ein Verzeichnis geöffnet und siehe da

Jan 09 18:58:12 weingeist-PC systemd[1]: media-ext4.automount: Got automount request for /media/ext4, triggered by 1712 (zsh)
Jan 09 18:58:12 weingeist-PC systemd[1]: Mounting /media/ext4...
Jan 09 18:58:12 weingeist-PC systemd[1]: Mounted /media/ext4.

Tja wieso also hängt er die Platte nicht automatisch ein?
Geht automount überhaupt mit der root Platte ?

Macht er doch :angel: Er hängt es automatisch ein, wenn man es benötigt, nicht wenn er bootet. Damit kann man den Boot-Prozess beschleunigen, z. B. Dann gibts es noch x-systemd.idle-timeout=180 → aushängen nach 3min Inaktivität. Sehr praktisch.

Verstehst du den Unterschied zwischen einem normalen Mount und einem Automount? Dann sollte dir klar sein, dass Automount für root sinnfrei ist.

Also der fstab Eintrag muss so aussehen.

UUID=983C244E3C2429A8              /media/C     x-systemd.automount,ntfs3  defaults,noatime,prealloc,nofail 0 1
UUID=4d67db85-2293-4040-bdfa-e6012e151560   /media/ext4      x-systemd.automount,ext4 defaults,noatime,nofail 0 1

Damit auch die korrekte Ausgabe

Jan 09 20:17:27 weingeist-PC systemd[1]: Mounting /media/C...
Jan 09 20:17:27 weingeist-PC systemd[1]: Mounting /media/Downloads...
Jan 09 20:17:27 weingeist-PC systemd[1]: Mounting /media/FTP...
Jan 09 20:17:27 weingeist-PC systemd[1]: Mounting /media/Games...
Jan 09 20:17:27 weingeist-PC systemd[1]: Mounting /media/NTFS...
Jan 09 20:17:27 weingeist-PC systemd[1]: Mounting /media/ext4...
Jan 09 20:17:27 weingeist-PC systemd[1]: Mounted /media/Games.
Jan 09 20:17:27 weingeist-PC systemd[1]: Mounted /media/C.
Jan 09 20:17:28 weingeist-PC systemd[1]: Mounted /media/ext4.
Jan 09 20:17:28 weingeist-PC systemd[1]: Mounted /media/FTP.
Jan 09 20:17:28 weingeist-PC systemd[1]: Mounted /media/Downloads.
Jan 09 20:17:29 weingeist-PC systemd[1]: Mounted /media/NTFS.

Nichts mehr mit plasmashell etc

Inwieweit und ob diese Parameter defaults,noatime,prealloc,nofail 0 1 noch eine Rolle spielen weiss ich noch nicht.

Was du meinst ist die Option noauto Default ist aber auto

Das scheint nur in Verbindung mit noauto zu funktionieren.

Fast alles falsch, was man falsch machen kann…

UUID=983C244E3C2429A8 /media/C ntfs3 defaults,noatime,prealloc,nofail,x-systemd.automount 0 1
UUID=4d67db85-2293-4040-bdfa-e6012e15156 /media/ext4 ext4 x-systemd.automount

Schau mal…

auto → mounte mit dem System-Boot
noauto → mounte nicht mit dem System-Boot, sondern nur auf Anfrage manuell
x-systemd.automount → mounte nicht mit System-Boot, sondern wenn es getriggert wird (Verzeichnis betreten)

Verständlich?

Stimmt, musste ich jetzt auch merken. Hatte mich darauf bezogen, was ja teilweise funktioniert.

Hast ja Recht. Da war ich beim lesen in systemd.mount gelandet. Da ist das so mit auto und noauto. hmpf

Kleine Zusammenfassung fstab Einträge

ext4 SSD

UUID=2c606cec-cfd4-4179-a786-62218237b2aa   /media/Games     ext4      defaults,noatime,nofail   0 1

ext4 HDD

UUID=4d67db85-2293-4040-bdfa-e6012e151560   /media/ext4  ext4  x-systemd.automount,x-systemd.idle-timeout=180 0 1

NTFS SSD

UUID=983C244E3C2429A8   /media/C  ntfs3     defaults,noatime,prealloc,nofail,uid=1000,gid=1000      0 0

NTFS HDD

UUID=C624E96724E95B47 /media/NTFS  ntfs3  defaults,noatime,prealloc,nofail,x-systemd.automount,x-systemd.idle-timeout=180  0 0

so korrekt ?

Jan 09 21:46:22 weingeist-PC systemd[1]: Set up automount media-FTP.automount.
Jan 09 21:46:22 weingeist-PC systemd[1]: Set up automount media-NTFS.automount.
Jan 09 21:46:22 weingeist-PC systemd[1]: Set up automount media-ext4.automount.
Jan 09 21:46:22 weingeist-PC systemd[1]: Mounting /media/C...
Jan 09 21:46:22 weingeist-PC systemd[1]: Mounting /media/Downloads...
Jan 09 21:46:22 weingeist-PC systemd[1]: Mounting /media/Games...
Jan 09 21:46:23 weingeist-PC systemd[1]: Mounted /media/Games.
Jan 09 21:46:23 weingeist-PC systemd[1]: Mounted /media/C.
Jan 09 21:46:23 weingeist-PC systemd[1]: Mounted /media/Downloads.

Das Ende nicht vergessen…

0 1 → ext4
0 0 → ntfs

die 1 am Ende bedeutet Fsck → file system check. Das ist sinnfrei bei NTFS da keine Unterstützung Linux.

Ansonsten scheint der Syntax korrekt zu sein.

Übernimmt nicht systemd den fsck ? Deswegen musste man doch in Grub umändern.

# Uncomment to ensure that the root filesystem is mounted read-only so that
# systemd-fsck can run the check automatically. We use 'fsck' by default, which
# needs 'rw' as boot parameter, to avoid delay in boot-time. 'fsck' needs to be
# removed from 'mkinitcpio.conf' to make 'systemd-fsck' work.
# See also Arch-Wiki: https://wiki.archlinux.org/index.php/Fsck#Boot_time_checking
GRUB_ROOT_FS_RO=true

Oder hab ich das jetzt auch falsch ?