When to run "chattr +i /var/lib/linstor"

Hi everyone,

I’m new to LINSTOR and have successfully set up the HA Controller following the guide at LINBIT.

However, I have a question about the command “chattr +i /var/lib/linstor”. This command is meant to protect the /var/lib/linstor directory. After executing “systemctl start var-lib-linstor.mount”, I noticed that the attributes of /var/lib/linstor get mounted and overridden by /dev/drbd/by-res/linstor_db/0.

# chattr +i /var/lib/linstor
# lsattr -d /var/lib/linstor
----i---------e------- /var/lib/linstor

# systemctl start var-lib-linstor.mount
lsattr -d /var/lib/linstor
--------------e------- /var/lib/linstor

So, should I run “chattr +i /var/lib/linstor” both before and after executing “systemctl start var-lib-linstor.mount”?

For context of future readers, the steps mentioned in the LINSTOR Users Guide:

cat << EOF > /etc/systemd/system/var-lib-linstor.mount
[Unit]
Description=Filesystem for the LINSTOR controller

[Mount]
# you can use the minor like /dev/drbdX or the udev symlink
What=/dev/drbd/by-res/linstor_db/0
Where=/var/lib/linstor
EOF

mv /var/lib/linstor{,.orig}
mkdir /var/lib/linstor
chattr +i /var/lib/linstor # only if on LINSTOR >= 1.14.0
drbdadm primary linstor_db
mkfs.ext4 /dev/drbd/by-res/linstor_db/0
systemctl start var-lib-linstor.mount
cp -r /var/lib/linstor.orig/* /var/lib/linstor
systemctl start linstor-controller

The chattr +i /var/lib/linstor makes the newly created and empty /var/lib/linstor immutable, so nothing (including LINSTOR) can create new files within it. When you mount the linstor_db DRBD device to /var/lib/linstor, that “overlays” the DRBD device’s filesystem and attributes over the original immutable directory, so LINSTOR can create and change files on the DRBD device’s filesystem.

This prevents LINSTOR from being started without the DRBD device that contains its database being mounted first. Otherwise, LINSTOR would be able to create a new (and empty) LINSTOR database on the local filesystem, which wouldn’t be replicated or contain previously created entries, and could lead to issues and inconsistencies within the cluster.

Only run chattr +i /var/lib/linstor before mounting the linstor_db device.

1 Like

Hi Kermat, thank you so much! Your explanation was very clear, and I understand much better now. :grin: :pray:

1 Like