1、先確保virtualBox安裝目錄下有對應的文件VBoxGuestAdditions.iso
2、點擊設備下的“安裝增強功能”,之后再centos可視化界面一步一步點擊即可
3、virtualBox設置共享目錄
4、在linux上輸入mount -t vboxsf www /var/www(ps:不要在/var/www目錄上執行該命令),沒有報錯到這里就可以了
5、執行4時報錯,/sbin/mount.vboxsf: mounting failed with the error: No such device,解決方法:
yum clean all
yum update
yum install -y kernel kernel-devel kernel-headers gcc make
reboot
cd /opt/VBoxGuestAdditions-*/init
./vboxadd setup
reboot,
之后再執行4即可
6、設置開機自動掛載,vi /etc/rc.local,mount -t vboxsf www /var/www,chmod +x /etc/rc.d/rc.local
參考url:https://blog.csdn.net/daiyudong2020/article/details/58073520