15

I have a partition mounted with mount -t ext3 /dev/sda3 /foo.

Each time I reboot, I need to remount. How can I keep this mounted after every reboot?

mailq
  • 17,023
  • 2
  • 37
  • 69
coffee
  • 239
  • 2
  • 4
  • 6

3 Answers3

34

You need to make an entry in /etc/fstab for the mount, something like:

/dev/sda3 /foo                       ext3    defaults        1 1

For more information see:

https://help.ubuntu.com/community/Fstab

DocWeird
  • 103
  • 4
Kyle Brandt
  • 83,619
  • 74
  • 305
  • 448
10

Sometimes, one may face critical issues due to /etc/fstab entries. So, the alternative is crontab.

Just add below entry in root's crontab.

$ sudo crontab -e

@reboot mount -t ext3 /dev/sda3 /foo

DMin
  • 398
  • 2
  • 11
Parvinder Singh
  • 249
  • 2
  • 3
  • 4
    Are you really suggesting to use an ugly hack instead of the proper way of doing it, which has been in use for *decades* and never actually caused those "critical issues" to anyone?!? – Massimo Jul 03 '13 at 07:29
  • 2
    I faced this situation while working on cloud machine on AWS. There was some problem while mounting using /etc/fstab, and the system was halting boot process. So, the system became useless as it was remote. So, i prefer safe boot (without specifying an entry in fstab) and then issue mount in crontab. – Parvinder Singh Oct 25 '13 at 13:22
  • @Massimo actually "critical issues" do exist. Here's what a Google engineer says about mounting a certain cloud storage (like Amazon S3) FUSE filesystem via fstab at boot: _"let me urge you to not do this. Requests to GCS are not nearly as reliable as local disk, and you're likely to find yourself with a system that hangs on boot if anything goes wrong"_ ( [here](https://github.com/GoogleCloudPlatform/gcsfuse/issues/135#issuecomment-151009207) ) – KajMagnus Jul 23 '16 at 14:32
  • Not sure what to do instead though, but crontab and `@reboot` makes sense to me. Perhaps in combination with a fstab `noauto` row, or `mount` directly in the crontab. — Anyway, upvoted from -3 to -2, because this answer is actually useful, in some rare cases. (And edit suggestoin: "sometimes" --> "in rare cases" :- ) ) – KajMagnus Jul 23 '16 at 14:33
  • This is what I did in my case: `@reboot echo '/opt/ed/mount-google-cloud-storage-backups-bucket.sh >> /opt/ed/cron.log 2>&1' | at now + 3 minutes`, works OK perhaps not for everyone, but for my use case. – KajMagnus Jul 23 '16 at 15:29
  • What are the critical issue that would not permit entries into fstab, could you give an exemple of cases. – Ali Mezgani May 13 '17 at 15:16
  • @Massimo i to had boot problems when added the mount. if the mount fails boot fails and you can not enter your machine! – tibi Feb 24 '18 at 09:17
0

For OpenSuse, coming from Novell Automatically mount a windows share at boot time with Linux

//winserver/share /mnt/winshare cifs gid=users,file_mode=0664,dir_mode=0775,auto,username=john,password=johnpass 0 0

Please add single quotes if the folder names contains spaces:

'//winserver/share with spaces' '/mnt/winshare with spaces' cifs gid=users,file_mode=0664,dir_mode=0775,auto,username=john,password=johnpass 0 0

Check the end of the article if you don't want to put passwords in fstab.

coz
  • 101
  • 3