You are not logged in.

#1 2008-05-11 10:57:08

Perre
Member
Registered: 2008-01-22
Posts: 189

[solved] Automount USB disk on startup?

Hi!

I've got an external USB disk that's always connected to my computer (it sits in a "slot" in my computer) and I'm having trouble getting it to automount upon startup. I use openbox as WM and pcmanfm as FM. To mount it I have to access the disk through pcmanfm and then it gets mounted perfectly. Since I've set up my computer as a freevo media center it's kinda annoying that the disk doesn't get automounted and I have to drag my a** out of the couch to mount it. tongue

My fstab looks like this:

# 
# /etc/fstab: static file system information
#
# <file system>        <dir>         <type>    <options>          <dump> <pass>
none                   /dev/pts      devpts    defaults            0      0
none                   /dev/shm      tmpfs     defaults            0      0


/dev/cdrom /mnt/cdrom   iso9660   ro,user,noauto,unhide   0      0
/dev/dvd /mnt/dvd   udf   ro,user,noauto,unhide   0      0
/dev/sda1 /boot ext2 defaults 0 1
/dev/sda2 / ext3 defaults 0 1
/dev/sda3 /var reiserfs defaults 0 1
/dev/sda4 /home ext3 defaults 0 1
/dev/sdb1 /extra ext3 defaults 0 1

I tried to add:
/dev/sdc1 /media/disk ext3 defaults 0 1

but get a error message during boot that filesystem can't be checked and the entire boot process halts. So I canged it to:

/dev/sdc1 /media/disk ext3 defaults 0 2

but then the disk didn't get mounted.
How can I get this to work?

Last edited by Perre (2008-05-11 12:08:25)

Offline

#2 2008-05-11 11:10:17

drag0nl0rd
Package Maintainer (PM)
From: Czech Republic
Registered: 2007-10-24
Posts: 127
Website

Re: [solved] Automount USB disk on startup?

Maybe you can use this: http://wiki.archlinux.org/index.php/AutoFS_HowTo
I'm too lazy to get automount working and don't need it anyway.

Edit:
if the USB stick doesn't need to be error checked, you can add "0 0" at the and of the /etc/fstab entry

Last edited by drag0nl0rd (2008-05-11 11:12:35)

Offline

#3 2008-05-11 11:38:08

Perre
Member
Registered: 2008-01-22
Posts: 189

Re: [solved] Automount USB disk on startup?

"Devices are now automatically mounted when they are accessed." (from the autoFS wiki). Seems AutoFS only does what I already can do, but doesn't automount the USB disk on startup. sad

I tried:
/dev/sdc1 /media/disk ext3 defaults 0 0

but I get an error "Special device /dev/sdc1 does not exist" when going through boot up.

Offline

#4 2008-05-11 11:49:00

_Marco_
Member
Registered: 2008-04-21
Posts: 242

Re: [solved] Automount USB disk on startup?

excuse me if I'm wrong.. but:
adding "mount /dev/sdc1 /media/disk ext3 defaults 0 0" in /etc/rc.local
and a "umount /media/disk" in /etc/rc.local.shutdown
is a bad way to do this?

Offline

#5 2008-05-11 11:55:48

Perre
Member
Registered: 2008-01-22
Posts: 189

Re: [solved] Automount USB disk on startup?

sudo mount /dev/sdc1 /media/disk ext3 defaults 0 0 in rc.local gives this:

Usage: mount -V                 : print version
       mount -h                 : print this help
       mount                    : list mounted filesystems
       mount -l                 : idem, including volume labels
So far the informational part. Next the mounting.
The command is `mount [-t fstype] something somewhere'.
Details found in /etc/fstab may be omitted.
       mount -a [-t|-O] ...     : mount all stuff from /etc/fstab
       mount device             : mount device at the known place
       mount directory          : mount known device here
       mount -t type dev dir    : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
       mount --bind olddir newdir
or move a subtree:
       mount --move olddir newdir
One can change the type of mount containing the directory dir:
       mount --make-shared dir
       mount --make-slave dir
       mount --make-private dir
       mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
       mount --make-rshared dir
       mount --make-rslave dir
       mount --make-rprivate dir
       mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using  -L label  or by uuid, using  -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
For many more details, say  man 8 mount .

Offline

#6 2008-05-11 11:57:38

_Marco_
Member
Registered: 2008-04-21
Posts: 242

Re: [solved] Automount USB disk on startup?

ah sorry... ^^" post-lunch sleeping tongue
mount /dev/sdc1 /media/disk

(I copied the /etc/fstab option without thinking... excuse me)

Last edited by _Marco_ (2008-05-11 11:58:40)

Offline

#7 2008-05-11 12:06:58

Perre
Member
Registered: 2008-01-22
Posts: 189

Re: [solved] Automount USB disk on startup?

Thanks alot _Marco_!!! smile It now works perfectly!

We all get a bit stupid after some nice lunch sleeping. tongue

Offline

#8 2008-05-11 12:19:34

_Marco_
Member
Registered: 2008-04-21
Posts: 242

Re: [solved] Automount USB disk on startup?

I'm glad it works smile
anyway using fstab is the right way to mount disks, so consider this a workaround and try to fix your fstab
bye

Offline

#9 2008-05-12 10:12:38

_Marco_
Member
Registered: 2008-04-21
Posts: 242

Re: [solved] Automount USB disk on startup?

ah simply pointing one thing I just discovered

"
/etc/rc.local.shutdown

Analogous to the /etc/rc.local file, this file may contain any commands you want to run right before the common rc.shutdown is executed. Please note that this file does not exist by default, and for it to work properly, it must be set as executable. "
http://wiki.archlinux.org/index.php/Off … tall_Guide

be sure that your /etc/rc.local.shutdown is executable (I've not tested it but I suppose it doesn't unmount your disk otherwise. 
(to set it executable run "chmod +x /etc/rc.local.shutdown" as root)
I hope it helps
bye!

Offline

#10 2008-05-12 11:07:52

vomix
Member
From: Belgium
Registered: 2007-05-02
Posts: 84

Re: [solved] Automount USB disk on startup?

Did you have usb in your HOOKS line of mkinitcpio.conf?

eg:

HOOKS="base udev autodetect sata usb filesystems"

If no, add it and rebuild your initramfs image with mkinitcpio -g kernel26.

Of course, don't forget to remove all the stuff you put in /etc/rc.local.shutdown
and /etc/rc.local!

I hope this helps. smile

Offline

#11 2008-05-30 15:57:47

vladi_vostok
Member
From: Slovakia
Registered: 2007-11-10
Posts: 4
Website

Re: [solved] Automount USB disk on startup?

vomix wrote:

Did you have usb in your HOOKS line of mkinitcpio.conf?

eg:

HOOKS="base udev autodetect sata usb filesystems"

If no, add it and rebuild your initramfs image with mkinitcpio -g kernel26.

Of course, don't forget to remove all the stuff you put in /etc/rc.local.shutdown
and /etc/rc.local!

I hope this helps. smile

Just thinking, there shouldn't be usbinput instead of usb?

[vladi_vostok@b02-535c etc]$ mkinitcpio -H usb
Help for hook 'usb':
  This hook loads the necessary modules for an usb root device.
  ...
[vladi_vostok@b02-535c etc]$ mkinitcpio -H usbinput
Help for hook 'usbinput':
  This hook loads the necessary modules for an usb input device.
  ...

Offline

#12 2009-04-22 03:38:40

akephalos
Member
From: Romania
Registered: 2009-04-22
Posts: 114

Re: [solved] Automount USB disk on startup?

I had this problem with my Seagate USB drive along many distros and only now I solved with this info. Thanks vomix for your advice.
The instructions are not explicit enough, so I'd like to explain to the others how I've done it.
- I edited /etc/mkinitcpio.conf, adding 'usb' in the hooks array, before 'filesystem', as shown before
- I ran

# mkinitcpio -g kernel26.img

in the /root folder. This creates the boot image.
- I made a backup of /boot/kernel26.img:

# mv /boot/kernel26.img /boot/kernel26.img~

- I copy the new image in the /boot directory:

# mv /root/kernel26.img /boot/kernel26.img

- I make sure this is the image GRUB loads, looking in /boot/grub/menu.lst

Offline

Board footer

Powered by FluxBB