How to use SystemDs HomeD

We go through how to set up and remove HomeD based users.

How to use SystemDs HomeD
/home in the Linux filesystem

HomeD was adding in SystemD 245, so it has been around for a little while now. Which means it was time to dig into it and see what it can do.

The commands in the following guide/post should be distro-agnostic as long as you have SystemD 245 or above on your system. I'm using Arch Linux for this.

Create a user

First we create a user. For this we use the homectl command. But it will only work if you homed service is running. To make sure it is, we run this:

sudo systemctl enable --now systemd-homed

In this guide we will create a user called test with an encrypted home partition using LUKS2 and 50 GB in size.

sudo homectl create test --storage=luks --disk-size=50G -c "Test User"

The -c "Test User" is for setting the comment, otherwise known as Full Name in some applications. It will then ask us for the password we want to assign to this user and ask us to confirm it by writing it again. Now the user is created and it has swallowed up about 50 GB of storage on our drive. You can also use percentages instead, which will take from the free space on the partition. If you don't define the space used, it will use 85% of free space for a LUKS storage user! Keep that in mind if you are on a multi-user system.

Allow homed user to sudo

Now we just have a regular user, no sudo access or anything. We want to add that. But just adding the user to wheel group with homectl does nothing. So we need to add a config to sudoers. For ease of setup we just add a new config in /etc/sudoers.d/.

echo "test ALL=(ALL) ALL" | sudo tee /etc/sudoers.d/90-homectl

This gives the test user the right to execute sudo based commands.

Now we can logout of our regular user and log in to the HomeD based user. Most display-managers can see these users. After this, the user functions just as any other user.

More user information

There is a homectl command for looking up information about your homectl based users.

To list all homed users on the system:

sudo homectl list

To look up more information on a user:

sudo homectl inspect <username>

Try it out.

Removing a user

To remove a HomeD based user is really easy. It's just one simple command.

sudo homectl remove <username>

This removes the users home folder, any storage it had claimed (the 50 GB in our example above) and remove them from display manager entries etc.

Modifying a user

So you set up a user, but you just noticed you forgot something. Luckily homectl has a command for that. It's called homectl update. It does what homectl create does, but it just amends information instead of creating it.

So lets say we have our test user, but we forgot to add their email, we can do it with:

sudo homectl update test --email-address="test@example.com"

So if you run the inspect command on that user now it also shows it's email address.

You can add/modify just about any attribute of a HomeD based user this way.