Results 1 to 8 of 8
I've got a script that includes "sudo mount /dev/sda1 /media" for my internal hdd that has all of my music on it. It was getting to be a pain to ...
- 08-10-2011 #1Just Joined!
- Join Date
- Feb 2011
- Posts
- 42
Trouble with init.d auto startup script(s)
I've got a script that includes "sudo mount /dev/sda1 /media" for my internal hdd that has all of my music on it. It was getting to be a pain to open nautilus and click media before rhythmbox would be able to read anything in the library. This script helped, but after a few minutes it seems to unmount itself again and rhythmbox is empty, forcing me to mount it in nautilus the old way to keep it there.
Another problem, do these scripts support multiple lines? Only the sudo mount...etc. line is followed, others (such as "evolution" to auto open my mail on boot) are ignored.
- 08-10-2011 #2Just Joined!
- Join Date
- Apr 2005
- Location
- Perth, Western Australia
- Posts
- 11
I would have thought this would be placed in the /etc/fstab. that way it loaded every time the system is rebooted.
ex:
/etc/fstab
/dev/sda1 /media [fs] defaults 0 0
Then if you are running a samba server add this to the /etc/samba/smb.conf
[music]
browseable = Yes
comment = Music Drive 1
inherit acls = Yes
path = /media
read only = No
valid users = [list of users who need access], remove the "[]"
- 08-11-2011 #3Linux Newbie
- Join Date
- Nov 2008
- Location
- Tokyo, Japan
- Posts
- 243
Is your music on removable media? "/dev/sda1" is typically your root filesystem, and not something you need to mount by hand. Isn't it "/dev/sdc1" or something like that?
If you are using removable media, the "/media" directory is used by an auto-mounting program like "gvfs-mount". If you use the system-level "mount" command, you interfere with the workings of this program; "gvfs-mount" expects there to be a sub-directory for every volume you mount to it, for example "/media/MyMusic" or "/media/DVD_Video". You should never mount to "/media" directly, you need to create a subdirectory "/media/MyMusic" first, then "mount /dev/sdc1 /media/MyMusic".
However, "gvfs-mount" does all of this for you -- it finds the volume label for the removable media, creates the sub-directory in "/media" based on the volume label, and then calls "mount". So instead of "sudo mount", change your script to call this:I am guessing the problem you have is caused because gvfs-mount sees you mounted to "/media", so when you create a sub-directory in "/media" you are actually creating a sub-directory on the removable media itself. "gvfs-mount" does not want to do that because if it mounts anything to a sub-directory of a "/media" you will not be able to safely unmount the device mounted to "/media" until you unmount all other devices mounted to sub-directories of "/media". So, to prevent this situation, it unmounts "/media" automatically, then proceeds as usual.Code:##sudo mount /dev/sdc1 /mount ##BAD gvfs-mount -d /dev/sdc1 ##GOOD ##gvfs-mount -u /media/* ##unmounts all devices mounted by gvfs-mount
If your are using a dedicated disk, not removable media, then do as JLmiller suggested, and modify your "/etc/fstab" file to automatically mount "/dev/sdc1" or whatever at startup. And don't use the "/media" directory for dedicated disks, you will confuse "gvfs-mount". Use a subdirectory of "/mnt" instead, like "/mnt/music". So the line you need to add to "/etc/fstab" should look like this:Code:/dev/sdc1 /mnt/music ext3 defaults 0 0
- 08-11-2011 #4Just Joined!
- Join Date
- Jul 2007
- Posts
- 6
ramin.honary said it. These instructions should work. Adding the given line to fstab should do the trick.
- 08-11-2011 #5Just Joined!
- Join Date
- Feb 2011
- Posts
- 42
I'll give it a go later today when I get home, though my issue was not that it isn't mounting- but that it unmounts after a few minutes. The script is running (at least the first line of it/only the media mounting part) but becomes useless after a short period.
Edit: For some reason (okay, for reason due to inexperience) I thought fstab was a folder, so mv customscript /etc/fstab of course wiped the original file and caused a plundering crash on reboot. Insert slackware disk, rename fstab backup and I'm good. Learning lesson.
Then I tried adding the line to fstab itself (it's a dedicated disk, always connected in the box) and got the same error I did when I swiped the fstab earlier: "errors mounting /mnt/music" (minus the torrent of errors I got after that, however). Pressed s for skip and it loads, but of course it's not mounted.
Also, gvfs-mount is not a command, nor a package I can install? Lastly, I've double checked, and sda1 is the media drive, sdb1 the main drive. Not sure what happened there.Last edited by nessonic; 08-11-2011 at 03:16 PM.
- 08-14-2011 #6Just Joined!
- Join Date
- Jul 2007
- Posts
- 6
Did you create a directory called "music" in /mnt ? The filesystem on sda1 may not be ext3.
If its a fat32 (Microsoft format) swap the
/dev/sdc1 /mnt/music ext3 defaults 0 0
for
/dev/sdc1 /mnt/music vfat rw,nosuid,nodev 0 0
in fstab and try.
- 08-14-2011 #7Just Joined!
- Join Date
- Feb 2011
- Posts
- 42
I used "sudo mount /dev/sda1 /mnt/media" and it works successfully. When I ssh login to the computer, I get a "dev/sda1 will be checked for errors on next bootup," and indeed boottime is a noticeable ~5-10 seconds longer, but it works.
dopplerduck: why did you put /dev/sdc1 when earlier in your post you recognized my media drive is sda1? Was that an error or would there be a point in changing it to sdc1?
- 08-16-2011 #8Just Joined!
- Join Date
- Jul 2007
- Posts
- 6
Oops! I just cut-pasted from my fstab. It was an error.
I'm glad it worked out for you.


1Likes
Reply With Quote