Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
mounting USB Drive on boot [Big 'ol SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Nallelcm
n00b
n00b


Joined: 04 Jan 2006
Posts: 16

PostPosted: Wed Jan 04, 2006 2:45 pm    Post subject: mounting USB Drive on boot [Big 'ol SOLVED] Reply with quote

I have added my usb drive (sda1) to my fstab

Code:

/dev/sda1    /mnt/drive   vfat     defaults    0 0


only prob is when i start up my computer it tells me that there is no sda1, yet after it boots i can mount sda1
_________________
- Nallelcm


Last edited by Nallelcm on Wed Jan 11, 2006 3:53 pm; edited 1 time in total
Back to top
View user's profile Send private message
mmbrothers
Apprentice
Apprentice


Joined: 24 Dec 2005
Posts: 224
Location: Boston

PostPosted: Wed Jan 04, 2006 2:57 pm    Post subject: Reply with quote

The point during boot where filesystems are mounted is pretty early. It is most likely that USB devices have not been detected this early in the process. You could always add a line such as

Code:

mount /mnt/drive


to /etc/conf.d/local.start. Of course, make sure that local is in the default runlevel.
Back to top
View user's profile Send private message
Nallelcm
n00b
n00b


Joined: 04 Jan 2006
Posts: 16

PostPosted: Wed Jan 04, 2006 3:58 pm    Post subject: Reply with quote

mmbrothers wrote:
The point during boot where filesystems are mounted is pretty early. It is most likely that USB devices have not been detected this early in the process. You could always add a line such as

Code:

mount /mnt/drive


to /etc/conf.d/local.start. Of course, make sure that local is in the default runlevel.


okay, but then, how do i mount it so that it's accessable by all users?
_________________
- Nallelcm
Back to top
View user's profile Send private message
mmbrothers
Apprentice
Apprentice


Joined: 24 Dec 2005
Posts: 224
Location: Boston

PostPosted: Wed Jan 04, 2006 5:05 pm    Post subject: Reply with quote

One thing that I forgot to ask is: are you loading the usb modules during boot? This could be another reason that the usb drive is not mounting with the other filesystems.

What do you mean by accessible? I assume that you mean allowing the users to see/modify files on this filesystem. You just need to give users permissions to the files that you want them to have access to. Don't forget that they will also need r-x permissions to the directory where you mount this FS, otherwise they cannot get to the files on this drive.

For information about permissions you can read man chmod and man chown
Back to top
View user's profile Send private message
Nallelcm
n00b
n00b


Joined: 04 Jan 2006
Posts: 16

PostPosted: Wed Jan 04, 2006 6:16 pm    Post subject: Reply with quote

mmbrothers wrote:
One thing that I forgot to ask is: are you loading the usb modules during boot? This could be another reason that the usb drive is not mounting with the other filesystems.

What do you mean by accessible? I assume that you mean allowing the users to see/modify files on this filesystem. You just need to give users permissions to the files that you want them to have access to. Don't forget that they will also need r-x permissions to the directory where you mount this FS, otherwise they cannot get to the files on this drive.

For information about permissions you can read man chmod and man chown


yeah i want users to be allowed to see/modify files. im not sure how my usb modules are being loaded... but if I as root "mount -t vfat /dev/sda1 /mnt/storage" and then "chmod 777 /mnt/storage" then as my user account i still dont have access to read/write to /mnt/storage :(
_________________
- Nallelcm
Back to top
View user's profile Send private message
mmbrothers
Apprentice
Apprentice


Joined: 24 Dec 2005
Posts: 224
Location: Boston

PostPosted: Wed Jan 04, 2006 10:47 pm    Post subject: Reply with quote

Are you setting permissions on all of the files/directories that you need access to on the filesystem?

If you want to set 777 on all files on the filesystem you will need to issue the command

Code:

chmod -R 777 /mnt/storage


Which will recursively set the file permissions on /mnt/storage.

Although mode 777 is usually a bad idea in most cases. You could create a group of users that you want to have write access to this drive and assign this group permissions to the files.
Back to top
View user's profile Send private message
Nallelcm
n00b
n00b


Joined: 04 Jan 2006
Posts: 16

PostPosted: Thu Jan 05, 2006 7:37 am    Post subject: Reply with quote

mmbrothers wrote:
Are you setting permissions on all of the files/directories that you need access to on the filesystem?

If you want to set 777 on all files on the filesystem you will need to issue the command

Code:

chmod -R 777 /mnt/storage


Which will recursively set the file permissions on /mnt/storage.

Although mode 777 is usually a bad idea in most cases. You could create a group of users that you want to have write access to this drive and assign this group permissions to the files.


Code:
emu media # ls -l
total 64
drwxr--r--  9 nallelcm root 32768 Dec 31  1969 storage
drwxr--r--  7 nallelcm root 32768 Jan  4 07:15 usbd
emu media # chmod 777 storage
chmod: changing permissions of `storage': Read-only file system
emu media # ls -l
total 64
drwxr--r--  9 nallelcm root 32768 Dec 31  1969 storage
drwxr--r--  7 nallelcm root 32768 Jan  4 07:15 usbd
emu media #     


you would think that chmod 777 storage would show a drwxrwxrwx as the permissions for storage... but no :(
_________________
- Nallelcm
Back to top
View user's profile Send private message
MrUlterior
Guru
Guru


Joined: 22 Mar 2005
Posts: 511
Location: Switzerland

PostPosted: Thu Jan 05, 2006 1:22 pm    Post subject: Reply with quote

You can't set permission on a VFAT fs with chmod! If you wish to set the permission on the mountpoint, then do so BEFORE mounting it, but this will only really affect users ability to cd into the dir, not perms on the dir's contents.

To set perms on the mounted content
You need "uid=XXX,gid=XXX,fmask=XXX,dmask=XXX" in your /etc/fstab

Where XXX in uid & gid are the UID/GID of the user & group owners of the content. fmask determines the umask to apply to files, dmask denotes the umask for directories.

Suggest you read "man mount" and search for umask there, for more info. Or else scream and I'll post my fstab which has a working example that I use to mount my CF card readers when I get home ...
_________________

Misanthropy 2.0 - enough hate to go around
Back to top
View user's profile Send private message
Nallelcm
n00b
n00b


Joined: 04 Jan 2006
Posts: 16

PostPosted: Thu Jan 05, 2006 7:14 pm    Post subject: Reply with quote

MrUlterior wrote:
You can't set permission on a VFAT fs with chmod! If you wish to set the permission on the mountpoint, then do so BEFORE mounting it, but this will only really affect users ability to cd into the dir, not perms on the dir's contents.

To set perms on the mounted content
You need "uid=XXX,gid=XXX,fmask=XXX,dmask=XXX" in your /etc/fstab

Where XXX in uid & gid are the UID/GID of the user & group owners of the content. fmask determines the umask to apply to files, dmask denotes the umask for directories.

Suggest you read "man mount" and search for umask there, for more info. Or else scream and I'll post my fstab which has a working example that I use to mount my CF card readers when I get home ...


Well, if you wouldn't mind, that would be great :D
_________________
- Nallelcm
Back to top
View user's profile Send private message
MrUlterior
Guru
Guru


Joined: 22 Mar 2005
Posts: 511
Location: Switzerland

PostPosted: Sat Jan 07, 2006 3:13 pm    Post subject: Reply with quote

Code:

## removable stuff
/dev/sdb1               /mnt/sdcard                     vfat            rw,uid=1000,gid=100,umask=022,noauto    0 0


You'll need to set your UID & GID as appropriate
_________________

Misanthropy 2.0 - enough hate to go around
Back to top
View user's profile Send private message
Nallelcm
n00b
n00b


Joined: 04 Jan 2006
Posts: 16

PostPosted: Sun Jan 08, 2006 5:45 am    Post subject: Reply with quote

MrUlterior wrote:
Code:

## removable stuff
/dev/sdb1               /mnt/sdcard                     vfat            rw,uid=1000,gid=100,umask=022,noauto    0 0


You'll need to set your UID & GID as appropriate


umm, what about if i wanted all users to be able to access it ... i dont know if yours already does that, but im gonna give it a shot
_________________
- Nallelcm
Back to top
View user's profile Send private message
MrUlterior
Guru
Guru


Joined: 22 Mar 2005
Posts: 511
Location: Switzerland

PostPosted: Sun Jan 08, 2006 2:02 pm    Post subject: Reply with quote

Nallelcm wrote:
MrUlterior wrote:
Code:

## removable stuff
/dev/sdb1               /mnt/sdcard                     vfat            rw,uid=1000,gid=100,umask=022,noauto    0 0


You'll need to set your UID & GID as appropriate


umm, what about if i wanted all users to be able to access it ... i dont know if yours already does that, but im gonna give it a shot


You are aware that users can be in multiple groups?
Code:

# groups mrulterior
wheel audio cdrom video vmware users
# cat /etc/group| egrep "^users"
users:x:100:games


So you see that my user is in the group "users", which has a GID 100. That GID is in my options for my SD card reader, meaning that group ownership of all content on the sdcard is forced to "users", see:

Code:
# mount sdcard && cd sdcard && touch test.txt && ls -lath test.txt
-rwxrwxrw-  1 root users 0 Jan  8 15:01 test.txt


So logically, any user you want to be able to read/write to that mountpoint, only has to be a member of the group "users"
_________________

Misanthropy 2.0 - enough hate to go around
Back to top
View user's profile Send private message
Nallelcm
n00b
n00b


Joined: 04 Jan 2006
Posts: 16

PostPosted: Tue Jan 10, 2006 9:26 am    Post subject: Reply with quote

MrUlterior wrote:



You are aware that users can be in multiple groups?
Code:

# groups mrulterior
wheel audio cdrom video vmware users
# cat /etc/group| egrep "^users"
users:x:100:games


So you see that my user is in the group "users", which has a GID 100. That GID is in my options for my SD card reader, meaning that group ownership of all content on the sdcard is forced to "users", see:

Code:
# mount sdcard && cd sdcard && touch test.txt && ls -lath test.txt
-rwxrwxrw-  1 root users 0 Jan  8 15:01 test.txt


So logically, any user you want to be able to read/write to that mountpoint, only has to be a member of the group "users"


well okay, i just want you to take a look at this
Code:
nallelcm@emu ~ $ cat /etc/fstab | grep "/dev/sda"
/dev/sda1               /media/storage  vfat            rw,uid=1000,gid=100,umask=022,noauto    0 0
nallelcm@emu ~ $ cat /etc/group | grep nallelcm
disk::6:root,adm,nallelcm
wheel::10:root,nallelcm
floppy::11:root,nallelcm
cron::16:cron,nallelcm
audio::18:nallelcm
cdrom::19:nallelcm
video::27:root,nallelcm
games::35:nallelcm
usb::85:nallelcm
users::100:games,nallelcm
nallelcm@emu ~ $ cat /etc/passwd | grep nallelcm
nallelcm:x:1000:100::/home/nallelcm:/bin/bash
nallelcm@emu ~ $   

that's how it's currently set up... the fstab is set up "right" however i rebooted expecting it to mount...
Code:
nallelcm@emu ~ $ cd /media/storage/
nallelcm@emu /media/storage $ ls
nallelcm@emu /media/storage $ 

so then i decided to mount it manually using the options specified in my fstab
Code:

emu nallelcm # mount -t vfat -o rw,uid=100,gid=100,umask=022,noauto /dev/sda1 /media/storage
emu nallelcm # cd /media/storage
emu storage # ls
ApInsTmp.log  Music                      config.sys  pagefile.sys  xorg.conf
Backup        System Volume Information  io.sys      sxs
Downloads     autoexec.bat               msdos.sys   system.sav
emu storage # exit
exit
nallelcm@emu ~ $ cd /media/storage
nallelcm@emu /media/storage $ ls
ApInsTmp.log  Music                      config.sys  pagefile.sys  xorg.conf
Backup        System Volume Information  io.sys      sxs
Downloads     autoexec.bat               msdos.sys   system.sav
nallelcm@emu /media/storage $ cd ..
nallelcm@emu /media $ ls -l
total 36
drwxr-xr-x  9      100 users 32768 Dec 31  1969 storage
drwxr-xr-x  2 nallelcm users  4096 Jan  4 07:00 usbd
nallelcm@emu /media $ cd storage
nallelcm@emu /media/storage $ echo "test" > new
bash: new: Permission denied


Well it looks like i can mount it for reading for all users, but i don't know how to make it writable for all users now... and it still doesn't do it on boot :(
_________________
- Nallelcm


Last edited by Nallelcm on Tue Jan 10, 2006 4:29 pm; edited 2 times in total
Back to top
View user's profile Send private message
MrUlterior
Guru
Guru


Joined: 22 Mar 2005
Posts: 511
Location: Switzerland

PostPosted: Tue Jan 10, 2006 12:30 pm    Post subject: Reply with quote

Change "noauto" to "auto" or remove it completely, and "umask=022" to "umask=002" in your /etc/fstab

You realise that your uid in /etc/fstab reads 100 instead of 1000 right? Otherwise this would have worked already ...

Code:

nallelcm@emu ~ $ cat /etc/passwd | grep nallelcm
nallelcm:x:1000:100::/home/nallelcm:/bin/bash

_________________

Misanthropy 2.0 - enough hate to go around
Back to top
View user's profile Send private message
Nallelcm
n00b
n00b


Joined: 04 Jan 2006
Posts: 16

PostPosted: Tue Jan 10, 2006 4:08 pm    Post subject: Reply with quote

MrUlterior wrote:
Change "noauto" to "auto" or remove it completely, and "umask=022" to "umask=002" in your /etc/fstab

You realise that your uid in /etc/fstab reads 100 instead of 1000 right? Otherwise this would have worked already ...

Code:

nallelcm@emu ~ $ cat /etc/passwd | grep nallelcm
nallelcm:x:1000:100::/home/nallelcm:/bin/bash


Wow, do I ever feel dumb, I just changed it now, but I'll have to wait until I get home to see if it works :)

EDIT::

well i ended up rebooting my computer while still at school, and it didn't mount...
Code:
nallelcm@emu / $ cat /etc/fstab | grep sda
/dev/sda1               /media/storage  vfat            rw,uid=1000,gid=100,umask=002,auto      0 0
that's my current fstab...

I'm gonna go ahead and assume that this is a problem where as my USB devices are being reconized after my fstab does its thing. Any idea of a work around?
_________________
- Nallelcm
Back to top
View user's profile Send private message
MrUlterior
Guru
Guru


Joined: 22 Mar 2005
Posts: 511
Location: Switzerland

PostPosted: Wed Jan 11, 2006 9:27 am    Post subject: Reply with quote

Nallelcm wrote:

I'm gonna go ahead and assume that this is a problem where as my USB devices are being reconized after my fstab does its thing. Any idea of a work around?


Hmmm ... bizarre. It should work, do you have "usb-storage" built as a module or is it within the kernel? Is usb-storage
listed in /etc/modules.autoload/kernel2.6 ?
_________________

Misanthropy 2.0 - enough hate to go around
Back to top
View user's profile Send private message
Nallelcm
n00b
n00b


Joined: 04 Jan 2006
Posts: 16

PostPosted: Wed Jan 11, 2006 2:12 pm    Post subject: Reply with quote

MrUlterior wrote:
Nallelcm wrote:

I'm gonna go ahead and assume that this is a problem where as my USB devices are being reconized after my fstab does its thing. Any idea of a work around?


Hmmm ... bizarre. It should work, do you have "usb-storage" built as a module or is it within the kernel? Is usb-storage
listed in /etc/modules.autoload/kernel2.6 ?

Code:
# /etc/modules.autoload.d/kernel-2.6:  kernel modules to load when system boots.
# $Header: /var/cvsroot/gentoo-src/rc-scripts/etc/modules.autoload.d/kernel-2.6,v 1.1 2003/07/16 18:13:45 azarah Exp $
#
# Note that this file is for 2.6 kernels.
#
# Add the names of modules that you'd like to load when the system
# starts into this file, one per line.  Comments begin with # and
# are ignored.  Read man modules.autoload for additional details.

# For example:
# 3c59x

thats what is in my kernel-2.6[/quote]
_________________
- Nallelcm
Back to top
View user's profile Send private message
MrUlterior
Guru
Guru


Joined: 22 Mar 2005
Posts: 511
Location: Switzerland

PostPosted: Wed Jan 11, 2006 2:21 pm    Post subject: Reply with quote

Ok, that doesn't really help.

If
Code:

gzcat /proc/config.gz | egrep CONFIG_USB_STORAGE=


returns:

Quote:

CONFIG_USB_STORAGE=m


Then add usb-storage to your /etc/modules.autoload.d/kernel-2.6

Code:

echo usb-storage >> /etc/modules.autoload.d/kernel-2.6


Reboot & test
_________________

Misanthropy 2.0 - enough hate to go around
Back to top
View user's profile Send private message
Nallelcm
n00b
n00b


Joined: 04 Jan 2006
Posts: 16

PostPosted: Wed Jan 11, 2006 2:50 pm    Post subject: Reply with quote

MrUlterior wrote:
Ok, that doesn't really help.

If
Code:

gzcat /proc/config.gz | egrep CONFIG_USB_STORAGE=


returns:

Quote:

CONFIG_USB_STORAGE=m


Then add usb-storage to your /etc/modules.autoload.d/kernel-2.6

Code:

echo usb-storage >> /etc/modules.autoload.d/kernel-2.6


Reboot & test

Code:
emu / # gzcat /proc/config.gz | egrep CONFIG_USB_STORAGE=
CONFIG_USB_STORAGE=m
emu / # cat /etc/modules.autoload.d/kernel-2.6 | grep usb-storage
usb-storage
emu / # cat /etc/fstab | grep sda
/dev/sda1               /media/storage  vfat            rw,uid=1000,gid=100,umask=002,auto      0 0
emu / # cd /media/storage
emu storage # ls
emu storage # mount -t vfat -o rw,uid=1000,gid=100,umask=002,auto /dev/sda1 /media/storage
emu storage # ls
ApInsTmp.log  Music                      config.sys  pagefile.sys  xorg.conf
Backup        System Volume Information  io.sys      sxs
Downloads     autoexec.bat               msdos.sys   system.sav
emu storage #


so it didn't mount on boot yet again, :S i'm stumped
_________________
- Nallelcm
Back to top
View user's profile Send private message
MrUlterior
Guru
Guru


Joined: 22 Mar 2005
Posts: 511
Location: Switzerland

PostPosted: Wed Jan 11, 2006 3:00 pm    Post subject: Reply with quote

Oh well, I suggest you try building the usb-storage into your kernel instead of as a module:

Code:

cd /usr/src/linux
make mrproper
gzcat /proc/config.gz | sed -e 's/CONFIG_USB_STORAGE=m/CONFIG_USB_STORAGE=y/g' > ./.config
make oldconfig && make && make modules_install


If your /boot is not auto-mounted, then mount it and:

Code:

make install


That should do it.

(More help on kernel compilation can be found here: http://gentoo-wiki.com/HOWTO_Compile_a_Kernel_Manually#Compiling_the_kernel)
_________________

Misanthropy 2.0 - enough hate to go around
Back to top
View user's profile Send private message
Nallelcm
n00b
n00b


Joined: 04 Jan 2006
Posts: 16

PostPosted: Wed Jan 11, 2006 3:52 pm    Post subject: Reply with quote

MrUlterior wrote:
Oh well, I suggest you try building the usb-storage into your kernel instead of as a module:

Code:

cd /usr/src/linux
make mrproper
gzcat /proc/config.gz | sed -e 's/CONFIG_USB_STORAGE=m/CONFIG_USB_STORAGE=y/g' > ./.config
make oldconfig && make && make modules_install


If your /boot is not auto-mounted, then mount it and:

Code:

make install


That should do it.

(More help on kernel compilation can be found here: http://gentoo-wiki.com/HOWTO_Compile_a_Kernel_Manually#Compiling_the_kernel)

I love you :) it works! Thx so much
_________________
- Nallelcm
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum