How does the OS know where /sysroot is?

The fstab below in MicroOS uses by default an overlay for /etc:

cat /etc/fstab 
UUID=45e755ab-5185-4f37-8c78-7a31f4d6dfaa  /                       btrfs  ro                            0  0
UUID=82f3ac8b-5b20-4420-b8c7-f994fccb82e7 /var btrfs subvol=/@/var,x-initrd.mount 0 0
UUID=45e755ab-5185-4f37-8c78-7a31f4d6dfaa  /usr/local              btrfs  subvol=/@/usr/local           0  0
UUID=45e755ab-5185-4f37-8c78-7a31f4d6dfaa  /srv                    btrfs  subvol=/@/srv                 0  0
UUID=45e755ab-5185-4f37-8c78-7a31f4d6dfaa /root btrfs subvol=/@/root,x-initrd.mount 0 0
UUID=45e755ab-5185-4f37-8c78-7a31f4d6dfaa  /opt                    btrfs  subvol=/@/opt                 0  0
UUID=45e755ab-5185-4f37-8c78-7a31f4d6dfaa  /home                   btrfs  subvol=/@/home                0  0
UUID=45e755ab-5185-4f37-8c78-7a31f4d6dfaa  /boot/writable          btrfs  subvol=/@/boot/writable       0  0
UUID=45e755ab-5185-4f37-8c78-7a31f4d6dfaa  /boot/grub2/x86_64-efi  btrfs  subvol=/@/boot/grub2/x86_64-efi  0  0
UUID=45e755ab-5185-4f37-8c78-7a31f4d6dfaa  /boot/grub2/i386-pc     btrfs  subvol=/@/boot/grub2/i386-pc  0  0
UUID=45e755ab-5185-4f37-8c78-7a31f4d6dfaa  /.snapshots             btrfs  subvol=/@/.snapshots          0  0
overlay /etc overlay defaults,lowerdir=/sysroot/etc,upperdir=/sysroot/var/lib/overlay/1/etc,workdir=/sysroot/var/lib/overlay/work-etc,x-systemd.requires-mounts-for=/var,x-systemd.requires-mounts-for=/sysroot/var,x-initrd.mount 0 0

In a previous comment it was noted that this /sysroot is located in /var/lib/overlay, which is indeed correct.

But what I seem to misunderstand is how /etc/fstab understands that this /sysroot is actually in /var/lib/overlay. The kernel documentation doesn’t provide me with the answer either. There it seems to define a directory on the filesystem? But if that’s true, how does this work if the verbatim directory /sysroot does not exist?

/sysroot is used by dracut to mount real root.

I see, thanks.

localhost:~ # journalctl --grep sysroot --boot -1 --no-pager 
Jun 20 10:16:09 localhost systemd[1]: Mounting /sysroot...
Jun 20 10:16:09 localhost systemd[1]: Mounted /sysroot.
Jun 20 10:16:09 localhost systemd-sysroot-fstab-check[504]: /sysroot/var should be mounted in the initrd, will request daemon-reload.
Jun 20 10:16:09 localhost systemd[1]: Mounting /sysroot/root...
Jun 20 10:16:09 localhost systemd[1]: Mounting /sysroot/var...
Jun 20 10:16:09 localhost systemd[1]: Mounted /sysroot/root.
Jun 20 10:16:09 localhost systemd[1]: Mounted /sysroot/var.
Jun 20 10:16:09 localhost systemd[1]: sysroot-etc.mount: Directory /sysroot/etc to mount over is not empty, mounting anyway.
Jun 20 10:16:10 localhost systemd[1]: Mounting /sysroot/etc...
Jun 20 10:16:10 localhost systemd[1]: Mounted /sysroot/etc.
Jun 20 10:16:10 localhost systemd[1]: transactional-update /etc overlay cleaner was skipped because of an unmet condition check (ConditionPathExists=/sysroot/var/lib/overlay/transactional-update.newsnapshot).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.