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

Auto-resize of a LUKS + btrfs homed partition doesn't work #23967

Closed
mrc0mmand opened this issue Jul 10, 2022 · 7 comments · Fixed by #25066
Closed

Auto-resize of a LUKS + btrfs homed partition doesn't work #23967

mrc0mmand opened this issue Jul 10, 2022 · 7 comments · Fixed by #25066
Labels
bug 🐛 Programming errors, that need preferential fixing homed homed, homectl, pam_homed
Milestone

Comments

@mrc0mmand
Copy link
Member

mrc0mmand commented Jul 10, 2022

systemd version the issue has been seen with

250.4-2

Used distribution

Arch Linux

Linux kernel version used

No response

CPU architectures issue was seen on

No response

Component

systemd-homed

Expected behaviour you didn't see

homectl activate test1 should successfully activate & mount a LUKS + btrfs home directory

Unexpected behaviour you saw

[ 2255.303239] systemd-homework[4785]: Setting up LUKS device /dev/mapper/home-test1 completed.
[ 2255.305562] systemd-homed[591]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/home1 interface=org.freedesktop.DBus.Properties member=Prope>
[ 2255.311735] systemd-homework[4785]: Provided password unlocks user record.
[ 2255.315177] systemd-homework[4785]: Probing file system completed (found btrfs).
[ 2255.323058] systemd-homework[4785]: File system check completed.
[ 2255.325065] systemd-homework[4785]: Mounting file system completed.
[ 2255.325778] systemd-homework[4785]: Discarded unused 1003.5M.
[ 2255.325833] systemd-homework[4785]: Operating on partition device /dev/disk/by-uuid/35f0350c-a455-4575-b69b-bac5d813b37a, using parent device.
[ 2255.325889] systemd-homework[4785]: Discovered used loopback device (null).
[ 2255.325932] systemd-homework[4785]: offset = 1048576, size = 1070596096, image = 1073741824
[ 2255.325970] systemd-homework[4785]: New partition doesn't fit into backing storage, refusing.

Steps to reproduce the problem

Whilst trying to debug #23740 I noticed a strange behavior when trying to activate a LUKS + btrfs formatted home:

# wipefs -af /dev/vdb
/dev/vdb: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54
/dev/vdb: 8 bytes were erased at offset 0x3ffffe00 (gpt): 45 46 49 20 50 41 52 54
/dev/vdb: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa
# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
loop0    7:0    0  512M  0 loop 
vda    254:0    0  128G  0 disk 
├─vda1 254:1    0    4G  0 part 
└─vda2 254:2    0  124G  0 part /
vdb    254:16   0    1G  0 disk 
# homectl create test1 --image-path=/dev/vdb --storage=luks --fs-type=btrfs
🔐 Please enter new password for user test1: *********               
🔐 Please enter new password for user test1 (repeat): *********
# homectl activate test1
🔐 Please enter password for user test1: *********               
Operation on home test1 failed: Failed to execute operation: Invalid argument
# homectl
NAME  UID   GID   STATE    REALNAME HOME        SHELL    
test1 60510 60510 inactive test1    /home/test1 /bin/bash

1 home areas listed.

which yields mentioned errors in journal:

Jul 10 20:37:29 arch.localdomain systemd-homed[591]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/home1 interface=org.freedesktop.DBus.Prope>
Jul 10 20:37:29 arch.localdomain systemd-homework[5056]: Setting up LUKS device /dev/mapper/home-test1 completed.
Jul 10 20:37:29 arch.localdomain systemd-homed[591]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/home1 interface=org.freedesktop.DBus.Prope>
Jul 10 20:37:29 arch.localdomain systemd-homework[5056]: Provided password unlocks user record.
Jul 10 20:37:29 arch.localdomain systemd-homework[5056]: Probing file system completed (found btrfs).
Jul 10 20:37:29 arch.localdomain systemd-homework[5056]: File system check completed.
Jul 10 20:37:29 arch.localdomain kernel: BTRFS info (device dm-0): flagging fs with big metadata feature
Jul 10 20:37:29 arch.localdomain kernel: BTRFS info (device dm-0): use zstd compression, level 1
Jul 10 20:37:29 arch.localdomain kernel: BTRFS info (device dm-0): turning on sync discard
Jul 10 20:37:29 arch.localdomain kernel: BTRFS info (device dm-0): using free space tree
Jul 10 20:37:29 arch.localdomain kernel: BTRFS info (device dm-0): has skinny extents
Jul 10 20:37:29 arch.localdomain systemd-homework[5056]: Mounting file system completed.
Jul 10 20:37:29 arch.localdomain systemd-homework[5056]: Discarded unused 1003.5M.
Jul 10 20:37:29 arch.localdomain systemd-homework[5056]: Operating on partition device /dev/disk/by-uuid/ee4a1bec-b048-426a-bed4-d1da3f4a49aa, using parent device.
Jul 10 20:37:29 arch.localdomain systemd-homework[5056]: Discovered used loopback device (null).
Jul 10 20:37:29 arch.localdomain systemd-homework[5056]: offset = 1048576, size = 1070596096, image = 1073741824
Jul 10 20:37:29 arch.localdomain systemd-homework[5056]: New partition doesn't fit into backing storage, refusing.
Jul 10 20:37:29 arch.localdomain systemd-homework[5056]: Discarded unused 124.0M.
Jul 10 20:37:29 arch.localdomain systemd-homed[591]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/home1 interface=org.freedesktop.DBus.Prope>
Jul 10 20:37:29 arch.localdomain systemd-homed[591]: Found an image for user test1 which already has a record, skipping.
Jul 10 20:37:29 arch.localdomain systemd-homed[591]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/home1 interface=org.freedesktop.DBus.Prope>
Jul 10 20:37:29 arch.localdomain audit[5056]: DM_CTRL module=crypt op=dtr ppid=591 pid=5056 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(>
Jul 10 20:37:29 arch.localdomain systemd-homed[591]: block device /sys/devices/virtual/block/dm-0 has been removed.
Jul 10 20:37:29 arch.localdomain systemd-homed[591]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/home1 interface=org.freedesktop.DBus.Prope>
Jul 10 20:37:29 arch.localdomain systemd-homed[591]: block device /sys/devices/virtual/block/dm-0 has been removed.

However, if I disable the auto-resize feature, everything works as expected:

# homectl update --auto-resize-mode=off test1
🔐 Please enter password for user test1: *********
# homectl activate test1
🔐 Please enter password for user test1: *********    
# homectl
NAME  UID   GID   STATE  REALNAME HOME        SHELL    
test1 60510 60510 active test1    /home/test1 /bin/bash

1 home areas listed.
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: Setting up LUKS device /dev/mapper/home-test1 completed.
Jul 10 20:39:46 arch.localdomain systemd-homed[591]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/home1 interface=org.freedesktop.DBus.Prope>
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: Provided password unlocks user record.
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: Probing file system completed (found btrfs).
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: File system check completed.
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: Mounting file system completed.
Jul 10 20:39:46 arch.localdomain kernel: BTRFS info (device dm-0): flagging fs with big metadata feature
Jul 10 20:39:46 arch.localdomain kernel: BTRFS info (device dm-0): use zstd compression, level 1
Jul 10 20:39:46 arch.localdomain kernel: BTRFS info (device dm-0): turning on sync discard
Jul 10 20:39:46 arch.localdomain kernel: BTRFS info (device dm-0): using free space tree
Jul 10 20:39:46 arch.localdomain kernel: BTRFS info (device dm-0): has skinny extents
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: Discarded unused 1003.5M.
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: Read embedded .identity file.
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: Provided password unlocks user record.
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: Reconciling user identities completed (host and header version were identical).
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: Reconciling embedded user identity completed (host and embedded version were identical).
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: Recursive changing of ownership not necessary, skipped.
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: Synchronized disk.
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: Moving to final mount point /home/test1 completed.
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: Activation completed.
Jul 10 20:39:46 arch.localdomain systemd-homework[5195]: Image size is 1021.0M, file system size is 1005.0M, file system payload size is 1005.0M, file system free is 100>
Jul 10 20:39:46 arch.localdomain systemd-homed[591]: Got from worker: {"userName":"test1","perMachine":[{"imagePath":"/dev/vdb","storage":"luks","fileSystemType":"btrfs">
Jul 10 20:39:46 arch.localdomain systemd-homed[591]: Home test1 is signed exclusively by our key, accepting.
Jul 10 20:39:46 arch.localdomain systemd-homed[591]: Activation of test1 completed.
Jul 10 20:39:46 arch.localdomain systemd-homed[591]: Sent message type=method_return sender=n/a destination=:1.78 path=n/a interface=n/a member=n/a cookie=391 reply_cook>
Jul 10 20:39:46 arch.localdomain systemd-homed[591]: test1: changing state activating → active

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

No response

@mrc0mmand mrc0mmand added the bug 🐛 Programming errors, that need preferential fixing label Jul 10, 2022
@mrc0mmand mrc0mmand changed the title Auto-resize of a LUKS homed partition doesn't work Auto-resize of a LUKS + btrfs homed partition doesn't work Jul 10, 2022
@github-actions github-actions bot added the homed homed, homectl, pam_homed label Jul 10, 2022
@mrc0mmand
Copy link
Member Author

mrc0mmand commented Jul 10, 2022

Also, I'm not sure if this scenario is supposed to work, but I can't activate a home dir created on a loop device (although, I can create it there without any issues):

# dd if=/dev/zero of=/test1.img bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB, 512 MiB) copied, 0.669525 s, 802 MB/s
# losetup --show -f -P /test1.img 
/dev/loop0
# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
loop0    7:0    0  512M  0 loop 
vda    254:0    0  128G  0 disk 
├─vda1 254:1    0    4G  0 part 
└─vda2 254:2    0  124G  0 part /
vdb    254:16   0    1G  0 disk 
└─vdb1 254:17   0 1021M  0 part 
# homectl create test2 --image-path=/dev/loop0 --storage=luks --fs-type=btrfs
🔐 Please enter new password for user test2: *********               
🔐 Please enter new password for user test2 (repeat): *********
# homectl
NAME  UID   GID   STATE     REALNAME HOME        SHELL    
test1 60510 60510 unfixated test1    /home/test1 /bin/bash
test2 60383 60383 inactive  test2    /home/test2 /bin/bash

2 home areas listed.
# homectl activate test2
🔐 Please enter password for user test2: *********               
Operation on home test2 failed: Failed to execute operation: Invalid argument
[ 5312.029128] systemd-homed[591]: Sending to worker: {"userName":"test2","perMachine":[{"imagePath":"/dev/loop0","storage":"luks","fileSystemType":"btrfs","matchMachineId":"292e6f2389d64c799d6fe25baadfd92f"}],"disposition":"regular","las>
[ 5312.029479] systemd-homed[591]: Successfully forked off '(sd-homework)' as PID 5530.
[ 5312.029661] systemd-homed[591]: test2: changing state inactive → activating
[ 5312.033995] systemd-homework[5530]: None of the supplied plaintext passwords unlock the user record's hashed passwords.
[ 5312.034558] systemd-homed[591]: Worker reported error code ENOKEY.
[ 5312.059609] systemd-homed[591]: Activation failed: Required key not available
[ 5312.059723] systemd-homed[591]: Sent message type=error sender=n/a destination=:1.99 path=n/a interface=n/a member=n/a cookie=544 reply_cookie=2 signature=s error-name=org.freedesktop.home1.BadPassword error-message=Password for home t>
[ 5312.059782] systemd-homed[591]: test2: changing state activating → inactive
[ 5312.059901] systemd-homed[591]: varlink: New incoming connection.
[ 5312.059957] systemd-homed[591]: varlink: Connections of user 0: 0 (of 1024 max)
[ 5312.059998] systemd-homed[591]: varlink-11: Setting state idle-server
[ 5312.060093] systemd-homed[591]: varlink-11: New incoming message: {"method":"io.systemd.UserDatabase.GetUserRecord","parameters":{"userName":"test2","service":"io.systemd.Home"}}
[ 5312.060142] systemd-homed[591]: varlink-11: Changing state idle-server → processing-method
[ 5312.060281] systemd-homed[591]: varlink-11: Sending message: {"parameters":{"record":{"userName":"test2","perMachine":[{"imagePath":"/dev/loop0","storage":"luks","fileSystemType":"btrfs","matchMachineId":"292e6f2389d64c799d6fe25baadfd9>
[ 5312.060386] systemd-homed[591]: varlink-11: Changing state processing-method → processed-method
[ 5312.060434] systemd-homed[591]: varlink-11: Changing state processed-method → idle-server
[ 5312.060525] systemd-homed[591]: varlink-11: Got POLLHUP from socket.
[ 5312.060568] systemd-homed[591]: varlink-11: Changing state idle-server → pending-disconnect
[ 5312.060607] systemd-homed[591]: varlink-11: Changing state pending-disconnect → processing-disconnect
[ 5312.060646] systemd-homed[591]: varlink-11: Changing state processing-disconnect → disconnected
[ 5314.022634] systemd-homed[591]: Got message type=method_call sender=:1.99 destination=org.freedesktop.home1 path=/org/freedesktop/home1 interface=org.freedesktop.home1.Manager member=ActivateHome cookie=3 reply_cookie=0 signature=ss er>
[ 5314.023009] systemd-homed[591]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=GetConnectionUnixUser cookie=545 reply_cookie=0 signature=s erro>
[ 5314.023077] systemd-homed[591]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.18 path=n/a interface=n/a member=n/a cookie=93 reply_cookie=545 signature=u error-name=n/a error-message=n/a
[ 5314.041293] systemd-homed[591]: Sending to worker: {"userName":"test2","perMachine":[{"imagePath":"/dev/loop0","storage":"luks","fileSystemType":"btrfs","matchMachineId":"292e6f2389d64c799d6fe25baadfd92f"}],"disposition":"regular","las>
[ 5314.041789] systemd-homed[591]: Successfully forked off '(sd-homework)' as PID 5532.
[ 5314.041874] systemd-homed[591]: test2: changing state inactive → activating
[ 5314.067808] systemd-homework[5532]: Provided password unlocks user record.
[ 5314.068318] systemd-homework[5532]: Setting up loopback device /dev/loop0 completed.
[ 5314.068568] systemd-homework[5532]: Failed to load LUKS superblock: Invalid argument
[ 5314.073918] systemd-homed[591]: Found an image for user test2 which already has a record, skipping.
[ 5314.074035] systemd-homed[591]: Found an image for user test2 which already has a record, skipping.
[ 5314.074283] systemd-homed[591]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/home1 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=546 reply_cookie=0 signature=sa{sv}as error-name=>
[ 5314.083493] systemd-homed[591]: Worker reported error code EINVAL.
[ 5314.083568] systemd-homed[591]: Activation failed: Invalid argument
[ 5314.083606] systemd-homed[591]: Sent message type=error sender=n/a destination=:1.99 path=n/a interface=n/a member=n/a cookie=547 reply_cookie=3 signature=s error-name=org.freedesktop.DBus.Error.InvalidArgs error-message=Failed to exec>
[ 5314.083650] systemd-homed[591]: test2: changing state activating → inactive

@mrc0mmand mrc0mmand added this to the v252 milestone Jul 11, 2022
@GreyXor
Copy link

GreyXor commented Aug 29, 2022

@mrc0mmand, anything I can do for helping/testing/debug this ?

@Thaodan
Copy link

Thaodan commented Sep 4, 2022

Did you try to use another/older kernel?

@GreyXor
Copy link

GreyXor commented Sep 4, 2022

I have always tested with stable kernels from archlinux (5.19.6-arch1-1 now). i can try with older one for sure. Any idea of the version you would like?

@Thaodan
Copy link

Thaodan commented Sep 4, 2022

I have always tested with stable kernels from archlinux (5.19.6-arch1-1 now). i can try with older one for sure. Any idea of the version you would like?

I have a similar issue, I know it resizing images worked at least with 5.18.x before, I would try this one.

@mrc0mmand
Copy link
Member Author

/cc @poettering

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
@yuwata yuwata modified the milestones: v253, v254 Feb 2, 2023
@mrc0mmand
Copy link
Member Author

Potential fix: #25066 (trying to coax GitHub to allow me linking this issue to that PR).

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)
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
bug 🐛 Programming errors, that need preferential fixing homed homed, homectl, pam_homed
Development

Successfully merging a pull request may close this issue.

5 participants