0

I'm developing a debian package and I want to add the following line in fstab while installing this package:

tmpfs /some/created/dir tmpfs defaults,noatime,nosuid,nodev,noexec,mode=0755,size=128M 0 0

How can I define this action?

4
  • 1
    Do you want to know how a program can add this line to /etc/fstab, or do you want to know how to perform any action before or after installation? Commented Jun 26, 2021 at 11:46
  • The answer to the first question is echo tmpfs /some/created/dir tmpfs defaults,noatime,nosuid,nodev,noexec,mode=0755,size=128M 0 0 >> /etc/fstab. Commented Jun 26, 2021 at 11:47
  • The answer to the second question is probably at debian.org/doc/manuals/maint-guide/dother.en.html#maintscripts. Commented Jun 26, 2021 at 11:49
  • 1
    As an aside, folk wanting a 'scratch' area like that would normally use /var/run, already present....
    – steve
    Commented Jun 26, 2021 at 16:47

2 Answers 2

7

I certainly wouldn't want any Debian package to change by fstab. This seems almost surely to be the wrong thing to do and it calls for trouble. /etc/fstab is meant as a file to be edited by a system administrator.

How do you make sure that the change does not interfer with the system administrator? He might already use the mount point for something else.

How would you revert the change when purging the package? You will be removing lines from fstab then? The sysadmin may have altered the line.

How do you make sure that the line will not get added twice when reinstalling?

1
  • One can output a message asking the system administrator to add the line to /etc/fstab.
    – waltinator
    Commented Jun 26, 2021 at 18:16
0

After comments review I found that the mechanism that I'm looking for is a Package maintainer scripts and installation procedure. Thanks to @berndbausch for this.

I just need to add debian/postinst and debian/prerm executable and idempotent bash scripts with respecting actions. Here you can see my example.

1
  • The fact that it is technically possible to modify /etc/fstab in postinst and prerm scripts does not mean that it is good practice to do so (which is why I have not mentioned this approach in my answer). In 20 years, I have never seen a single Debian package that would dare to modify my fstab. I really suggest you search for an alternative to modifying /etc/fstab automatically, as suggested in the comment of @steve , for example.
    – user33593
    Commented Jun 30, 2021 at 10:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .