You are not logged in.

#1 2011-03-18 12:51:49

cl10k
Member
From: Germany
Registered: 2008-12-24
Posts: 92

[SOLVED] USB Harddrive via fstab turned off during Boot -> Error

Hello^^

I'm trying to mount my external USB Drive.

I put the following line in fstab:

/dev/sdb1 /media/Musik ext4 noauto,user,default 0 1

I only want to start the Harddive occasionally.

The problem is, when the drive is completly turned off during boot I get the following error:

No such file or directory while trying to open /dev/sdb1
Possibly non existend device? 

I thought that the noauto Option should prevent fstab from mounting the hdd???


regards

cl10k

PS: Manual mounting works without any problems...

Last edited by cl10k (2011-03-20 22:49:43)

Offline

#2 2011-03-18 13:12:31

bohoomil
Member
Registered: 2010-09-04
Posts: 2,376
Website

Re: [SOLVED] USB Harddrive via fstab turned off during Boot -> Error

I don't know exactly why but I often experienced issues with USB hard drives when trying to mount them via fstab. My solution was to mount them with udev instead by putting a dedicated *.rules file in /etc/udev/rules.d. This seems to work seamlessly.


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#3 2011-03-18 13:56:01

milomouse
Member
Registered: 2009-03-24
Posts: 940
Website

Re: [SOLVED] USB Harddrive via fstab turned off during Boot -> Error

i agree with bohoomil about using udev instead for external drives but if you wish to keep it in fstab, you might want to make pass '0' as well; the last digit in your fstab line. not sure if it has anything to do with your problem but it just seems to make more sense since it's skipped anyway and, as you said, turned off completely at times. </my 2 cents>

Offline

#4 2011-03-19 01:30:52

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: [SOLVED] USB Harddrive via fstab turned off during Boot -> Error

@cl10k, I believe you need to add the 'nofail' option for your USB drives in fstab.  The drives listed in fstab are checked at boot (fsck).  A non-existent drive is a major failure!

From man mount's listed options:

nofail    Do not report errors for this device if it does not exist.

So your fstab line for a USB drive should look something like this:

/dev/sdb1 /media/Musik ext4 noauto,nofail,user,default 0 2

USB NTFS partitions, using ntfs-3g, aren't checked by fsck, and 'nofail' is not a valid option for them.

Offline

#5 2011-03-19 15:02:06

cl10k
Member
From: Germany
Registered: 2008-12-24
Posts: 92

Re: [SOLVED] USB Harddrive via fstab turned off during Boot -> Error

Thx for your ideas!

Nofail works regarding the bootup but then fails from commandline when i try to "mount /dev/sdb1"

wrong fs type, bad option, bad superblock on /dev/sdb1

Unless you have any ideas about the new problem, I guess its time to learn how to make udev-rules.


I'll leave this thread unsolved until I really got it working with udev or fstab.

regards

Offline

#6 2011-03-19 16:52:14

bohoomil
Member
Registered: 2010-09-04
Posts: 2,376
Website

Re: [SOLVED] USB Harddrive via fstab turned off during Boot -> Error

Let me give you a hand then. The following I have in my /etc/udev/rules.d/11-media-by-label-auto-mount.rules, and what it does is:

-- pick the name of a drive,
-- create a dedicated /media/mountpoint name (certainly, "mountpoint" is replaced by the name of your drive),
-- mount the drive on boot,
-- unmount the drive on shutdown and delete the /media/mountpoint.

KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"

# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"

# Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"

# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"

# Mount the device
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"

# Clean up after removal
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"

# Exit
LABEL="media_by_label_auto_mount_end"

Plenty of handy examples you can find in /lib/udev/rules.d/ and modify them so they meet you needs. I hope it clarifies the matter a bit. wink

Last edited by bohoomil (2011-03-19 16:57:36)


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#7 2011-03-19 17:03:59

cl10k
Member
From: Germany
Registered: 2008-12-24
Posts: 92

Re: [SOLVED] USB Harddrive via fstab turned off during Boot -> Error

Thats very kind!

Offline

#8 2011-03-19 21:19:33

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: [SOLVED] USB Harddrive via fstab turned off during Boot -> Error

I don't thinl the udev rules are going to help.

The message from the 'mount' command indicates there is a filesystem error.  You should run fsck on the drive.  If you're uncomfortable with the command line form of fsck, you can use gparted to check the disk.

Offline

#9 2011-03-19 22:26:11

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: [SOLVED] USB Harddrive via fstab turned off during Boot -> Error

I think the problem is that you put "default" at the end of the options, which overwrites the previous options. Try putting it at the beginning.

Offline

#10 2011-03-19 23:07:16

cl10k
Member
From: Germany
Registered: 2008-12-24
Posts: 92

Re: [SOLVED] USB Harddrive via fstab turned off during Boot -> Error

I tried changing the default position, but still have the same error.

My fstab line now looks like this:

/dev/sdb1 /media/Musik ext4 default,nofail,noauto,user 0 0

Fsck doesnt show any problems...

Offline

#11 2011-03-20 03:08:08

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: [SOLVED] USB Harddrive via fstab turned off during Boot -> Error

I usually mount USB drives manually, though they are listed in fstab to allow an ordinary user to mount them.  I did run a test for automounting through fstab.  I don't know if this information will help you.

I used this line in fstab and rebooted (I shortened the UUID for this display):

UUID=08a...bd9  /mnt/spare  jfs  defaults,nofail,noatime,nodiratime  0 2

When I check the mount options, this is what I have:

$ mount
    ...
    Omitted
    ...
/dev/sdh8 on /mnt/spare type jfs (rw,_netdev,noatime,nodiratime)

The _netdev option surprised me.  Mount's manpage says it means:

The  filesystem resides on a device that requires network access (used to prevent the system from attempting to mount these filesystems until the network has been enabled on the system).

Offline

#12 2011-03-20 21:41:28

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: [SOLVED] USB Harddrive via fstab turned off during Boot -> Error

You should probably write "defaults" instead of "default"... Other than that, your options are starting to look like what I'm using:

LABEL=Samsung1000     /mnt/samsung1000  ext4  defaults,users,exec,noauto,noatime,commit=30 0 0

This is supposed to work even when my usb disk is unplugged, but to be honest it's always plugged in so I'm not sure if it works smile.

Offline

#13 2011-03-20 22:49:09

cl10k
Member
From: Germany
Registered: 2008-12-24
Posts: 92

Re: [SOLVED] USB Harddrive via fstab turned off during Boot -> Error

stqn is right! I should be defaultS... *facepalm*

Now everything is working perfectly.

Thanks to everyone contributing to this thread!!

kind regards

cl10k

Offline

Board footer

Powered by FluxBB