Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've got an entry for an external harddrive in my fstab:

UUID="680C0FE30C0FAAE0" /jgdata ntfs noatime,rw

But sometimes this drive isn't plugged in at boot time. This leaves me half way through a boot, with a prompt to "Continue Waiting, press S or press M" but no keypress has any affect at this stage (including Ctrl-Alt-Delete, not even caps-lock).

Short of writing a script to check the output of fdisk -l, how can I mount this drive at boot time only if it is present? It would be handy to have an fdisk entry for this drive, so I can just type mount /jgdata instead of needing a device name.

share|improve this question

5 Answers 5

up vote 10 down vote accepted

does the noauto option let the boot process continue?

it doesn't automatically mount if present, but it does get it known if present so a simple mount /jgdata works...then a scripted mount /jdata wouldn't need an output check, just catch the error and keep booting

edit: upon some further reading bootwait is probably a more correct option to pass...(usually used for network shares that might not be present until later in the boot process, but it might still cause a hang, idk)

and the mount script could be added like so: http://stackoverflow.com/questions/2062543/running-a-script-with-the-help-of-grub-and-menu-lst

share|improve this answer
    
Thanks for the answer. Just to clarify, the options are to be added to the fstab line, correct? (EDIT: Nvm, googled it. Looks like nobootwait is what I need.) –  Jeremy Nov 24 '10 at 4:56
1  
I've used the nobootwait option in fstab, works perfectly, thanks. –  Jeremy Nov 24 '10 at 5:04

You're all on the right trail. I've found a way that is a little more clean and better form.

The correct option to add in fstab is nofail, however, it needs to come after auto. If you change it to noauto, it will never mount during boot. If you add nobootwait to the bootloader, you could potentially miss something serious.

After making the above change, The system will start normally (and mount the volume) if the device is plugged in while the system is shutdown. It will also boot normally if the device is not present at boot time.

The only inconvenience is that if you connect the device while the system is running, depending on configuration (too many variables to test), the device may not mount immediately. This can be remedied with a simple mount -a or mount /specific_device or a reboot.

share|improve this answer

I had the same issue - I've done one extra step

If you use the nofail option in /etc/fstab, the system will look for your disk (and partition) on boot time. If the device is plugged, the filesystem will be mounted. If not, the boot will continue as normal.

See arch wiki: https://wiki.archlinux.org/index.php/Fstab

Example

UUID=XXXXXXXXXXXXXXX    /myhdd ntfs  nofail,auto,noatime,rw,user    0   0

I've tried to boot the system with and without the device plugged, and it works ok.

What I've not archived is to automount when disk is plugged after boot (when isn't plugged at boot). I must use mount -a as root to mount all again

share|improve this answer

The recommended way to mount during the boot is instructing their system through the fstab file. Looking at your Ask, I could see you are almost there, lacks only the instruction that sets the device to use automount options, allowing your system to mount the device when its available.

So, just rewrite the line in your fstab to be like below:

# <file system>           <dir>       <type>    <options>         <dump> <pass>
UUID="680C0FE30C0FAAE0"   /jgdata      ntfs      user,auto,rw       0     0

After change and save it, try to mount it by hand:

$ sudo mount -a

It's important to note that:

  1. you need to be sure about the device's UUID. UUIDs are generated by the make-filesystem utilities (mkfs.*) when you create a filesystem.
  2. Those <options> needs to be written following a very specific format, separated by commas but no spaces after each comma. Be careful with this ;-)
  3. I'm not sure if this will work smoothly because you are trying to automount a NTFS filesystem, that are handleable using NTFS-3G utilities. While my instructions are supposed to work correctly, I never tried automount NTFS before. So, if its failed, I recommend you to look at this Mounting Windows Partitions for alternative uses of NTFS.

Thanks!

share|improve this answer
    
i think he gets most of what you said, but it's hanging when the disk isn't detected. that's why i suggested a workaround to the "proper" way –  hbdgaf Nov 23 '10 at 5:02
    
Thanks for the answer. FYI the sudo blkid command is a good way to find out UUIDs. –  Jeremy Nov 24 '10 at 4:44
    
I have just tried that exact line in fstab. When the HDD is plugged in, the system boots normally. But, during boot, when the external HDD is not plugged in, it still prompts me to Wait/Skip/Manualy Recover. Since this prompt doesn't time out, if I'm not at the terminal, the box will not boot if the external HDD is not plugged in. –  Jeremy Nov 24 '10 at 4:53

I have the same issue. I have been editing fstab to comment out the entry when I know I am not going to have the drive present next time I boot. Then when I do have the drive present I simply edit fstab to remove the comment and issue mount -a. This is not a perfect solution. It would be great if I could figure out a way to have the system automatically mount the drive if present or automatically skip it if not present. Same problem occurs if your have NFS shares mounted automatically and the sever is not present.

share|improve this answer
1  
Check out the answer I've accepted, just add nobootwait to the mount options in fstab. –  Jeremy Nov 24 '10 at 5:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.