首页 技术 正文
技术 2022年11月15日
0 收藏 417 点赞 2,312 浏览 8536 个字

一、系统与软件

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

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

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

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

[root@pc ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 //指出设备名称
HWADDR=:::::4A //硬件Mac地址
TYPE=Ethernet //网络类型
UUID=c1d0e14c-cd39--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
[root@pc ~]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
[root@pc ~]# ifconfig
eth0 Link encap:Ethernet HWaddr :::::2C
inet addr:192.168.88.111 Bcast:192.168.88.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe57:732c/ Scope:Link
UP BROADCAST RUNNING MULTICAST MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (11.9 MiB) TX bytes: (341.4 KiB)lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::/ Scope:Host
UP LOOPBACK RUNNING MTU: Metric:
RX packets: errors: dropped: overruns: frame:
TX packets: errors: dropped: overruns: carrier:
collisions: txqueuelen:
RX bytes: (0.0 b) TX bytes: (0.0 b)
[root@pc ~]# ping www.baidu.com
PING www.baidu.com (111.13.100.92) () bytes of data.
bytes from 111.13.100.92: icmp_seq= ttl= time=59.1 ms
bytes from 111.13.100.92: icmp_seq= ttl= time=65.4 ms

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

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

[root@pc ~]# yum -y install vsftpd                                        // 安装FTP
...
Complete!
[root@pc ~]# service vsftpd start // 启动FTP
Starting vsftpd for vsftpd: [ OK ]
[root@pc ~]# vi /etc/sysconfig/iptables // 防火墙开启21端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport -j ACCEPT
[root@pc ~]# 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 ]
[root@pc ~]# cat /etc/passwd | grep ftp // 新增一个账户ftpuser,并设置密码
ftp:x:::FTP User:/var/ftp:/sbin/nologin
[root@pc ftp]# useradd -g ftp ftpuser
[root@pc ftp]# passwd ftpuser
Changing password for user ftpuser.

无法读取目录     解决WIN7与虚拟机CentOS的文件夹共享问题

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

正常连接上虚拟机       解决WIN7与虚拟机CentOS的文件夹共享问题

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

[root@pc ~]# cd /home/ftpuser/
[root@pc ftpuser]# ll
total
drwxr-xr-x. ftpuser ftp Apr : VBoxGuestAdditions

五、开始安装增强功能

[root@pc ~]# cd /home/ftpuser/VBoxGuestAdditions/
[root@pc VBoxGuestAdditions]# ll
total
drwxr-xr-x. ftpuser ftp Apr : 32Bit
drwxr-xr-x. ftpuser ftp Apr : 64Bit
-rw-r--r--. ftpuser ftp Apr : AUTORUN.INF
-rw-r--r--. ftpuser ftp Apr : autorun.sh
drwxr-xr-x. ftpuser ftp Apr : cert
drwxr-xr-x. ftpuser ftp Apr : OS2
-rw-r--r--. ftpuser ftp Apr : runasroot.sh
-rw-r--r--. ftpuser ftp Apr : VBoxLinuxAdditions.run
-rw-r--r--. ftpuser ftp Apr : VBoxSolarisAdditions.pkg
-rw-r--r--. ftpuser ftp Apr : VBoxWindowsAdditions-amd64.exe
-rw-r--r--. ftpuser ftp Apr : VBoxWindowsAdditions.exe
-rw-r--r--. ftpuser ftp Apr : VBoxWindowsAdditions-x86.exe
[root@pc VBoxGuestAdditions]# chmod +x runasroot.sh
[root@pc 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()-like tool is available.
[root@pc VBoxGuestAdditions]# chmod +x VBoxLinuxAdditions.run
[root@pc VBoxGuestAdditions]# ./VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0. 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.-.el6.x86_64Building 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.
[root@pc VBoxGuestAdditions]# cat /var/log/vboxadd-install.log
/tmp/vbox./Makefile.include.header:: *** 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

[root@pc VBoxGuestAdditions]# yum -y install gcc make gcc-c++
[root@pc VBoxGuestAdditions]# yum -y install kernel
[root@pc VBoxGuestAdditions]# yum -y install kernel-devel
[root@pc VBoxGuestAdditions]# yum -y install kernel-headers

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

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

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

再次进行安装

[root@pc ~]# /opt/VBoxGuestAdditions-5.0./uninstall.sh
[root@pc ~]# /home/ftpuser/VBoxGuestAdditions/VBoxLinuxAdditions.run
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0. 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是精简版没有界面的!

六、设置共享

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

[root@pc ~]# ll /media/
total
drwxrwx---. root vboxsf Mar : sf_win_www

———————————-2019-01-10———————————-

 [root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
% /
tmpfs % /dev/shm
/dev/sda1 % /boot
.host://www 165686344 81123004 84563340 49% /datas/htdocs
.host://log 165686344 81123004 84563340 49% /datas/log
.host://vmware 157300384 89902340 67398044 58% /datas/vmware
[root@localhost ~]# vmware-hgfsclient #查看共享目录
www
vmware
log
python
[root@localhost ~]# mount -t vmhgfs .host:/python /datas/python #挂载
Error: cannot canonicalize mount point: No such file or directory
[root@localhost ~]# mkdir /datas/python
[root@localhost ~]# mount -t vmhgfs .host:/python /datas/python
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
% /
tmpfs % /dev/shm
/dev/sda1 % /boot
.host:/www 165686344 81123004 84563340 49% /datas/htdocs
.host:/log 165686344 81123004 84563340 49% /datas/log
.host:/vmware 157300384 89902340 67398044 58% /datas/vmware
.host:/python 165686344 81123004 84563340 49% /datas/python
[root@localhost ~]# ll /datas/python/
total
-rwxrwxrwx root root May .log
[root@localhost ~]# vim /etc/fstab #自动挂载
.host:/python /datas/python vmhgfs iocharset=utf8,rw,uid=www,gid=www 0 1
[root@localhost ~]# init
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
% /
tmpfs % /dev/shm
/dev/sda1 % /boot
.host:/www 165686344 81123004 84563340 49% /datas/htdocs
.host:/log 165686344 81123004 84563340 49% /datas/log
.host:/vmware 157300384 89902340 67398044 58% /datas/vmware
.host:/python 165686344 81123004 84563340 49% /datas/python

https://blog.csdn.net/qq_30309813/article/details/79830356
https://www.cnblogs.com/qiyebao/p/4484047.html

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,031
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,520
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,368
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,148
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,781
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,859