I have a partition mounted with mount /mnt/filesys.bin /mnt/mymnt/
Each time I reboot, I need to remount. How can I keep this mounted after every reboot?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityFrom man fstab
:
The file
/etc/fstab
contains descriptive information about the filesystems the system can mount.fstab
is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file.
To do what you want you just need to add an entry for this mount in /etc/fstab
as follows:
Open new terminal window Ctrl+Alt+T.
Open the file /etc/fstab
for edit with root privileges, using nano
:
sudo nano /etc/fstab
Go to the bottom of the file and add the following line - here I'm assuming it is an image file, so we need to use the loop
option (reference):
/mnt/filesys.bin /mnt/mymnt/ auto nofail,defaults,loop 0 0
If you want to mount physical device (or partition), you can identify it by several different ways, for example by its UUID. To find the UUID use sudo blkid
while the device is mounted (or use the GUI tool Disks
). In this case the entry could look like:
/dev/disk/by-uuid/a58b40e4-eb9b-4720-835b-785a3be3ae33 /mnt/mymnt/ auto nosuid,nodev,nofail 0 0
or:
UUID=a58b40e4-eb9b-4720-835b-785a3be3ae33 /mnt/mymnt/ auto nosuid,nodev,nofail 0 0
Where a58b40e4-eb9b-4720-835b-785a3be3ae33
is the UUID of your device.
Save the file: Ctrl+O, then exit from nano
: Ctrl+X.
Restart the system or type sudo mount -a
to see the result.
Do not forgot to remove that entry if you remove the image file.
blkid
command in terminal, while the device is mounted,then to fstab use UUID=<uuid> /mnt/mymount auto nofail,defaults
Nov 22, 2018 at 9:56
systemd.mount
unit.
@pa4080 is totally right, but the really easy solution is (running as the superuser, so sudo su
first):
mount /mnt/filesys.bin /mnt/mymnt/
grep mymnt /etc/mtab >>/etc/fstab
The first line mounts your device with whatever other options you need, the second will put it into /etc/fstab
with the same options so that it gets mounted on every reboot.
/etc/fstab
for that?/etc/fstab
is the correct think to look for, not a Bash script.sudo cp /etc/mtab /etc/fstab
would do that. It's not something I would ever want to try! At any given time, I have a number of temporary mounts that I wouldn't want saved.