[systemd-devel] stacked extension not working

Umut Tezduyar Lindskog Umut.Tezduyar at axis.com
Wed Jan 26 12:59:18 UTC 2022


Way to go Luca! Thank you for informing. We still have great interest in portable services. 

On 2022-01-23, 4:45 PM, "Luca Boccassi" <bluca at debian.org> wrote:

    FYI, support for using directories with --extension has just been
    merged in main and will be available in v251.

    On Wed, 20 Oct 2021 at 16:15, Luca Boccassi <bluca at debian.org> wrote:
    >
    > No, it's only supported for images at the moment, as the documentation
    > says:
    >
    >        --extension=PATH
    >            Add an additional image PATH as an overlay on top of IMAGE
    > when attaching/detaching. This argument can
    >            be specified multiple times, in which case the order in
    > which images are laid down follows the rules
    >            specified in systemd.exec(5) for the ExtensionImages=
    > directive. The image(s) must contain an
    >            extension-release file with metadata that matches what is
    > defined in the os-release of IMAGE. See: os-
    >            release(5).
    >
    > The internal implementation of extensions is ExtensionImage= which as
    > the name says, it's for binary images. There's no ExtensionDirectory=
    > yet - no reason it can't there be one, just someone needs to implement
    > it. PRs welcome!
    >
    > On Wed, 2021-10-20 at 17:04 +0200, Umut Tezduyar Lindskog wrote:
    > > It indeed worked as squashfs image. Thanks for that.
    > >
    > > It is not working as a folder though (portablectl --runtime attach --
    > > extension=./stackupper ./base stackupper) This stuff should work on
    > > folders too right? Should I open a ticket?
    > >
    > > Also, when it works, the upper stack shows as detached. Isn't that
    > > wrong too? Should I open a ticket?
    > >
    > > root at osboxes:/home/osboxes/Development# portablectl attach --runtime
    > > --extension $PWD/stackupper.raw $PWD/base.raw stackupper
    > > (Matching unit files with prefixes 'stackupper'.)
    > > Created directory /run/systemd/system.attached.
    > > Created directory /run/systemd/system.attached/stackupper.service.d.
    > > Written /run/systemd/system.attached/stackupper.service.d/20-
    > > portable.conf.
    > > Created symlink /run/systemd/system.attached/stackupper.service.d/10-
    > > profile.conf →
    > > /usr/lib/systemd/portable/profile/default/service.conf.
    > > Copied /run/systemd/system.attached/stackupper.service.
    > > Created symlink /run/portables/stackupper.raw →
    > > /home/osboxes/Development/stackupper.raw.
    > > Created symlink /run/portables/base.raw →
    > > /home/osboxes/Development/base.raw.
    > > root at osboxes:/home/osboxes/Development# portablectl list
    > > NAME       TYPE RO CRTIME                      MTIME
    > >       USAGE  STATE
    > > base       raw  no Wed 2021-10-20 10:54:41 EDT Wed 2021-10-20
    > > 10:54:41 EDT 920.0K attached-runtime
    > > stackupper raw  no Wed 2021-10-20 10:54:57 EDT Wed 2021-10-20
    > > 10:54:57 EDT 36.0K  detached
    > >
    > >
    > > Thanks again
    > > Umut
    > >
    > > On Wed, Oct 20, 2021 at 12:01 AM Luca Boccassi <bluca at debian.org>
    > > wrote:
    > > > On Tue, 2021-10-19 at 16:09 +0200, Umut Tezduyar Lindskog wrote:
    > > > > Hi Luca, have you had time to help me out or do you think you
    > > > could
    > > > > help me
    > > > > out? Thanks in advance.
    > > >
    > > > Works fine for me with systemd 249.5:
    > > >
    > > > $ tar xf ~/Downloads/portable.tar
    > > > $ mksquashfs base/ base.raw
    > > > Parallel mksquashfs: Using 4 processors
    > > > Creating 4.0 filesystem on base.raw, block size 131072.
    > > > [==================================================================
    > > > =====================================|] 23/23 100%
    > > >
    > > > Exportable Squashfs 4.0 filesystem, gzip compressed, data block
    > > > size 131072
    > > >         compressed data, compressed metadata, compressed fragments,
    > > >         compressed xattrs, compressed ids
    > > >         duplicates are removed
    > > > Filesystem size 918.80 Kbytes (0.90 Mbytes)
    > > >         39.83% of uncompressed filesystem size (2306.95 Kbytes)
    > > > Inode table size 359 bytes (0.35 Kbytes)
    > > >         35.69% of uncompressed inode table size (1006 bytes)
    > > > Directory table size 319 bytes (0.31 Kbytes)
    > > >         62.80% of uncompressed directory table size (508 bytes)
    > > > Number of duplicate files found 3
    > > > Number of inodes 29
    > > > Number of files 9
    > > > Number of fragments 2
    > > > Number of symbolic links 0
    > > > Number of device nodes 0
    > > > Number of fifo nodes 0
    > > > Number of socket nodes 0
    > > > Number of directories 20
    > > > Number of ids (unique uids + gids) 1
    > > > Number of uids 1
    > > >         luca (1000)
    > > > Number of gids 1
    > > >         luca (1000)
    > > > $ mksquashfs stackupper/ stackupper.raw
    > > > Parallel mksquashfs: Using 4 processors
    > > > Creating 4.0 filesystem on stackupper.raw, block size 131072.
    > > > [==================================================================
    > > > =======================================|] 3/3 100%
    > > >
    > > > Exportable Squashfs 4.0 filesystem, gzip compressed, data block
    > > > size 131072
    > > >         compressed data, compressed metadata, compressed fragments,
    > > >         compressed xattrs, compressed ids
    > > >         duplicates are removed
    > > > Filesystem size 33.94 Kbytes (0.03 Mbytes)
    > > >         41.81% of uncompressed filesystem size (81.18 Kbytes)
    > > > Inode table size 269 bytes (0.26 Kbytes)
    > > >         34.98% of uncompressed inode table size (769 bytes)
    > > > Directory table size 261 bytes (0.25 Kbytes)
    > > >         58.78% of uncompressed directory table size (444 bytes)
    > > > Number of duplicate files found 2
    > > > Number of inodes 24
    > > > Number of files 5
    > > > Number of fragments 1
    > > > Number of symbolic links 1
    > > > Number of device nodes 0
    > > > Number of fifo nodes 0
    > > > Number of socket nodes 0
    > > > Number of directories 18
    > > > Number of ids (unique uids + gids) 1
    > > > Number of uids 1
    > > >         luca (1000)
    > > > Number of gids 1
    > > >         luca (1000)
    > > > $ sudo portablectl attach --runtime --extension $PWD/stackupper.raw
    > > > $PWD/base.raw stackupper
    > > > (Matching unit files with prefixes 'stackupper'.)
    > > > Created directory /run/systemd/system.attached.
    > > > Created directory
    > > > /run/systemd/system.attached/stackupper.service.d.
    > > > Written /run/systemd/system.attached/stackupper.service.d/20-
    > > > portable.conf.
    > > > Created symlink
    > > > /run/systemd/system.attached/stackupper.service.d/10-profile.conf →
    > > > /usr/lib/systemd/portable/profile/default/service.conf.
    > > > Copied /run/systemd/system.attached/stackupper.service.
    > > > Created symlink /run/portables/stackupper.raw →
    > > > /tmp/portable/stackupper.raw.
    > > > Created symlink /run/portables/base.raw → /tmp/portable/base.raw.
    > > > $ sudo systemctl start stackupper
    > > > $ systemctl status stackupper
    > > > ○ stackupper.service
    > > >      Loaded: loaded
    > > > (/run/systemd/system.attached/stackupper.service; static)
    > > >     Drop-In: /run/systemd/system.attached/stackupper.service.d
    > > >              └─10-profile.conf, 20-portable.conf
    > > >      Active: inactive (dead)
    > > >
    > > > Oct 19 22:57:16 luca-desktop tree[100886]: |   |   |   |   |--
    > > > oom_score
    > > > Oct 19 22:57:16 luca-desktop tree[100886]: |   |   |   |   |--
    > > > oom_score_adj
    > > > Oct 19 22:57:16 luca-desktop tree[100886]: |   |   |   |   |--
    > > > pagemap
    > > > Oct 19 22:57:16 luca-desktop tree[100886]: |   |   |   |   |--
    > > > patch_state
    > > > Oct 19 22:57:16 luca-desktop tree[100886]: |   |   |   |   |--
    > > > personality
    > > > Oct 19 22:57:16 luca-desktop tree[100886]: |   |   |   |   |--
    > > > projid_map
    > > > Oct 19 22:57:16 luca-desktop tree[100886]: |   |   |   |   |-- root
    > > > -> [Error\ reading\ symbolic\ link\ information]
    > > > Oct 19 22:57:17 luca-desktop systemd[1]: stackupper.service:
    > > > Deactivated successfully.
    > > > Oct 19 22:57:17 luca-desktop systemd[1]: Finished
    > > > stackupper.service.
    > > > Oct 19 22:57:17 luca-desktop systemd[1]: stackupper.service:
    > > > Consumed 1.022s CPU time.
    > > >
    > > > > On Mon, Oct 18, 2021 at 12:56 PM Umut Tezduyar Lindskog
    > > > > <umut at tezduyar.com>
    > > > > wrote:
    > > > >
    > > > > > Hi again. I tried renaming (
    > > > > >
    > > > https://www.freedesktop.org/software/systemd/man/os-release.html)
    > > > it
    > > > > > but
    > > > > > that didn't work. I am not getting any errors during the
    > > > attachment
    > > > > > phase
    > > > > > so I am not sure if the failure is due to extension file in any
    > > > way.
    > > > > >
    > > > > > A wish list is to be more verbose regarding what is going on
    > > > during
    > > > > > extension file check/comparison and during overlaying /usr and
    > > > /opt.
    > > > > > I
    > > > > > think portablectl is quite verbose when it comes to preparing
    > > > files,
    > > > > > symb
    > > > > > links and what I wish fits well.
    > > > > >
    > > > > > Could you please try it yourself? I put them in
    > > > > >
    > > > https://drive.google.com/file/d/1LoN_swR7jgvo5yxajWjYK5ck_e8kJs1W/view?usp=sharing
    > > > > > there should be a download button on the top right. Appreciate
    > > > your
    > > > > > help.
    > > > > >
    > > > > > Thanks,
    > > > > > Umut
    > > > > >
    > > > > >
    > > > > > On Fri, Oct 15, 2021 at 3:46 PM Luca Boccassi
    > > > <bluca at debian.org>
    > > > > > wrote:
    > > > > >
    > > > > > > On Fri, 2021-10-15 at 14:59 +0200, Umut Tezduyar Lindskog
    > > > wrote:
    > > > > > > > Thanks and I would have never figured it out without your
    > > > help.
    > > > > > > > However, moving the binary to /opt didn't work either (I
    > > > made
    > > > > > > > sure
    > > > > > > > there is empty /opt in the base too). Anything else I am
    > > > missing?
    > > > > > > >
    > > > > > > > root at osboxes:/home/osboxes/Development# tree stackupper/
    > > > > > > > stackupper/
    > > > > > > > ├── bin
    > > > > > > > │   └── umut
    > > > > > > > ├── dev
    > > > > > > > ├── etc
    > > > > > > > │   ├── machine-id
    > > > > > > > │   ├── resolv.conf
    > > > > > > > │   └── runtime
    > > > > > > > ├── lib -> usr/lib
    > > > > > > > ├── opt
    > > > > > > > │   └── tree
    > > > > > > > ├── proc
    > > > > > > > ├── root
    > > > > > > > ├── run
    > > > > > > > ├── sys
    > > > > > > > ├── tmp
    > > > > > > > ├── usr
    > > > > > > > │   ├── bin
    > > > > > > > │   └── lib
    > > > > > > > │       ├── extension-release.d
    > > > > > > > │       │   └── extension-release.base
    > > > > > > > │       └── systemd
    > > > > > > > │           └── system
    > > > > > > > │               └── stackupper.service
    > > > > > > > └── var
    > > > > > > >     └── tmp
    > > > > > > >
    > > > > > > > 18 directories, 7 files
    > > > > > > > root at osboxes:/home/osboxes/Development# cat
    > > > > > > > stackupper/usr/lib/systemd/system/stackupper.service
    > > > > > > > [Service]
    > > > > > > > Type=oneshot
    > > > > > > > ExecStart=/opt/tree /
    > > > > > >
    > > > > > > The extension-release file in the extension must be named
    > > > exactly
    > > > > > > after
    > > > > > > the extension (eg: foo.raw must contain /usr/lib/extension-
    > > > > > > release.d/extension-release.foo), but in your case it's
    > > > called
    > > > > > > ".base"
    > > > > > > which doesn't seem right, so double check that. This too is
    > > > > > > documented
    > > > > > > in the man page.
    > > > > > >
    > > > > > > > On Fri, Oct 15, 2021 at 2:23 PM Luca Boccassi
    > > > <bluca at debian.org>
    > > > > > > > wrote:
    > > > > > > > > On Fri, 2021-10-15 at 12:18 +0000, Umut Tezduyar Lindskog
    > > > > > > > > wrote:
    > > > > > > > > > Hi, following works for us (for reference,
    > > > configuration is
    > > > > > > > > printed
    > > > > > > > > > at the end)
    > > > > > > > > >
    > > > > > > > > > portablectl --now attach --extension=./stackupper
    > > > ./base
    > > > > > > > > stackupper
    > > > > > > > > >
    > > > > > > > > > However, if we move the cat from base/usr/bin/cat to
    > > > > > > > > > stackupper/bin/cat it is not working. Seems like we
    > > > cannot
    > > > > > > > > include
    > > > > > > > > > any library/executable in the extension.
    > > > > > > > > >
    > > > > > > > > > Are we missing something?
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > > root at osboxes:/home/osboxes/Development# tree base/
    > > > > > > > > > base/
    > > > > > > > > > ├──bin
    > > > > > > > > > ├──dev
    > > > > > > > > > ├──etc
    > > > > > > > > > │   ├── machine-id
    > > > > > > > > > │   ├── os-release
    > > > > > > > > > │   └── resolv.conf
    > > > > > > > > > ├──lib
    > > > > > > > > > │   └── x86_64-linux-gnu
    > > > > > > > > > │       └── libc.so.6
    > > > > > > > > > ├──lib64
    > > > > > > > > > │   ├──ld-2.32.so
    > > > > > > > > > │   └── ld-linux-x86-64.so.2
    > > > > > > > > > ├──proc
    > > > > > > > > > ├──root
    > > > > > > > > > ├──run
    > > > > > > > > > ├──sys
    > > > > > > > > > ├──tmp
    > > > > > > > > > ├──usr
    > > > > > > > > > │   ├──bin
    > > > > > > > > > │   │   ├──cat
    > > > > > > > > > │   │   ├──echo
    > > > > > > > > > │   │   └── tree
    > > > > > > > > > │   └── lib
    > > > > > > > > > │       └── systemd
    > > > > > > > > > │           └── system
    > > > > > > > > > └── var
    > > > > > > > > >     └── tmp
    > > > > > > > > >
    > > > > > > > > > 18 directories, 9 files
    > > > > > > > > >
    > > > > > > > > > root at osboxes:/home/osboxes/Development# tree
    > > > stackupper/
    > > > > > > > > > stackupper/
    > > > > > > > > > ├──bin
    > > > > > > > > > │   └── umut
    > > > > > > > > > ├──dev
    > > > > > > > > > ├──etc
    > > > > > > > > > │   ├── machine-id
    > > > > > > > > > │   ├── resolv.conf
    > > > > > > > > > │   └── runtime
    > > > > > > > > > ├──lib -> usr/lib
    > > > > > > > > > ├──proc
    > > > > > > > > > ├──root
    > > > > > > > > > ├──run
    > > > > > > > > > ├──sys
    > > > > > > > > > ├──tmp
    > > > > > > > > > ├──usr
    > > > > > > > > > │   ├──bin
    > > > > > > > > > │   └── lib
    > > > > > > > > > │       ├──extension-release.d
    > > > > > > > > > │       │   └── extension-release.base
    > > > > > > > > > │       └── systemd
    > > > > > > > > > │           └── system
    > > > > > > > > > │               └── stackupper.service
    > > > > > > > > > └── var
    > > > > > > > > >     └── tmp
    > > > > > > > > >
    > > > > > > > > > 17 directories, 6 files
    > > > > > > > > >
    > > > > > > > > > root at osboxes:/home/osboxes/Development# cat
    > > > > > > > > > stackupper/usr/lib/systemd/system/stackupper.service
    > > > > > > > > > [Service]
    > > > > > > > > > Type=oneshot
    > > > > > > > > > ExecStart=/usr/bin/cat /etc/os-release
    > > > > > > > > > root at osboxes:/home/osboxes/Development#systemctl --
    > > > version
    > > > > > > > > > systemd 249 (249.4-1)
    > > > > > > > > > +PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP
    > > > +GCRYPT
    > > > > > > > > +GNUTLS -
    > > > > > > > > > OPENSSL +ACL +BLKID +CURL +ELFUTILS -FIDO2 +IDN2 -IDN
    > > > +IPTC
    > > > > > > > > > +KMOD
    > > > > > > > > > +LIBCRYPTSETUP -LIBFDISK +PCRE2 -PWQUALITY -P11KIT -
    > > > QRENCODE
    > > > > > > > > +BZIP2
    > > > > > > > > > +LZ4 +XZ +ZLIB +ZSTD -XKBCOMMON +UTMP +SYSVINIT
    > > > default-
    > > > > > > > > > hierarchy=unified
    > > > > > > > >
    > > > > > > > > Hi,
    > > > > > > > >
    > > > > > > > > You need to build your extension with the binaries under
    > > > either
    > > > > > > > > the
    > > > > > > > > /usr or /opt hierarchies. Legacy locations like /bin and
    > > > /lib
    > > > > > > > > are
    > > > > > > > > ignored. This is explained in the systemd-sysext.8
    > > > manpage.
    > > > > > > > >
    > > > > > >
    > > > > > >
    > > >
    >



More information about the systemd-devel mailing list