VirtualBox: CentOS设置共享文件夹

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/IOIO_/article/details/84000930

VirtualBox: CentOS设置共享文件夹

主机

选择一个文件夹作为共享文件夹,如:

VboxShare


虚拟机

新建一个文件夹作为共享文件夹,如:

/home/share


挂载映射

mount -t vboxsf VboxShare /home/share

# 查看[如果成功则可以看到本机的文件]
cd /home/share
ls

开机自动挂载

普通用户状态下:
$ vi ~/.bashrc
mount -t vboxsf VboxShare /home/share
普通用户执行不了mount...,导致没有什么作用,还是看不到内容。

若在root状态下:
# vi ~/.bashrc
mount -t vboxsf VboxShare /home/share
重启后,普通用户状态下同样看不到内容,共享文件夹为空。需要先进入root下,才会自动挂载,然后root下可以看到共享文件夹内容,再切换到普通用户下,亦可看到内容。

开机自动挂载改进

You have to do two things below:

  1. add user dijk[your user name] to vboxsf group
  2. check auto-mount on vbox configuration gui

Add user dijk to vboxsf group

$ sudo usermod -aG vboxsf dijk

or

$ sudo gpasswd -a dijk vboxsf

check auto-mount on vbox configuration gui[勾选自动挂载]

After these two steps, both dijk & root can go into sf_VboxShare[desktop & terminal].

sf_VboxShare is the shared directory[/media/sf_VboxShare].


Attention

There may be a problem when execute the command below:

$ sudo usermod -aG vboxsf dijk

or

$ sudo gpasswd -a dijk vboxsf

Problem: “dijk is not in the sudoers file. This incident will be reported.”

You can find a solution here.

猜你喜欢

转载自blog.csdn.net/IOIO_/article/details/84000930