I use lvcreate and mkfs to create new filesystems on my Ubuntu Server 18.04 LTS systems. One thing I find confusing is that the system does not automatically add any new filesystems that I create to the /etc/fstab file. The only ones added are the ones that were created when the system was initially created during install.
Is there any way (mkfs flag, or separate apt package) that new filesystems could be inserted automatically in the /etc/fstab file rather than requiring the administrator to manually edit the file?
That's normal, because there is no way for tools or operating system to know where do you want to mount the partitions, logical volumes or etc that you have just created.
The ones you create while installing system are detected by your choices (When you select your
root
,home
, etc) and are added to fstab because they are necessary for booting your system.you have to manually edit the fstab.
BUT, there is other ways to automatically mount partitions, tools like udisks.
https://help.ubuntu.com/community/AutomaticallyMountPartitions
Here's a sample Korn shell script I made to see if it was possible to automate the creation of the LV, filesystem, and mount point all in one, and then add the appropriate entry to /etc/fstab.
Not sure if it works on all systems and configs, but it seems to be working for my needs so far. It is far from a finished product (not much error checking), but just shows me that automating the lvcreate/mkfs/mount routines into one command should be possible.