I just mounted sda2 to /mnt. How can I force a refresh of fstab so it can pickup the changes and insert a new line for sda2-/mnt?
You need to manually edit the file
fstab. To find out what to put in there, issue the
mount command and look at its output.
Linux definitely does provide the tools to do this automatically. Rather than using
mount, you should be using
man mount 2>/dev/null | grep -m1 -B1 findmnt For more robust and customizable output use findmnt(8), especially in your scripts. printf '%s%s 0 0\n' '/dev/disk/by-uuid/' \ "$(findmnt -n -o UUID,TARGET,FSTYPE,OPTIONS /mnt)" | sudo tee -a /etc/fstab
P.S. You'll want to have a look at
man fstab for information about the
0 0 bit on the end there. They're related to
pass respectively. Whether or not their values above will suit you I cannot say. I can say that those are also output options available with
findmnt - but asking it to report on them would make no sense for a disk that isn't already in
/etc/fstab. You might also want to reconsider
/mnt as the permanent mount point for your new