You are not logged in.

#1 2023-01-14 17:27:29

robinm
Member
Registered: 2023-01-14
Posts: 5

Systemd homed overwrote .home file, can it be recovered?

Hi everyone,

I recently changed distribution on my system. I have a separate /home partition which has a systemd homed  username.home file on it containing my data. I did a manual partitioning and everything went well until the time came to import my old data. I did a big booboo by creating a new user with homectl and overwriting my old .home file. The command in question was:

sudo homectl create user --uid=1000 --storage=luks

Where "user" was my user name.
The thing that gives me hope is that the user.home file is still really big even though when it is mounted it doesn't show anything but the newly created empty standard folders (Documents, Pictures, etc.). I tried to login as root via tty2 and manually mount the home file with losetup and cryptsetup but the same empty standard directories show up.

Can anyone think of a way that I could potentially get the old home folder back or should I just shed a tear and move on?
What would have been the correct way of importing the identity onto the new system? I couldn't find a ".identity" file in my home folder (even before ruining it).

Thank you for your time,

Robin

Offline

#2 2023-01-15 06:09:27

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,130

Re: Systemd homed overwrote .home file, can it be recovered?

Do you have a backup? My guess is you've overwritten the LUKS header, but I don't know enough about systemd-homed to be sure. Do you have a backup of the header? (Backing up the header of a LUKS container is a standard recommendation, so you might have made one if you followed the relevant wiki guidance.)

It seems perilously easy to destroy all one's personal data with systemd-homed. It boggles my mind that homectl will do things like deletion without double-checking. (I mean, yes, you should know what you're doing, but, yes, highly destructive commands should incorporate safeguards when reasonably practicable.) This case is even worse. Overwriting an existing user when asked to create a brand new user without asking whether you're sure is deplorable.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#3 2023-01-15 14:10:35

robinm
Member
Registered: 2023-01-14
Posts: 5

Re: Systemd homed overwrote .home file, can it be recovered?

Thank you for your response cfr.

cfr wrote:

Do you have a backup of the header? (Backing up the header of a LUKS container is a standard recommendation, so you might have made one if you followed the relevant wiki guidance.)

I followed the instructions on the systemd website back when I converted my regular user into a homed one and backing up the header wasn't part of the process... It will be part of my process from now on!

It seems perilously easy to destroy all one's personal data with systemd-homed. It boggles my mind that homectl will do things like deletion without double-checking.

Thank you for being on my side smile That was my first thought as well. Then I reminded myself of the whole "with great power comes great responsibility" adage. Loads of commands executed as root can be very destructive without warning so I should have been more careful. It is a very interesting question though, whether holding an administrative user by the hand is part of the GNU/Linux philosophy or not...

As a (potentially destructive) experiment, I have kept using the newly created user. Interestingly, the .home file keeps growing, unlike on a regular partition where the old data would just get overwritten if it doesn't show up in the index file. Which makes me thing there is potentially still some sort of header there that the system is aware of. Also, I have found out  that it is possible to have multiple partitions in a single LUKS container. I wonder if I couldn't specify some sort of offset when mounting the LUKS volume to find the old header in case the new one was "nudged in" just before.

So my next step is learning about the structure of LUKS containers and how homed handles them to see if anything is worth exploring. I'll come back and post potential findings here!

Offline

Board footer

Powered by FluxBB