auto-mount shared folders using fstab

Discussions about using Linux guests in VirtualBox.
Post Reply
manuli
Posts: 10
Joined: 22. Aug 2013, 09:40

auto-mount shared folders using fstab

Post by manuli »

hello,

i have tried several ways to mount my shared folders. first i mounted manually. bit annoying, then i wrote a shellscript with the commands, put it to /usrs/bin and added the directory to the rc.local file. that didnt work (double-clicking it mounted the folders, but they haven't been mounted upon reboot; maybe because expecting root pwd?).
then i tried to mount on startup via fstab using "workspace /mnt/macworkspace vboxsf defaults 0 0". still the same problem - after reboot, they are not mounted.
i am using a osx 10.8.3. host system, ubuntu 12.04 as a guest. interesting also - when the guest machine is powered off and i inspect its shared folders, there is no option for "permanent", though it being appearant when opening the shared folder options while guest system is running.

does anyone have a tip here? would appreciate a lot!

thanx in advance
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: auto-mount shared folders using fstab

Post by Perryg »

No need to make a script if you are mounting the drive in /etc/rc.local . Just put the mount statement there and it will run at login.
edit the /etc/rc.local file and add according to example below.

Code: Select all

# By default this script does nothing.

mount -t vboxsf -o rw,uid=1000,gid=1000 shared /mnt/shared

exit 0
uid & gid are your user uid & gid
shared = name you gave the share
/mnt/shared = the absolution path to the mount point
manuli
Posts: 10
Joined: 22. Aug 2013, 09:40

Re: auto-mount shared folders using fstab

Post by manuli »

thanx for your quick response! it worked indeed, but only for the first sudo-command. the following two lines seem to be ignored (or ...?)... any idea here? is there a special line-break or line-ending-character to insert?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: auto-mount shared folders using fstab

Post by Perryg »

but only for the first sudo-command
Can you explain this better? First you don't need to have sudo in the mount statement since this is being loaded at boot by the OS. Are you trying to mount more than one share?
manuli
Posts: 10
Joined: 22. Aug 2013, 09:40

Re: auto-mount shared folders using fstab

Post by manuli »

Perryg wrote:
Can you explain this better? First you don't need to have sudo in the mount statement since this is being loaded at boot by the OS. Are you trying to mount more than one share?
sorry... of course no sudo.
yes, i am trying to mount three shared folders. My thought was to just simply write the three commands to the rc.local file according your description, which would be something like:

Code: Select all


mount -t vboxsf -o rw,uid=1000,gid=1000 share /home/manuli/Share
mount -t vboxsf -o rw,uid=1000,gid=1000 workspace /home/manuli/macworkspace
mount -t vboxsf -o rw,uid=1000,gid=1000 DA /home/manuli/diplarbeit

exit 0
after reboot it mounts share to Share, but the other two are not mounted...
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: auto-mount shared folders using fstab

Post by Perryg »

Did you create the mount points?
manuli
Posts: 10
Joined: 22. Aug 2013, 09:40

Re: auto-mount shared folders using fstab

Post by manuli »

Perryg wrote:Did you create the mount points?
yes. the directories do exist.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: auto-mount shared folders using fstab

Post by Perryg »

If the names are correct (case matters) and the mount points are in fact created and the shares still do not work then you need to see what the error messages are. Look in /var/log/syslog or dmesg and see what they say.

Note: what you posted as your solution to multiple mounts is correct.
manuli
Posts: 10
Joined: 22. Aug 2013, 09:40

Re: auto-mount shared folders using fstab

Post by manuli »

Perryg wrote:If the names are correct (case matters) and the mount points are in fact created and the shares still do not work then you need to see what the error messages are. Look in /var/log/syslog or dmesg and see what they say.

Note: what you posted as your solution to multiple mounts is correct.
had a look at the syslog file. the vbox related entries would be:

Code: Select all

Aug 22 18:11:52 manuliVB kernel: [   19.255042] vboxguest: major 0, IRQ 20, I/O port d020, MMIO at 00000000f0400000 (size 0x400000)
Aug 22 18:11:52 manuliVB kernel: [   19.255045] vboxguest: Successfully loaded version 4.2.16 (interface 0x00010004)
...
Aug 22 18:11:52 manuliVB kernel: [   20.237650] vboxsf: Successfully loaded version 4.2.16 (interface 0x00010004)
...
Aug 22 18:31:35 manuliVB kernel: [    0.891985] ata2.00: ATAPI: VBOX CD-ROM, 1.0, max UDMA/133
...
Aug 22 18:31:35 manuliVB kernel: [    0.892876] scsi 1:0:0:0: CD-ROM            VBOX     CD-ROM           1.0  PQ: 0 ANSI: 5
...
Aug 22 18:31:35 manuliVB kernel: [    1.888374] ata3.00: ATA-6: VBOX HARDDISK, 1.0, max UDMA/133
Aug 22 18:31:35 manuliVB kernel: [    1.888377] ata3.00: 40960000 sectors, multi 128: LBA48 NCQ (depth 31/32)
Aug 22 18:31:35 manuliVB kernel: [    1.888528] ata3.00: configured for UDMA/133
Aug 22 18:31:35 manuliVB kernel: [    1.888664] scsi 2:0:0:0: Direct-Access     ATA      VBOX HARDDISK    1.0  PQ: 0 ANSI: 5
Aug 22 18:31:35 manuliVB kernel: [    1.888891] sd 2:0:0:0: [sda] 40960000 512-byte logical blocks: (20.9 GB/19.5 GiB)
Aug 22 18:31:35 manuliVB kernel: [    1.888980] sd 2:0:0:0: [sda] Write Protect is off
Aug 22 18:31:35 manuliVB kernel: [    1.888984] sd 2:0:0:0: [sda] Mode Sense: 00 3a 00 00
Aug 22 18:31:35 manuliVB kernel: [    1.889013] sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
Aug 22 18:31:35 manuliVB kernel: [    1.889288] sd 2:0:0:0: Attached scsi generic sg1 type 0
...
Aug 22 19:04:04 manuliVB kernel: [   62.199340] VBoxGuest: VBoxGuestCommonGuestCapsAcquire: pSession(0xffff880070033e10), OR(0x0), NOT(0xffffffff), flags(0x0)
Aug 22 19:04:04 manuliVB kernel: [   62.199988] VBoxGuest: VBoxGuestCommonGuestCapsAcquire: pSession(0xffff880079356a10), OR(0x0), NOT(0xffffffff), flags(0x0)
Aug 22 19:04:04 manuliVB kernel: [   62.201812] VBoxGuest: VBoxGuestCommonGuestCapsAcquire: pSession(0xffff880079356a10), OR(0x0), NOT(0xffffffff), flags(0x0)
Aug 22 19:04:04 manuliVB kernel: [   62.204040] VBoxGuest: VBoxGuestCommonGuestCapsAcquire: pSession(0xffff880071817810), OR(0x0), NOT(0xffffffff), flags(0x0)
Aug 22 19:04:04 manuliVB kernel: [   62.206543] VBoxGuest: VBoxGuestCommonGuestCapsAcquire: pSession(0xffff880078f77810), OR(0x0), NOT(0xffffffff), flags(0x0)
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: auto-mount shared folders using fstab

Post by Perryg »

That's fine but the error probably will not show as a VBox but a different error. search for vboxsf or error
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: auto-mount shared folders using fstab

Post by Perryg »

Do the other shares work if you manually mount them?
manuli
Posts: 10
Joined: 22. Aug 2013, 09:40

Re: auto-mount shared folders using fstab

Post by manuli »

Perryg wrote:That's fine but the error probably will not show as a VBox but a different error. search for vboxsf or error
searching for "error" results in several of these:

Code: Select all

Aug 22 19:03:14 manuliVB kernel: [   13.738442] EXT4-fs (sda1): re-mounted. Opts: errors=remount-ro
searching for "vboxsf" in several of those:

Code: Select all

Aug 22 16:57:20 manuliVB kernel: [   13.374860] vboxsf: Successfully loaded version 4.2.16 (interface 0x00010004)
manuli
Posts: 10
Joined: 22. Aug 2013, 09:40

Re: auto-mount shared folders using fstab

Post by manuli »

mounting manually throws a protocol error. :(
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: auto-mount shared folders using fstab

Post by Perryg »

This is almost always a share name issue (case does not match) or the mount point either does not exist of case is wrong.
Look closely.
manuli
Posts: 10
Joined: 22. Aug 2013, 09:40

Re: auto-mount shared folders using fstab

Post by manuli »

you were right. there were some name issues... stared too long at the screen thus haven't seen it. now it works! thank you so much for your support! :)
Post Reply