[systemd-devel] Mounting / as writable without in `/etc/fstab`

Paul Menzel pmenzel+systemd-devel at molgen.mpg.de
Thu Nov 26 09:58:40 UTC 2020


Dear Mantas,



Thank you for your detailed reply.


Am 26.11.20 um 09:12 schrieb Mantas Mikulėnas:
> On Mon, Nov 23, 2020 at 5:23 PM Paul Menzel wrote:

>> Is an entry for / in `/etc/fstab` still needed, or is there a systemd
>> way of doing it?
> 
> That *is* the systemd way -- the fstab entry will be read by
> systemd-remount-fs(8) and the new mount options applied.

Thank you. That wasn’t clear to me.

>> Installing Debian bullseye/testing with the Debian Installer, it creates
>> a GPT and `/etc/fstab`. [...]
>> Commenting out the entries for `/`, the root partition is mounted as
>> read-only.
>>
>>       $ findmnt /
>>       TARGET SOURCE         FSTYPE OPTIONS
>>       /      /dev/nvme0n1p2 ext4   ro,relatime
>>
>> Shouldn’t it be mounted as writable?
> 
> No, if you had it initially mounted with 'ro' and did not leave any
> instructions for remounting, then it won't be remounted...

Understood.

>>
>>       $ sudo /lib/systemd/systemd-remount-fs
>>       $ findmnt /
>>       TARGET SOURCE         FSTYPE OPTIONS
>>       /      /dev/nvme0n1p2 ext4   rw,relatime,errors=remount-ro

Sorry, that was my confusion. I checked it again, and I messed up during 
testing. This result was with the entry for / present in `/etc/fstab`, 
that means not commented out.

>> The log says:
>>
>>       [    2.320133] systemd[179]: /usr/lib/systemd/system-generators/systemd-gpt-auto-generator succeeded.
>>
>> I can work around it changing `ro` to `rw` on the Linux command line,
>> but I thought, it is possible without that.
> 
> I would say that having the initramfs directly mount the filesystem as rw
> is the *preferred method*, not a workaround... Of course it depends on how
> your distro's initramfs wants to work, but at least that's what Arch does
> -- since fsck is run from the initramfs, there's not much point in later
> mounting it ro at all.

Sorry, I didn’t understand that last paragraph. I thought, it’s 
desirable to first mount it ro, so fsck can run, and then remount it as 
read-writable?

My use case is to boot without initramfs. But, now that I know, that 
`/etc/fstab` is there to stay, I know what to do.


Kind regards,

Paul


More information about the systemd-devel mailing list