# Default values are assigned via the parser so we go via the argument parser to construct
# the config for the initrd.
- password, hashed = state.config.root_password or (None, False)
- if password:
+ if state.config.root_password:
+ password, hashed = state.config.root_password
rootpwopt = f"hashed:{password}" if hashed else password
else:
rootpwopt = None
creds = []
for option, cred, value in settings:
- if not value:
+ # Check for None as password might be the empty string
+ if value is None:
continue
options += [option, value]
: Set the system root password. If this option is not used, but a `mkosi.rootpw` file is found in the local
directory, the password is automatically read from it. If the password starts with `hashed:`, it is treated
as an already hashed root password. The root password is also stored in `/usr/lib/credstore` under the
- appropriate systemd credential so that it applies even if only `/usr` is shipped in the image.
+ appropriate systemd credential so that it applies even if only `/usr` is shipped in the image. To create
+ an unlocked account without any password use `hashed:` without a hash.
`Autologin=`, `--autologin`