Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd-homed: Getting "New partition doesn't fit into backing storage, refusing" #22255

Closed
mat8913 opened this issue Jan 26, 2022 · 17 comments · Fixed by #25066
Closed

systemd-homed: Getting "New partition doesn't fit into backing storage, refusing" #22255

mat8913 opened this issue Jan 26, 2022 · 17 comments · Fixed by #25066
Labels
homed homed, homectl, pam_homed regression ⚠️ A bug in something that used to work correctly and broke through some recent commit
Milestone

Comments

@mat8913
Copy link

mat8913 commented Jan 26, 2022

systemd version the issue has been seen with

systemd 250 (250.3-1-arch)
+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 -BPF_FRAMEWORK +XKBCOMMON +UTMP -SYSVINIT default-hierarchy=unified

Used distribution

Manjaro ARM (https://github.com/manjaro-pinephone/phosh)

Linux kernel version used (uname -a)

Linux manjaro-arm 5.16.2-1-MANJARO-ARM #1 SMP PREEMPT Thu Jan 20 14:59:31 UTC 2022 aarch64 GNU/Linux

CPU architecture issue was seen on

arm64

Expected behaviour you didn't see

Logging in via gdm should work

Unexpected behaviour you saw

Logging in via gdm stalls. When I attempt to activate manually via homectl activate, I get an "Invalid argument" error.

Steps to reproduce the problem

I created the home partition on an sd card via something like homectl create --image-path=/dev/mmcblk0 ... on an older version of systemd (it was a while ago, so I don't remember exactly which version). Today I upgraded systemd and restarted, and I found I could no longer activate my home directory.

Additional program output to the terminal or log subsystem illustrating the issue

Jan 27 02:15:51 manjaro-arm kernel: Btrfs loaded, crc32c=crc32c-generic, zoned=no, fsverity=no
Jan 27 02:15:51 manjaro-arm kernel: BTRFS: device label matthew devid 1 transid 10277 /dev/dm-0 scanned by systemd-udevd (3758)
Jan 27 02:15:51 manjaro-arm systemd-homework[3747]: Setting up LUKS device /dev/mapper/home-matthew completed.
Jan 27 02:15:51 manjaro-arm systemd-homework[3747]: Provided password unlocks user record.
Jan 27 02:15:51 manjaro-arm systemd-homework[3747]: Probing file system completed (found btrfs).
Jan 27 02:15:51 manjaro-arm systemd-homework[3747]: File system check completed.
Jan 27 02:15:51 manjaro-arm kernel: BTRFS info (device dm-0): flagging fs with big metadata feature
Jan 27 02:15:51 manjaro-arm kernel: BTRFS info (device dm-0): use zstd compression, level 1
Jan 27 02:15:51 manjaro-arm kernel: BTRFS info (device dm-0): turning on sync discard
Jan 27 02:15:51 manjaro-arm kernel: BTRFS info (device dm-0): disk space caching is enabled
Jan 27 02:15:51 manjaro-arm kernel: BTRFS info (device dm-0): has skinny extents
Jan 27 02:15:51 manjaro-arm kernel: BTRFS info (device dm-0): enabling ssd optimizations
Jan 27 02:15:51 manjaro-arm systemd-homework[3747]: Mounting file system completed.
Jan 27 02:15:55 manjaro-arm systemd-homework[3747]: Discarded unused 75.3G.
Jan 27 02:15:55 manjaro-arm systemd-homework[3747]: Operating on partition device /dev/disk/by-uuid/533a4221-b19e-4954-a815-f6ef69276>
Jan 27 02:15:55 manjaro-arm systemd-homework[3747]: Discovered used loopback device (null).
Jan 27 02:15:55 manjaro-arm systemd-homework[3747]: offset = 1048576, size = 127864389120, image = 127865454592
Jan 27 02:15:55 manjaro-arm systemd-homework[3747]: New partition doesn't fit into backing storage, refusing.
Jan 27 02:15:56 manjaro-arm systemd-homework[3747]: Discarded unused 3.2G.
Jan 27 02:15:56 manjaro-arm systemd-homed[3157]: block device /sys/devices/virtual/block/dm-0 has been removed.
Jan 27 02:15:56 manjaro-arm systemd-homed[3157]: Activation failed: Invalid argument
Jan 27 02:15:56 manjaro-arm systemd-homed[3157]: matthew: changing state activating → inactive
Jan 27 02:15:56 manjaro-arm systemd-homed[3157]: block device /sys/devices/virtual/block/dm-0 has been removed.
@yuwata yuwata added homed homed, homectl, pam_homed regression ⚠️ A bug in something that used to work correctly and broke through some recent commit labels Jan 26, 2022
@jpalko
Copy link

jpalko commented Jan 27, 2022

I have a similar issue with a homed on a dedicated drive nvme1n1 which has the partition nvme1n1p1 which is the LUKS btrfs storage for my user. When I run homectl activate jukka on systemd version 249.7-2, I get:

tammi 26 06:46:35 r7-5700g systemd-homed[631]: jukka: changing state inactive → activating-for-acquire
tammi 26 06:46:35 r7-5700g systemd-homework[1795]: None of the supplied plaintext passwords unlock the user record's hashed passwords.
tammi 26 06:46:35 r7-5700g systemd-homed[631]: Activation failed: Required key not available
tammi 26 06:46:35 r7-5700g systemd-homed[631]: jukka: changing state activating-for-acquire → inactive
tammi 26 06:46:35 r7-5700g systemd-homed[631]: Got notification that all sessions of user jukka ended, deactivating automatically.
tammi 26 06:46:35 r7-5700g systemd-homed[631]: Home jukka already deactivated, no automatic deactivation needed.
tammi 26 06:46:38 r7-5700g systemd-homed[631]: jukka: changing state inactive → activating-for-acquire
tammi 26 06:46:38 r7-5700g systemd-homework[1796]: Provided password unlocks user record.
tammi 26 06:46:38 r7-5700g systemd-homework[1796]: Setting up loopback device /dev/disk/by-uuid/ddd9773b-568e-4dd3-8684-ce641f460a4b completed.
tammi 26 06:46:38 r7-5700g kernel: BTRFS: device label jukka devid 1 transid 139108 /dev/dm-1 scanned by systemd-udevd (1799)
tammi 26 06:46:38 r7-5700g systemd-homework[1796]: Setting up LUKS device /dev/mapper/home-jukka completed.
tammi 26 06:46:39 r7-5700g systemd-homework[1796]: Provided password unlocks user record.
tammi 26 06:46:39 r7-5700g systemd-homework[1796]: Probing file system completed (found btrfs).
tammi 26 06:46:39 r7-5700g systemd-homework[1796]: File system check completed.
tammi 26 06:46:39 r7-5700g kernel: BTRFS info (device dm-1): flagging fs with big metadata feature
tammi 26 06:46:39 r7-5700g kernel: BTRFS info (device dm-1): turning on sync discard
tammi 26 06:46:39 r7-5700g kernel: BTRFS info (device dm-1): disk space caching is enabled
tammi 26 06:46:39 r7-5700g kernel: BTRFS info (device dm-1): has skinny extents
tammi 26 06:46:39 r7-5700g systemd-homework[1796]: Mounting file system completed.
tammi 26 06:46:39 r7-5700g kernel: BTRFS info (device dm-1): enabling ssd optimizations
tammi 26 06:46:46 r7-5700g systemd-homework[1796]: Discarded unused 835.3G.
tammi 26 06:46:46 r7-5700g systemd-homework[1796]: Read embedded .identity file.
tammi 26 06:46:46 r7-5700g systemd-homework[1796]: Provided password unlocks user record.
tammi 26 06:46:46 r7-5700g systemd-homework[1796]: Reconciling user identities completed (host and header version were identical).
tammi 26 06:46:46 r7-5700g systemd-homework[1796]: Reconciling embedded user identity completed (host and embedded version were identical).
tammi 26 06:46:46 r7-5700g systemd-homework[1796]: Recursive changing of ownership not necessary, skipped.
tammi 26 06:46:46 r7-5700g systemd-homework[1796]: Synchronized disk.
tammi 26 06:46:46 r7-5700g systemd-homework[1796]: Moving to final mount point /home/jukka completed.
tammi 26 06:46:46 r7-5700g systemd-homework[1796]: Everything completed.
tammi 26 06:46:46 r7-5700g systemd-homework[1796]: Image size is 931.5G, file system size is 931.4G, file system payload size is 931.4G, file system free is 835.2G.
tammi 26 06:46:46 r7-5700g systemd-homed[631]: Home jukka is signed exclusively by our key, accepting.
tammi 26 06:46:46 r7-5700g systemd-homed[631]: jukka: changing state activating-for-acquire → active
tammi 26 06:46:46 r7-5700g login[1794]: pam_systemd_home(login:auth): Home for user jukka successfully acquired.

As soon I upgrade my systemd to 250 or above, that same execution causes me to have this log output:

tammi 26 07:36:53 r7-5700g sddm-greeter[1438]: Reading from "/usr/share/xsessions/plasma.desktop"
tammi 26 07:36:53 r7-5700g sddm[858]: Message received from greeter: Login
tammi 26 07:36:53 r7-5700g sddm[858]: Reading from "/usr/share/xsessions/plasma.desktop"
tammi 26 07:36:53 r7-5700g sddm[858]: Reading from "/usr/share/xsessions/plasma.desktop"
tammi 26 07:36:53 r7-5700g sddm[858]: Session "/usr/share/xsessions/plasma.desktop" selected, command: "/usr/bin/startplasma-x11"
tammi 26 07:36:53 r7-5700g sddm-helper[1843]: [PAM] Starting...
tammi 26 07:36:53 r7-5700g sddm-helper[1843]: [PAM] Authenticating...
tammi 26 07:36:53 r7-5700g systemd-homed[794]: jukka: changing state inactive → activating-for-acquire
tammi 26 07:36:53 r7-5700g systemd-homework[1844]: None of the supplied plaintext passwords unlock the user record's hashed passwords.
tammi 26 07:36:53 r7-5700g systemd-homed[794]: Activation failed: Required key not available
tammi 26 07:36:53 r7-5700g systemd-homed[794]: jukka: changing state activating-for-acquire → inactive
tammi 26 07:36:53 r7-5700g systemd-homed[794]: Got notification that all sessions of user jukka ended, deactivating automatically.
tammi 26 07:36:53 r7-5700g systemd-homed[794]: Home jukka already deactivated, no automatic deactivation needed.
tammi 26 07:36:53 r7-5700g sddm-helper[1843]: [PAM] Preparing to converse...
tammi 26 07:36:53 r7-5700g sddm-helper[1843]: [PAM] Conversation with 1 messages
tammi 26 07:36:53 r7-5700g systemd-homed[794]: jukka: changing state inactive → activating-for-acquire
tammi 26 07:36:53 r7-5700g systemd-homework[1845]: Provided password unlocks user record.
tammi 26 07:36:53 r7-5700g systemd-homework[1845]: Setting up loopback device /dev/disk/by-uuid/ddd9773b-568e-4dd3-8684-ce641f460a4b completed.
tammi 26 07:36:54 r7-5700g kernel: device-mapper: uevent: version 1.0.3
tammi 26 07:36:54 r7-5700g kernel: device-mapper: ioctl: 4.45.0-ioctl (2021-03-22) initialised: dm-devel@redhat.com
tammi 26 07:36:54 r7-5700g kernel: Key type encrypted registered
tammi 26 07:36:54 r7-5700g kernel: BTRFS: device label jukka devid 1 transid 139150 /dev/dm-0 scanned by systemd-udevd (1848)
tammi 26 07:36:54 r7-5700g systemd-homework[1845]: Setting up LUKS device /dev/mapper/home-jukka completed.
tammi 26 07:36:54 r7-5700g systemd-homework[1845]: Provided password unlocks user record.
tammi 26 07:36:54 r7-5700g systemd-homework[1845]: Probing file system completed (found btrfs).
tammi 26 07:36:54 r7-5700g systemd-homework[1845]: File system check completed.
tammi 26 07:36:54 r7-5700g kernel: BTRFS info (device dm-0): flagging fs with big metadata feature
tammi 26 07:36:54 r7-5700g kernel: BTRFS info (device dm-0): use zstd compression, level 1
tammi 26 07:36:54 r7-5700g kernel: BTRFS info (device dm-0): turning on sync discard
tammi 26 07:36:54 r7-5700g kernel: BTRFS info (device dm-0): disk space caching is enabled
tammi 26 07:36:54 r7-5700g kernel: BTRFS info (device dm-0): has skinny extents
tammi 26 07:36:54 r7-5700g systemd-homework[1845]: Mounting file system completed.
tammi 26 07:36:54 r7-5700g kernel: BTRFS info (device dm-0): enabling ssd optimizations
tammi 26 07:36:57 r7-5700g systemd-timesyncd[781]: Initial synchronization to time server 193.104.37.238:123 (2.manjaro.pool.ntp.org).
tammi 26 07:36:58 r7-5700g systemd[1]: systemd-hostnamed.service: Deactivated successfully.
tammi 26 07:36:58 r7-5700g audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='unit=systemd-hostnamed comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
tammi 26 07:36:58 r7-5700g kernel: audit: type=1131 audit(1643175418.199:116): pid=1 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='unit=systemd-hostnamed comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
tammi 26 07:36:58 r7-5700g audit: BPF prog-id=0 op=UNLOAD
tammi 26 07:36:58 r7-5700g audit: BPF prog-id=0 op=UNLOAD
tammi 26 07:36:58 r7-5700g audit: BPF prog-id=0 op=UNLOAD
tammi 26 07:36:58 r7-5700g kernel: audit: type=1334 audit(1643175418.309:117): prog-id=0 op=UNLOAD
tammi 26 07:36:58 r7-5700g kernel: audit: type=1334 audit(1643175418.309:118): prog-id=0 op=UNLOAD
tammi 26 07:36:58 r7-5700g kernel: audit: type=1334 audit(1643175418.309:119): prog-id=0 op=UNLOAD
tammi 26 07:37:02 r7-5700g systemd-homework[1845]: Discarded unused 835.3G.
tammi 26 07:37:02 r7-5700g systemd-homework[1845]: Operating on partition device /dev/disk/by-uuid/ddd9773b-568e-4dd3-8684-ce641f460a4b, using parent device.
tammi 26 07:37:02 r7-5700g systemd-homework[1845]: Discovered used loopback device (null).
tammi 26 07:37:02 r7-5700g systemd-homework[1845]: offset = 1048576, size = 1000203820544, image = 1000204886016
tammi 26 07:37:02 r7-5700g systemd-homework[1845]: New partition doesn't fit into backing storage, refusing.
tammi 26 07:37:09 r7-5700g systemd-homework[1845]: Discarded unused 2.8G.
tammi 26 07:37:09 r7-5700g systemd-homed[794]: block device /sys/devices/virtual/block/dm-0 has been removed.
tammi 26 07:37:09 r7-5700g systemd-homed[794]: block device /sys/devices/virtual/block/dm-0 has been removed.
tammi 26 07:37:09 r7-5700g systemd-homed[794]: Activation failed: Invalid argument
tammi 26 07:37:09 r7-5700g systemd-homed[794]: jukka: changing state activating-for-acquire → inactive
tammi 26 07:37:09 r7-5700g systemd-homed[794]: Got notification that all sessions of user jukka ended, deactivating automatically.
tammi 26 07:37:09 r7-5700g sddm-helper[1843]: pam_systemd_home(sddm:auth): Failed to acquire home for user jukka: Failed to execute operation: Invalid argument
tammi 26 07:37:09 r7-5700g systemd-homed[794]: Home jukka already deactivated, no automatic deactivation needed.
tammi 26 07:37:09 r7-5700g sddm-helper[1843]: [PAM] Preparing to converse...
tammi 26 07:37:09 r7-5700g sddm-helper[1843]: [PAM] Conversation with 1 messages
tammi 26 07:37:09 r7-5700g sddm-helper[1843]: gkr-pam: unable to locate daemon control file
tammi 26 07:37:09 r7-5700g sddm-helper[1843]: gkr-pam: stashed password to try later in open session
tammi 26 07:37:09 r7-5700g sddm-helper[1843]: pam_kwallet5(sddm:auth): pam_kwallet5: pam_sm_authenticate
tammi 26 07:37:09 r7-5700g audit[1843]: USER_AUTH pid=1843 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='op=PAM:authentication grantors=pam_shells,pam_faillock,pam_permit,pam_faillock,pam_gnome_keyring acct="jukka" exe="/usr/lib/sddm/sddm-helper" hostname=? addr=? terminal=? res=success'
tammi 26 07:37:09 r7-5700g sddm-helper[1843]: [PAM] returning.
tammi 26 07:37:09 r7-5700g kernel: audit: type=1100 audit(1643175429.879:120): pid=1843 uid=0 auid=4294967295 ses=4294967295 subj==unconfined msg='op=PAM:authentication grantors=pam_shells,pam_faillock,pam_permit,pam_faillock,pam_gnome_keyring acct="jukka" exe="/usr/lib/sddm/sddm-helper" hostname=? addr=? terminal=? res=success'
tammi 26 07:37:09 r7-5700g systemd-homed[794]: jukka: changing state inactive → activating-for-acquire
tammi 26 07:37:09 r7-5700g systemd-homework[1895]: None of the supplied plaintext passwords unlock the user record's hashed passwords.
tammi 26 07:37:09 r7-5700g systemd-homed[794]: Activation failed: Required key not available
tammi 26 07:37:09 r7-5700g systemd-homed[794]: jukka: changing state activating-for-acquire → inactive
tammi 26 07:37:09 r7-5700g systemd-homed[794]: Got notification that all sessions of user jukka ended, deactivating automatically.
tammi 26 07:37:09 r7-5700g systemd-homed[794]: Home jukka already deactivated, no automatic deactivation needed.
tammi 26 07:37:09 r7-5700g sddm-helper[1843]: [PAM] Preparing to converse...
tammi 26 07:37:09 r7-5700g sddm-helper[1843]: [PAM] Conversation with 1 messages

I checked the pam.d configurations after noticing the sddm-helper and pam activity coming up unlike the first home activation and there was no difference in pam.d configurations that relate to sddm login.

After noticing this I did a freshly installed kvm machine of Manjaro and Arch Linux with newest packages to both of which I provided two 20G disks and made a RAID1 out of them as /dev/md/home. On both of them I noticed that when I mount the user home, I have the following:

[root@arch-homed ~]# lsblk -o +FSTYPE,UUID
NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS FSTYPE            UUID
sr0          11:0    1 864.3M  0 rom               iso9660           2022-01-01-10-11-06-00
zram0       253:0    0 986.5M  0 disk  [SWAP]                        
vda         254:0    0    80G  0 disk                                
├─vda1      254:1    0   484M  0 part  /boot       vfat              9144-A9E3
└─vda2      254:2    0  79.5G  0 part  /           btrfs             04db9194-facd-4920-b3d7-77b23fadabdc
vdb         254:16   0    20G  0 disk              linux_raid_member b0b8e30c-0799-6dcc-8a63-2d06a4e8c88c
└─md127       9:127  0    20G  0 raid1                               
  └─md127p1 259:0    0    20G  0 part              crypto_LUKS       9a5c59f3-963b-496d-870e-31a9e6be867a
vdc         254:32   0    20G  0 disk              linux_raid_member b0b8e30c-0799-6dcc-8a63-2d06a4e8c88c
└─md127       9:127  0    20G  0 raid1                               
  └─md127p1 259:0    0    20G  0 part              crypto_LUKS       9a5c59f3-963b-496d-870e-31a9e6be867a
[root@arch-homed ~]# cryptsetup open /dev/md/home1 home-jpalko
Enter passphrase for /dev/md/home1:
[root@arch-homed ~]# mount /dev/mapper/home-jpalko /mnt/
[root@arch-homed ~]# ls -larth /mnt/
total 32K
drwxr-xr-x 1 root   root   142 Jan 26 10:41 ..
drwxr-xr-x 1 root   root    12 Jan 26 19:05 .
drwx------ 1 nobody nobody  82 Jan 26 19:05 jpalko
[root@arch-homed ~]# ls -larth /mnt/jpalko/
total 32K
-rw-r--r-- 1 nobody nobody 141 Jan  8 20:31 .bashrc
-rw-r--r-- 1 nobody nobody  57 Jan  8 20:31 .bash_profile
-rw-r--r-- 1 nobody nobody  21 Jan  8 20:31 .bash_logout
drwxr-xr-x 1 root   root    12 Jan 26 19:05 ..
-rw------- 1 nobody nobody 831 Jan 26 19:05 .identity
drwx------ 1 nobody nobody  82 Jan 26 19:05 .

The user creation on both was done via:

homectl create jpalko -c "Jukka Palko" -G wheel,lp,network,scanner,power --shell=/bin/zsh --storage=luks --image-path=/dev/md/home --fs-type=btrfs

I also tried making the home using the device /dev/disk/by-id/md-uuid-b0b8e30c\:07996dcc\:8a632d06\:a4e8c88c on the Arch host and it doesn't make any difference.

@mrblumi
Copy link

mrblumi commented Feb 11, 2022

Same issue here, seems to be related with btrfs. If i run below command with --fs-type=ext4 everything works fine

systemd version

systemd 250 (250.3-4-arch)
+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 -BPF_FRAMEWORK +XKBCOMMON +UTMP -SYSVINIT default-hierarchy=unified

Used distro

Arch Linux (x86_64)

Linux kernel version

Linux test 5.16.8-arch1-1 #1 SMP PREEMPT Tue, 08 Feb 2022 21:21:08 +0000 x86_64 GNU/Linux

CPU architecture

x86_64

Steps to reproduce

homectl create foo --image-path=/dev/sdb --storage=luks --fs-type=btrfs
homectl authenticate foo

journalctl -xeu systemd-homed

Feb 11 15:43:35 test systemd[1]: Starting Home Area Manager...
░░ Subject: A start job for unit systemd-homed.service has begun execution
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ A start job for unit systemd-homed.service has begun execution.
░░ 
░░ The job identifier is 210.
Feb 11 15:43:35 test systemd-homed[332]: Successfully loaded private key pair.
Feb 11 15:43:35 test systemd-homed[332]: Watching /home.
Feb 11 15:43:35 test systemd[1]: Started Home Area Manager.
░░ Subject: A start job for unit systemd-homed.service has finished successfully
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░ 
░░ A start job for unit systemd-homed.service has finished successfully.
░░ 
░░ The job identifier is 210.
Feb 11 15:43:35 test systemd-homed[332]: Failed to acquire ID_FS_UUID device property, ignoring: No such file or directory
Feb 11 15:43:51 test systemd-homed[332]: foo: changing state inactive → creating
Feb 11 15:43:51 test systemd-homework[384]: Full device discard completed.
Feb 11 15:43:51 test systemd-homework[384]: Writing of partition table completed.
Feb 11 15:43:51 test systemd-homework[384]: Setting up loopback device /dev/loop0 completed.
Feb 11 15:43:53 test systemd-homework[384]: LUKS formatting completed.
Feb 11 15:43:54 test systemd-homework[384]: Writing password to LUKS keyslot 0 completed.
Feb 11 15:43:54 test systemd-homework[384]: LUKS activation by volume key succeeded.
Feb 11 15:43:54 test systemd-homework[384]: Writing user record as LUKS token completed.
Feb 11 15:43:54 test systemd-homework[384]: Setting up LUKS device /dev/mapper/home-foo completed.
Feb 11 15:43:55 test systemd-homed[393]: WARNING: failed to open /dev/btrfs-control, skipping device registration: Operation not permitted
Feb 11 15:43:55 test systemd-homed[393]: NOTE: several default settings have changed in version 5.15, please make sure
Feb 11 15:43:55 test systemd-homed[393]:       this does not affect your deployments:
Feb 11 15:43:55 test systemd-homed[393]:       - DUP for metadata (-m dup)
Feb 11 15:43:55 test systemd-homed[393]:       - enabled no-holes (-O no-holes)
Feb 11 15:43:55 test systemd-homed[393]:       - enabled free-space-tree (-R free-space-tree)
Feb 11 15:43:55 test systemd-homework[384]: /dev/mapper/home-foo successfully formatted as btrfs (label "foo", uuid f9bb3fc7-79b1-46de-a65d-3ecd0f101175)
Feb 11 15:43:55 test systemd-homework[384]: Formatting file system completed.
Feb 11 15:43:55 test systemd-homework[384]: Mounting file system completed.
Feb 11 15:43:55 test systemd-homework[384]: Copying in /etc/skel completed.
Feb 11 15:43:55 test systemd-homework[384]: Wrote embedded .identity file.
Feb 11 15:43:55 test systemd-homework[384]: Recursive changing of ownership completed.
Feb 11 15:43:55 test systemd-homework[384]: Changed top-level directory access mode to 0700.
Feb 11 15:43:55 test systemd-homework[384]: Synchronized disk.
Feb 11 15:43:55 test systemd-homed[332]: block device /sys/devices/virtual/block/dm-2 has been removed.
Feb 11 15:43:55 test systemd-homed[332]: block device /sys/devices/virtual/block/dm-2 has been removed.
Feb 11 15:43:55 test systemd-homed[332]: block device /sys/devices/virtual/block/loop0 has been removed.
Feb 11 15:43:55 test systemd-homework[384]: Watching /dev/disk/by-uuid
Feb 11 15:43:55 test systemd-homework[384]: Watching /dev/disk/by-uuid
Feb 11 15:43:55 test systemd-homework[384]: Creation completed.
Feb 11 15:43:55 test systemd-homework[384]: Image size is 5.0G, file system size is 4.9G, file system payload size is 4.9G, file system free is 4.9G.
Feb 11 15:43:55 test systemd-homed[332]: foo: changing state creating → inactive
Feb 11 15:44:01 test systemd-homed[332]: foo: changing state inactive → activating
Feb 11 15:44:01 test systemd-homework[433]: None of the supplied plaintext passwords unlock the user record's hashed passwords.
Feb 11 15:44:01 test systemd-homed[332]: Activation failed: Required key not available
Feb 11 15:44:01 test systemd-homed[332]: foo: changing state activating → inactive
Feb 11 15:44:02 test systemd-homed[332]: foo: changing state inactive → activating
Feb 11 15:44:03 test systemd-homework[434]: Provided password unlocks user record.
Feb 11 15:44:03 test systemd-homework[434]: Setting up loopback device /dev/disk/by-uuid/ee7f8a9d-b80d-422c-9357-c1df6cb8f4ce completed.
Feb 11 15:44:03 test systemd-homework[434]: Setting up LUKS device /dev/mapper/home-foo completed.
Feb 11 15:44:03 test systemd-homework[434]: Provided password unlocks user record.
Feb 11 15:44:03 test systemd-homework[434]: Probing file system completed (found btrfs).
Feb 11 15:44:03 test systemd-homework[434]: File system check completed.
Feb 11 15:44:03 test systemd-homework[434]: Mounting file system completed.
Feb 11 15:44:03 test systemd-homework[434]: Discarded unused 4.9G.
Feb 11 15:44:03 test systemd-homework[434]: Operating on partition device /dev/disk/by-uuid/ee7f8a9d-b80d-422c-9357-c1df6cb8f4ce, using parent device.
Feb 11 15:44:03 test systemd-homework[434]: Discovered used loopback device (null).
Feb 11 15:44:03 test systemd-homework[434]: offset = 1048576, size = 5366611968, image = 5368709120
Feb 11 15:44:03 test systemd-homework[434]: New partition doesn't fit into backing storage, refusing.
Feb 11 15:44:03 test systemd-homework[434]: Discarded unused 535.5M.
Feb 11 15:44:03 test systemd-homed[332]: Activation failed: Invalid argument
Feb 11 15:44:03 test systemd-homed[332]: foo: changing state activating → inactive
Feb 11 15:44:03 test systemd-homed[332]: block device /sys/devices/virtual/block/dm-2 has been removed.
Feb 11 15:44:03 test systemd-homed[332]: block device /sys/devices/virtual/block/dm-2 has been removed.

homectl inspect foo

   User name: foo
       State: inactive
 Disposition: regular
 Last Change: Fri 2022-02-11 15:43:48 CET
    Login OK: yes
 Password OK: yes
         UID: 60269
         GID: 60269 (foo)
   Directory: /home/foo
     Storage: luks (strong encryption)
  Image Path: /dev/disk/by-uuid/ee7f8a9d-b80d-422c-9357-c1df6cb8f4ce
   Removable: yes
       Shell: /bin/bash
LUKS Discard: online=yes offline=yes
   LUKS UUID: ee7f8a9d-b80d-422c-9357-c1df6cb8f4ce
   Part UUID: bd8cc017-f3d0-436f-8390-c0b7ef23ce48
     FS UUID: f9bb3fc7-79b1-46de-a65d-3ecd0f101175
 File System: btrfs
 LUKS Cipher: aes
 Cipher Mode: xts-plain64
  Volume Key: 256bit
 Mount Flags: nosuid nodev exec
   Disk Size: 4.9G
  Disk Floor: 256.0M
Disk Ceiling: 5.0T
   Bad Auth.: 1
    Last Bad: Fri 2022-02-11 15:44:01 CET
    Next Try: anytime
 Auth. Limit: 30 attempts per 1min
   Passwords: 1
  Local Sig.: yes
     Service: io.systemd.Home

@FrankNoWar
Copy link

Hello! I found a workaround on my x64 Arch Linux box. I simply added the btrfs module to my initcpio (mkinitcpio in my case).
I know that this is might not be a real solution but it solved the problem for me.
I think it has something to do with trying to mount a btrfs partition before the module is fully loaded.

@mrblumi
Copy link

mrblumi commented Feb 27, 2022

Unfortunately this does not work on my x64 Arch setup...

former /etc/mkinitcpio.conf

MODULES=""
BINARIES=""
FILES=""
HOOKS="base systemd autodetect modconf keyboard sd-vconsole sd-encrypt block filesystems fsck"

Tried adding 'btrfs' hook as well as 'btrfs' module and 'btrfs' and 'btrfsck' binaries instead (which is more or less what btrfs hook does in install section). Nothing helped. Still user 'foo' is not able to login with its home directory decrypted...

@jpalko
Copy link

jpalko commented Feb 28, 2022

I doubt any delay in btrfs module loading is the issue for myself as my root filesystem is btrfs .

@Vaelio
Copy link

Vaelio commented Mar 9, 2022

Hello! I found a workaround on my x64 Arch Linux box. I simply added the btrfs module to my initcpio (mkinitcpio in my case). I know that this is might not be a real solution but it solved the problem for me. I think it has something to do with trying to mount a btrfs partition before the module is fully loaded.

Hi,
Could you post your mkinitcpio.conf ? I tried aswell and it doesn't work. Weird thing is that i have another computer running ARCH aswell and with same version of systemd that works.

@FrankNoWar
Copy link

FrankNoWar commented Mar 10, 2022

Hi, Could you post your mkinitcpio.conf ? I tried aswell and it doesn't work. Weird thing is that i have another computer running ARCH aswell and with same version of systemd that works.

Here it is. Looking back, I think my partitions needed to be created with the module loaded by mkinitcpio.

# MODULES
MODULES=(btrfs nvidia nvidia_modeset nvidia_uvm nvidia_drm)

# BINARIES
BINARIES=()

# FILES
FILES=()

# HOOKS
HOOKS=(base udev plymouth autodetect modconf block keyboard zfs filesystems resume strip)

# COMPRESSION
COMPRESSION="zstd"

# COMPRESSION_OPTIONS
#COMPRESSION_OPTIONS=()

Edit:

Almost forgot to mention - my homed backing devices are ZFS ZVols.

@heipa0
Copy link

heipa0 commented Apr 2, 2022

Yesterday I updated my openSUSE Tumbleweed and since then I am having the exact same issue.

My home is on a dedicated SSD (256GB, /dev/sdb, Luks, Btrfs).

Before the update (everything was working fine):

systemd 249 (249.7+suse.57.g523f32df57)
+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

Linux os 5.15.12-1-default #1 SMP Wed Dec 29 14:50:16 UTC 2021 (375fcb8) x86_64 x86_64 x86_64 GNU/Linux

After the update (Error: New partition doesn't fit):

systemd 250 (250.4+suse.35.g8ef8dfd540)
+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 -BPF_FRAMEWORK -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified

Linux os 5.17.1-1-default #1 SMP PREEMPT Thu Mar 31 05:28:33 UTC 2022 (58205bc) x86_64 x86_64 x86_64 GNU/Linux

I have a snapshot from before and after the update. So I can compare this two if anyone needs more information...

@heipa0
Copy link

heipa0 commented Apr 2, 2022

I also noticed a second issue which, I think, is related because it also only happened after the update.

When I login with my guest user (10 GB, /home/guest.home, Luks, Btrfs) I get a warning that my / is full.

Before I login with my guest account:

Filesystem	Size	Used	Avail	Use%	Mounted on
/dev/sda2	118G	19G	93	17%	/
…

After I login with my guest account:

Filesystem	Size	Used	Avail	Use%	Mounted on
/dev/sda2	118G	113G	0	100%	/
…

But its not full. I still can write on / .

@jpalko
Copy link

jpalko commented Apr 2, 2022

@heipa0 That can also be caused by LUKS discard settings.
See for example: [SOLVED] systemd-homed:"Authentication failed:No space left on device"

@heipa0
Copy link

heipa0 commented Apr 2, 2022

@jpalko Thanks for the link!

homectl update --luks-discard=on guest indeed solved the issue with the guest account. However the posts mention that its not recommended and a bit risky. Do I need to worry?

The main issue with my own home on the dedicated disk is not solved by that.

@jpalko
Copy link

jpalko commented Apr 2, 2022

@heipa0 I've had to leave it on for my LUKS image file home directories so that I don't keep bumping into the issue and thus far I've had no problems caused by it. The man page of homectl describes that the over-committing of the filesystem containing /home directory to be the main reason which you propably won't run into in a single user system.

Let's however keep this thread on topic which remains present for my systems as well.

@LEW21
Copy link

LEW21 commented Jun 18, 2022

This has broken my system after update to Fedora Workstation 36. (Of course, systemd-homed isn't really supported there.)

As a workaround, I had to disable systemd-homed completely, switch to traditional /etc/passwd (add my user and group there), and mount the home dir manually, as root, before signing in:

cryptsetup open /dev/sda1 home-linus
mount /dev/mapper/home-linus /mnt
mount -B /mnt/linus /home/linus

@macedigital
Copy link

I encountered the same issue on ArchLinux using a (external) disk with btrfs as the underlying filesystem having the current ArchLinux packages (systemd 251.2-1 and pam 1.5.2-1) installed.

What fixed the problem for me was to disable the implicit auto-resize-mode=shrink-and-grow that is enabled when using LUKS2/btrfs. After executing homectl update $USERNAME --auto-resize-mode=off, mounting of the user folder works as expected when I log in. I didn't have to change the discard settings at all.

$ homectl inspect $USERNAME
// ... other settings
  Image Path: /dev/disk/by-uuid/c17e67a8-3b9a-48a9-9154-a5a311acb61f
   Removable: yes
LUKS Discard: online=yes offline=yes
// ... other settings
 Auto Resize: off

If you also see this error in your logs (and using a dedicated block device for a given user) check if adjusting the affected home zone with the flag --auto-resize-mode=off fixes the issue.

@mrblumi
Copy link

mrblumi commented Jun 25, 2022

Great, works like a charm. Thanks alot

@gibeom-gwon
Copy link
Contributor

I did bisect, the issue occurred since 2619100 commit.

@yuwata yuwata added this to the v252 milestone Oct 18, 2022
@gibeom-gwon
Copy link
Contributor

I found something suspicious.

new_partition_size_rounded = DISK_SIZE_ROUND_DOWN(h->disk_size);
if (setup->partition_size >= new_partition_size_rounded &&
setup->partition_size <= h->disk_size) {
log_info("Partition size already matching, skipping operation.");
return 0;
}
new_partition_size = new_partition_size_rounded;
intention = CMP(new_partition_size, setup->partition_size);
}
}
if ((UINT64_MAX - setup->partition_offset) < new_partition_size ||
setup->partition_offset + new_partition_size > new_image_size)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "New partition doesn't fit into backing storage, refusing.");

The h->disk_size variable in my system has UINT64_MAX. It looks like a default value when --disk-size option was not used. So it need to be handled separately if h->disk_size == UNIT64_MAX I think. @poettering @yuwata

gibeom-gwon added a commit to gibeom-gwon/systemd that referenced this issue Oct 19, 2022
If the backing storage is LUKS2 on a block device, auto resize mode
is enabled, and disk size is not specified, resize the partition to
the maximum expandable size.

Fixes: systemd#22255, systemd#23967
gibeom-gwon added a commit to gibeom-gwon/systemd that referenced this issue Oct 19, 2022
If the backing storage is LUKS2 on a block device, auto resize mode
is enabled, and disk size is not specified, resize the partition to
the maximum expandable size.

Fixes: systemd#22255, systemd#23967
gibeom-gwon added a commit to gibeom-gwon/systemd that referenced this issue Oct 19, 2022
If the backing storage is LUKS2 on a block device, auto resize mode
is enabled, and disk size is not specified, resize the partition to
the maximum expandable size.

Fixes: systemd#22255, systemd#23967
gibeom-gwon added a commit to gibeom-gwon/systemd that referenced this issue Oct 19, 2022
If the backing storage is LUKS2 on a block device, auto resize mode
is enabled, and disk size is not specified, resize the partition to
the maximum expandable size.

Fixes: systemd#22255, systemd#23967
gibeom-gwon added a commit to gibeom-gwon/systemd that referenced this issue Oct 19, 2022
If the backing storage is LUKS2 on a block device, auto resize mode
is enabled, and disk size is not specified, resize the partition to
the maximum expandable size.

Fixes: systemd#22255, systemd#23967
gibeom-gwon added a commit to gibeom-gwon/systemd that referenced this issue Oct 21, 2022
If the backing storage is LUKS2 on a block device, auto resize mode
is enabled, and disk size is not specified, resize the partition to
the maximum expandable size.

Fixes: systemd#22255, systemd#23967
gibeom-gwon added a commit to gibeom-gwon/systemd that referenced this issue Oct 24, 2022
If the backing storage is LUKS2 on a block device, auto resize mode
is enabled, and disk size is not specified, resize the partition to
the maximum expandable size.

Fixes: systemd#22255, systemd#23967
@bluca bluca modified the milestones: v252, v253 Oct 31, 2022
pimzero added a commit to pimzero/systemd that referenced this issue Nov 20, 2022
This commit enable homework-luks to create a user home partition on an
existing partition. This allows us to have multiple user home partitions
on a single disk, or share user home partitions with the system
partitions.

This commit address systemd#15273 for "vanilla" partitions
Partitions on LVM have not been tested.

This works by getting the parent block device of the selected partition,
and if it has a GPT partition table, edit the partition table entry and
format the partition as a per-user home partition.

Testing:

```
$ sudo mkosi --force build
[...]
$ truncate -s 16G ./mkosi.output/arch~rolling/image.raw && sfdisk -a ./mkosi.output/arch~rolling/image.raw <<EOF
label: gpt
device: /dev/sda
unit: sectors
sector-size: 512

/dev/sda3 : size=8G, uuid=$(systemd-id128 new -u), name=test
EOF
$ sudo mkosi qemu
[...]
[root@archlinux ~]# NEWPASSWORD=APassword111 homectl create user1 --storage=luks --image-path=/dev/sda3 --fs-type=ext4 # Testing with ext4 because of systemd#22255
[root@archlinux ~]# homectl activate user1
[root@archlinux ~]# su user1
[user1@archlinux root]$ cd
[user1@archlinux ~]$ lsblk
NAME           MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINTS
sda              8:0    0   16G  0 disk
├─sda1           8:1    0  256M  0 part
├─sda2           8:2    0    3G  0 part  /
└─sda3           8:3    0    8G  0 part
  └─home-user1 254:0    0    8G  0 crypt /home/user1
```
pimzero added a commit to pimzero/systemd that referenced this issue Nov 20, 2022
This commit enable homework-luks to create a user home partition on an
existing partition. This allows us to have multiple user home partitions
on a single disk, or share user home partitions with the system
partitions.

This commit address systemd#15273 for "vanilla" partitions
Partitions on LVM have not been tested.

This works by getting the parent block device of the selected partition,
and if it has a GPT partition table, edit the partition table entry and
format the partition as a per-user home partition.

Testing:

```
$ sudo mkosi --force build
[...]
$ truncate -s 16G ./mkosi.output/arch~rolling/image.raw && sfdisk -a ./mkosi.output/arch~rolling/image.raw <<EOF
label: gpt
device: /dev/sda
unit: sectors
sector-size: 512

/dev/sda3 : size=8G, uuid=$(systemd-id128 new -u), name=test
EOF
$ sudo mkosi qemu
[...]
[root@archlinux ~]# NEWPASSWORD=APassword111 homectl create user1 --storage=luks --image-path=/dev/sda3 --fs-type=ext4 # Testing with ext4 because of systemd#22255
[root@archlinux ~]# homectl activate user1
[root@archlinux ~]# su user1
[user1@archlinux root]$ cd
[user1@archlinux ~]$ lsblk
NAME           MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINTS
sda              8:0    0   16G  0 disk
├─sda1           8:1    0  256M  0 part
├─sda2           8:2    0    3G  0 part  /
└─sda3           8:3    0    8G  0 part
  └─home-user1 254:0    0    8G  0 crypt /home/user1
```
pimzero added a commit to pimzero/systemd that referenced this issue Nov 28, 2022
This commit enable homework-luks to create a user home partition on an
existing partition. This allows us to have multiple user home partitions
on a single disk, or share user home partitions with the system
partitions.

This commit address systemd#15273 for "vanilla" partitions
Partitions on LVM have not been tested.

This works by getting the parent block device of the selected partition,
and if it has a GPT partition table, edit the partition table entry and
format the partition as a per-user home partition.

Testing:

```
$ sudo mkosi --force build
[...]
$ truncate -s 16G ./mkosi.output/arch~rolling/image.raw && sfdisk -a ./mkosi.output/arch~rolling/image.raw <<EOF
label: gpt
device: /dev/sda
unit: sectors
sector-size: 512

/dev/sda3 : size=8G, uuid=$(systemd-id128 new -u), name=test
EOF
$ sudo mkosi qemu
[...]
[root@archlinux ~]# NEWPASSWORD=APassword111 homectl create user1 --storage=luks --image-path=/dev/sda3 --fs-type=ext4 # Testing with ext4 because of systemd#22255
[root@archlinux ~]# homectl activate user1
[root@archlinux ~]# su user1
[user1@archlinux root]$ cd
[user1@archlinux ~]$ lsblk
NAME           MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINTS
sda              8:0    0   16G  0 disk
├─sda1           8:1    0  256M  0 part
├─sda2           8:2    0    3G  0 part  /
└─sda3           8:3    0    8G  0 part
  └─home-user1 254:0    0    8G  0 crypt /home/user1
```
pimzero added a commit to pimzero/systemd that referenced this issue Nov 28, 2022
This commit enable homework-luks to create a user home partition on an
existing partition. This allows us to have multiple user home partitions
on a single disk, or share user home partitions with the system
partitions.

This commit address systemd#15273 for "vanilla" partitions
Partitions on LVM have not been tested.

This works by getting the parent block device of the selected partition,
and if it has a GPT partition table, edit the partition table entry and
format the partition as a per-user home partition.

Testing:

```
$ sudo mkosi --force build
[...]
$ truncate -s 16G ./mkosi.output/arch~rolling/image.raw && sfdisk -a ./mkosi.output/arch~rolling/image.raw <<EOF
label: gpt
device: /dev/sda
unit: sectors
sector-size: 512

/dev/sda3 : size=8G, uuid=$(systemd-id128 new -u), name=test
EOF
$ sudo mkosi qemu
[...]
[root@archlinux ~]# NEWPASSWORD=APassword111 homectl create user1 --storage=luks --image-path=/dev/sda3 --fs-type=ext4 # Testing with ext4 because of systemd#22255
[root@archlinux ~]# homectl activate user1
[root@archlinux ~]# su user1
[user1@archlinux root]$ cd
[user1@archlinux ~]$ lsblk
NAME           MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINTS
sda              8:0    0   16G  0 disk
├─sda1           8:1    0  256M  0 part
├─sda2           8:2    0    3G  0 part  /
└─sda3           8:3    0    8G  0 part
  └─home-user1 254:0    0    8G  0 crypt /home/user1
```
pimzero added a commit to pimzero/systemd that referenced this issue Nov 28, 2022
This commit enable homework-luks to create a user home partition on an
existing partition. This allows us to have multiple user home partitions
on a single disk, or share user home partitions with the system
partitions.

This commit address systemd#15273 for "vanilla" partitions
Partitions on LVM have not been tested.

This works by getting the parent block device of the selected partition,
and if it has a GPT partition table, edit the partition table entry and
format the partition as a per-user home partition.

Testing:

```
$ sudo mkosi --force build
[...]
$ truncate -s 16G ./mkosi.output/arch~rolling/image.raw && sfdisk -a ./mkosi.output/arch~rolling/image.raw <<EOF
label: gpt
device: /dev/sda
unit: sectors
sector-size: 512

/dev/sda3 : size=8G, uuid=$(systemd-id128 new -u), name=test
EOF
$ sudo mkosi qemu
[...]
[root@archlinux ~]# NEWPASSWORD=APassword111 homectl create user1 --storage=luks --image-path=/dev/sda3 --fs-type=ext4 # Testing with ext4 because of systemd#22255
[root@archlinux ~]# homectl activate user1
[root@archlinux ~]# su user1
[user1@archlinux root]$ cd
[user1@archlinux ~]$ lsblk
NAME           MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINTS
sda              8:0    0   16G  0 disk
├─sda1           8:1    0  256M  0 part
├─sda2           8:2    0    3G  0 part  /
└─sda3           8:3    0    8G  0 part
  └─home-user1 254:0    0    8G  0 crypt /home/user1
```
pimzero added a commit to pimzero/systemd that referenced this issue Nov 28, 2022
This commit enable homework-luks to create a user home partition on an
existing partition. This allows us to have multiple user home partitions
on a single disk, or share user home partitions with the system
partitions.

This commit address systemd#15273 for "vanilla" partitions
Partitions on LVM have not been tested.

This works by getting the parent block device of the selected partition,
and if it has a GPT partition table, edit the partition table entry and
format the partition as a per-user home partition.

Testing:

```
$ sudo mkosi --force build
[...]
$ truncate -s 16G ./mkosi.output/arch~rolling/image.raw && sfdisk -a ./mkosi.output/arch~rolling/image.raw <<EOF
label: gpt
device: /dev/sda
unit: sectors
sector-size: 512

/dev/sda3 : size=8G, uuid=$(systemd-id128 new -u), name=test
EOF
$ sudo mkosi qemu
[...]
[root@archlinux ~]# NEWPASSWORD=APassword111 homectl create user1 --storage=luks --image-path=/dev/sda3 --fs-type=ext4 # Testing with ext4 because of systemd#22255
[root@archlinux ~]# homectl activate user1
[root@archlinux ~]# su user1
[user1@archlinux root]$ cd
[user1@archlinux ~]$ lsblk
NAME           MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINTS
sda              8:0    0   16G  0 disk
├─sda1           8:1    0  256M  0 part
├─sda2           8:2    0    3G  0 part  /
└─sda3           8:3    0    8G  0 part
  └─home-user1 254:0    0    8G  0 crypt /home/user1
```
@yuwata yuwata modified the milestones: v253, v254 Feb 2, 2023
gibeom-gwon added a commit to gibeom-gwon/systemd that referenced this issue Jun 18, 2023
If the backing storage is LUKS2 on a block device, auto resize mode
is enabled, and disk size is not specified, resize the partition to
the maximum expandable size.

Fixes: systemd#22255, systemd#23967
poettering pushed a commit that referenced this issue Jun 19, 2023
If the backing storage is LUKS2 on a block device, auto resize mode
is enabled, and disk size is not specified, resize the partition to
the maximum expandable size.

Fixes: #22255, #23967
valentindavid pushed a commit to valentindavid/systemd that referenced this issue Aug 8, 2023
If the backing storage is LUKS2 on a block device, auto resize mode
is enabled, and disk size is not specified, resize the partition to
the maximum expandable size.

Fixes: systemd#22255, systemd#23967
(cherry picked from commit 5bfc4de)
(cherry picked from commit d682e09)
(cherry picked from commit aca5356)
pimzero added a commit to pimzero/systemd that referenced this issue Sep 8, 2023
This commit enable homework-luks to create a user home partition on an
existing partition. This allows us to have multiple user home partitions
on a single disk, or share user home partitions with the system
partitions.

This commit address systemd#15273 for "vanilla" partitions
Partitions on LVM have not been tested.

This works by getting the parent block device of the selected partition,
and if it has a GPT partition table, edit the partition table entry and
format the partition as a per-user home partition.

Testing:

```
$ sudo mkosi --force build
[...]
$ truncate -s 16G ./mkosi.output/arch~rolling/image.raw && sfdisk -a ./mkosi.output/arch~rolling/image.raw <<EOF
label: gpt
device: /dev/sda
unit: sectors
sector-size: 512

/dev/sda3 : size=8G, uuid=$(systemd-id128 new -u), name=test
EOF
$ sudo mkosi qemu
[...]
[root@archlinux ~]# NEWPASSWORD=APassword111 homectl create user1 --storage=luks --image-path=/dev/sda3 --fs-type=ext4 # Testing with ext4 because of systemd#22255
[root@archlinux ~]# homectl activate user1
[root@archlinux ~]# su user1
[user1@archlinux root]$ cd
[user1@archlinux ~]$ lsblk
NAME           MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINTS
sda              8:0    0   16G  0 disk
├─sda1           8:1    0  256M  0 part
├─sda2           8:2    0    3G  0 part  /
└─sda3           8:3    0    8G  0 part
  └─home-user1 254:0    0    8G  0 crypt /home/user1
```
nmeyerhans pushed a commit to nmeyerhans/systemd that referenced this issue Jan 21, 2024
If the backing storage is LUKS2 on a block device, auto resize mode
is enabled, and disk size is not specified, resize the partition to
the maximum expandable size.

Fixes: systemd#22255, systemd#23967
(cherry picked from commit 5bfc4de)
(cherry picked from commit d682e09)
yuwata pushed a commit to yuwata/systemd that referenced this issue Apr 26, 2024
If the backing storage is LUKS2 on a block device, auto resize mode
is enabled, and disk size is not specified, resize the partition to
the maximum expandable size.

Fixes: systemd#22255, systemd#23967
(cherry picked from commit 5bfc4de)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
homed homed, homectl, pam_homed regression ⚠️ A bug in something that used to work correctly and broke through some recent commit
Development

Successfully merging a pull request may close this issue.