解决WIN7与虚拟机CentOS的文件夹共享问题

一、系统与软件

WIN7 64bit、VirtualBox 5.0.14、CentOS 6.5、SecureCRT 7.2.3

二、使用文件夹共享需要安装增强功能,但是安装时无法读取光盘iso文件

三、为了方便操作,配置静态IP,并使用CRT连接上去(参考http://my.oschina.net/allman90/blog/294847?fromerr=CotpElUe

[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0                               //指出设备名称
HWADDR=08:00:27:20:01:4A                  //硬件Mac地址
TYPE=Ethernet                             //网络类型
UUID=c1d0e14c-cd39-4817-af44-37daca90c1f9 //设备UUID编号
ONBOOT=yes                                //是否启动应用
NM_CONTROLLED=yes                         //设备是否被NetworkManager管理
BOOTPROT=static                           //启动类型 dhcp|static
BROADCAST=192.168.88.203                  //广播地址
IPADDR=192.168.88.111                     //IP地址
NETMASK=255.255.255.0                     //子网掩码
NETWORK=192.168.88.0                      //网络地址
GATEWAY=192.168.88.254                    //网关地址
DNS1=8.8.8.8                              //DNS
[[email protected] ~]# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]
[[email protected] ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:57:73:2C
          inet addr:192.168.88.111  Bcast:192.168.88.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe57:732c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9520 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5348 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:12491456 (11.9 MiB)  TX bytes:349639 (341.4 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
[[email protected] ~]# ping www.baidu.com
PING www.baidu.com (111.13.100.92) 56(84) bytes of data.
64 bytes from 111.13.100.92: icmp_seq=1 ttl=49 time=59.1 ms
64 bytes from 111.13.100.92: icmp_seq=2 ttl=49 time=65.4 ms

四、既然无法读取光盘,便采用FTP上传,配置FTP(参考http://os.51cto.com/art/201408/448630.htm

[[email protected] ~]# yum -y install vsftpd                                        // 安装FTP
...
Complete!
[[email protected] ~]# service vsftpd start                                         // 启动FTP
Starting vsftpd for vsftpd:                                [  OK  ]
[[email protected] ~]# vi /etc/sysconfig/iptables                                   // 防火墙开启21端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
[[email protected] ~]# service iptables restart                                     // 重启防火墙
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
[[email protected] ~]# cat /etc/passwd | grep ftp                                   // 新增一个账户ftpuser,并设置密码
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
[[email protected] ftp]# useradd -g ftp ftpuser
[[email protected] ftp]# passwd ftpuser
Changing password for user ftpuser.

无法读取目录     

[[email protected] ~]# getsebool -a | grep ftp                        // 开启外网访问
allow_ftpd_full_access --> off
ftp_home_dir --> off
[[email protected] ~]# setsebool -P allow_ftpd_full_access 1
[[email protected] ~]# setsebool -P ftp_home_dir 1
[[email protected] ~]# vi /etc/vsftpd/vsftpd.conf                     // 设定passive模式端口范围
pasv_min_port=30000
pasv_max_port=30999
[[email protected] ~]# service vsftpd restart                         // 重启FTP
[[email protected] ~]# vi /etc/sysconfig/iptables                     // 开启防火墙对应范围端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 30000:30999 -j ACCEPT
[[email protected] ~]# service iptables restart                       // 重启防火墙

正常连接上虚拟机       

把VirtualBox安装目录下的 VBoxGuestAdditions.iso 解压,并通过FTP客户端filezilla上传到虚拟机

[[email protected] ~]# cd /home/ftpuser/
[[email protected] ftpuser]# ll
total 4
drwxr-xr-x. 6 ftpuser ftp 4096 Apr 19 22:28 VBoxGuestAdditions

五、开始安装增强功能

[[email protected] ~]# cd /home/ftpuser/VBoxGuestAdditions/
[[email protected] VBoxGuestAdditions]# ll
total 51296
drwxr-xr-x. 2 ftpuser ftp     4096 Apr 19 22:28 32Bit
drwxr-xr-x. 2 ftpuser ftp     4096 Apr 19 22:28 64Bit
-rw-r--r--. 1 ftpuser ftp      647 Apr 19 22:28 AUTORUN.INF
-rw-r--r--. 1 ftpuser ftp     6909 Apr 19 22:28 autorun.sh
drwxr-xr-x. 2 ftpuser ftp     4096 Apr 19 22:28 cert
drwxr-xr-x. 2 ftpuser ftp     4096 Apr 19 22:28 OS2
-rw-r--r--. 1 ftpuser ftp     5519 Apr 19 22:28 runasroot.sh
-rw-r--r--. 1 ftpuser ftp  7515597 Apr 19 22:28 VBoxLinuxAdditions.run
-rw-r--r--. 1 ftpuser ftp 17449472 Apr 19 22:28 VBoxSolarisAdditions.pkg
-rw-r--r--. 1 ftpuser ftp 16950032 Apr 19 22:28 VBoxWindowsAdditions-amd64.exe
-rw-r--r--. 1 ftpuser ftp   316016 Apr 19 22:28 VBoxWindowsAdditions.exe
-rw-r--r--. 1 ftpuser ftp 10245216 Apr 19 22:28 VBoxWindowsAdditions-x86.exe
[[email protected] VBoxGuestAdditions]# chmod +x runasroot.sh
[[email protected] VBoxGuestAdditions]# ./runasroot.sh
Usage: runasroot.sh DESCRIPTION COMMAND [ADVICE]

Attempt to execute COMMAND with root privileges, displaying DESCRIPTION if
possible and displaying ADVICE if possible if no su(1)-like tool is available.
[[email protected] VBoxGuestAdditions]# chmod +x VBoxLinuxAdditions.run
[[email protected] VBoxGuestAdditions]# ./VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.14 Guest Additions for Linux............
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
Building the VirtualBox Guest Additions kernel modules
The gcc utility was not found. If the following module compilation fails then
this could be the reason and you should try installing it.

The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.
The missing package can be probably installed with
yum install kernel-devel-2.6.32-358.el6.x86_64

Building the main Guest Additions module                   [FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions              [  OK  ]
Installing the Window System drivers
Could not find the X.Org or XFree86 Window System, skipping.
[[email protected] VBoxGuestAdditions]# cat /var/log/vboxadd-install.log
/tmp/vbox.0/Makefile.include.header:97: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.

查找报错 Building the main Guest Additions module [FAILED](参考    http://www.xuebuyuan.com/2039380.html

[[email protected] VBoxGuestAdditions]# yum -y install gcc make gcc-c++
[[email protected] VBoxGuestAdditions]# yum -y install kernel
[[email protected] VBoxGuestAdditions]# yum -y install kernel-devel
[[email protected] VBoxGuestAdditions]# yum -y install kernel-headers

重启CentOS并再次执行VBoxLinuxAdditions.run,依旧报错(参考 http://askubuntu.com/questions/22743/how-do-i-install-guest-additions-in-a-virtualbox-vm

[[email protected] VBoxGuestAdditions]# yum update
[[email protected] ~]# /opt/VBoxGuestAdditions-5.0.14/uninstall.sh
[[email protected] ~]# /home/ftpuser/VBoxGuestAdditions/VBoxLinuxAdditions.run
[[email protected] ~]# cat /var/log/vboxadd-install.log
/bin/sh: perl: command not found

这次变成报没有 perl,于是  yum -y perl  补齐

再次进行安装

[[email protected] ~]# /opt/VBoxGuestAdditions-5.0.14/uninstall.sh
[[email protected] ~]# /home/ftpuser/VBoxGuestAdditions/VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.14 Guest Additions for Linux............
VirtualBox Guest Additions installer
You appear to have a version of the VBoxGuestAdditions software
on your system which was installed from a different source or using a
different type of installer.  If you installed it from a package from your
Linux distribution or if it is a default part of the system then we strongly
recommend that you cancel this installation and remove it properly before
installing this version.  If this is simply an older or a damaged
installation you may safely proceed.

Do you wish to continue anyway? [yes or no]
yes
Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
grep: /opt/VBoxGuestAdditions-*/init/*: No such file or directory
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module                   [  OK  ]
Building the shared folder support module                  [  OK  ]
Building the OpenGL support module                         [FAILED]
(Look at /var/log/vboxadd-install.log to find out what went wrong. The module is not built but the others are.)
Doing non-kernel setup of the Guest Additions              [  OK  ]
Starting the VirtualBox Guest Additions                    [  OK  ]
Installing the Window System drivers
Could not find the X.Org or XFree86 Window System, skipping.

终于成功了,其中 OpenGL 失败是因为我的CentOS是精简版没有界面的!

六、设置共享

[[email protected] ~]# ll /media/
total 4
drwxrwx---. 1 root vboxsf 4096 Mar 27 16:59 sf_win_www
时间: 2024-11-02 17:44:48

解决WIN7与虚拟机CentOS的文件夹共享问题的相关文章

vmtools安装后不能实现开发主机和Linux虚拟机之间的文件夹共享的问题解决

以前用ubuntu12.04一直没有问题.最近心血来潮将版本更新到最新后发现共享文件夹不能用了.所以就重新安装vmtools.但是在编译vmhgfs时报错.错误如下: In file included from ./arch/x86/include/asm/percpu.h:44:0, from ./arch/x86/include/asm/preempt.h:5, from include/linux/preempt.h:18, from include/linux/spinlock.h:50

无法更新运行时文件夹共享状态:在客户机操作系统内装载共享文件夹文件系统时出错--解决办法

1.问题描述: 在物理主机和虚拟机CentOS6.4共享文件的时候出现:无法更新运行时文件夹共享状态:在客户机操作系统内装载共享文件夹文件系统时出错 其他症状: vmware-hgfsclient  能够看到共享的文件夹名字 mount.vmhgfs  .host:/ /mnt  报错: Error: cannot mount filesystem: No such device 2.解决思路 /etc/vmware-tools/services.sh restart 如果出现FAILD yum

2017-7-19-每日博客-关于Linux下的CentOS中文件夹基本操作命令.doc

CentOS中文件夹基本操作命令 文件(夹)查看类命令 ls--显示指定目录下内容 说明:ls 显示结果以不同的颜色来区分文件类别.蓝色代表目录,灰色代表普通文件,绿色代表可执行文件,红色代表压缩文件,浅蓝色代表链接文件. -a---显示所有内容,包括隐藏文件 说明:在Linux系统中,以"."开头的就是隐藏文件或隐藏目录. -l---以长格式(内容更详细)显示文件或目录的详细信息. 说明:ls -l命令可以简写成ll, 输出的信息共分为7组:文件类别和文件权限.链接数或子目录个数.文

MyEclipse破解失败的解决办法 | 找不到plugin文件夹

文章出处:http://www.lihuoqing.cn/tool/803.html 感谢大侠的帮助. 前几天在Ubuntu装上了MyEclipse10.6最新版,用着还不错,一直都盲目的追求新版,也不知道有些什么新东西值得期待的,今天心情大好,翻出天朝去往西方MyEclipse官网把新版特征偷了过来,哈哈. 一.MyEclipse10.6 Enterprise WorkBench新版特征 New Editors in 10.6 Hibernate 4.1 New Server Support

freebsd 与win7进行文件夹共享

以前用的是ubuntu ,系统安装好之后,再装个vmware tools 就可以设置文件夹共享,进入/mnt/hgfs 找到共享文件夹 现在工作要用到freebsd ,要装vmware tools确实麻烦,试了几次都没有成功过,找了一下其他方法共享. http://blog.chinaunix.net/uid-22914802-id-1765557.html 用安装任何其他软件.直接用命令 mount_smbfs -I windowsip //[email protected]/共享文件夹 /m

WIN7中如何设置文件夹共享

通常,在局域网内共享文件是非常有用的,也是一种非常好的共享资源和传送文件的方式.下面我将跟大家分享一下win7系统中局域网内共享文件夹的办法: 第一步.共享文件夹的设置,找到我们需要共享的文件夹,然后右击->属性,打开如下对话框: 打开共享选项,出现如下对话框: 在这里,我们选择Everyone角色,点击添加,并为Everyone角色设置权限,读取或者读/写权限,如图所示: 点击共享,然后回到属性对话框,我们再次选择高级共享,打开如下对话框,选择共享此文件夹: 第二步.网络的设置:打开网络和共享

XE6移动开发环境搭建之IOS篇(5):解决Windows和虚拟机下Mac OSX的共享问题(有图有真相)

XE6移动开发环境搭建之IOS篇(5):解决Windows和虚拟机下Mac OSX的共享问题(有图有真相) 2014-08-20 20:28 网上能找到的关于Delphi XE系列的移动开发环境的相关文章甚少,本文尽量以详细的内容.傻瓜式的表达来告诉你想要的答案. 在安装XE6 PAServer前,我们先解决Windows和虚拟机下Mac的文件共享问题,由于虚拟机和我们安装的XE6是同一台电脑,所以此问题很好解决.网上相传有很多的共享大法,但是在WIN7这种权限管制得过份的系统下显得相对复杂了,

VMware中linux与window文件夹共享

在虚拟机下来实现在windows下共享一个文件夹: (前提已安装完成vmtools:http://blog.csdn.net/pipisorry/article/details/21318931) 打开VMware->工具栏->虚拟机->选择 设置->选项 共享文件夹 点添加,按提示来添加一个windows下的文件夹.在/mnt/hgfs下就是你在windows下共享的文件夹了 不行的话直接将文件(夹)从linux拖曳到windows桌面上(文件夹中不能包含快捷方式) 两台wind

server 2008 文件夹共享用户名密码,及用户对应文件夹权限划分

最近遇到的一个奇葩的问题服务器文件夹共享,虽然之前已经设置好,有先例,但是这里还是要提一下,一来巩固自己对这块的认知,二来,为以后查找方便:服务器server 2008 设置用户登陆共享文件夹:新建立文件demo,作为共享的母文件夹:(未遇到问题"坑"可不看)建立共享步骤:第一步:右键文件夹(demo属性)-->共享--↓共享:这里可以直接设置添加指定的账户账户访问此文件夹账户问题:添加账户: 首先打开[运行]程序: 运行中输入'CMD': 然后在上面输入'compmgmt.ms