一、安装增强包
1、启动CentOS6.5虚拟机,点击设备à安装增强功能。
则 “光盘”VBOXADDITIONS已经挂载到 CentOS 5.5 的桌面上了.
此时 双击光盘—>双击VboxLinuxAdditions.run即可完成安装
通常情况下我们直接运行挂载到系统中的VirtualBox客户端增强功能的组件即可。
2、报错解决:笔者安装时出现报错
Bulding the VirtualBoxGuest Additions Kernel modules[failed]
Your system does not seemto be set up to build kernel modules.
Look at/var/log/vboxadd-install.log to find out what went worg. Once you havecorrected it,you run
/etc/init.d/vboxadd setupto build them
显然内核不支持缺少编译内核的相关组件,解决方法安装内核组件即可。
[root@localhost ~]# yum install kernel kernel-devel
Loaded plugins: fastestmirror, refresh-packagekit,security
Repository c6-media is listed more than once in theconfiguration
Loading mirror speeds from cached hostfile
* base:mirror.sunnyvision.com
* extras:mirror.sunnyvision.com
* updates:ftp.cuhk.edu.hk
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:2.6.32-642.1.1.el6will be installed
--> Processing Dependency: kernel-firmware >=2.6.32-642.1.1.el6 for package: kernel-2.6.32-642.1.1.el6.x86_64
--> Processing Dependency: dracut-kernel >=004-388.el6 for package: kernel-2.6.32-642.1.1.el6.x86_64
---> Package kernel-devel.x86_640:2.6.32-642.1.1.el6 will be installed
--> Running transaction check
---> Package dracut-kernel.noarch 0:004-335.el6will be updated
---> Package dracut-kernel.noarch0:004-409.el6_8.2 will be an update
--> Processing Dependency: dracut =004-409.el6_8.2 for package: dracut-kernel-004-409.el6_8.2.noarch
---> Package kernel-firmware.noarch0:2.6.32-431.el6 will be updated
---> Package kernel-firmware.noarch0:2.6.32-642.1.1.el6 will be an update
--> Running transaction check
---> Package dracut.noarch 0:004-335.el6 will beupdated
---> Package dracut.noarch 0:004-409.el6_8.2will be an update
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
kernel x86_64 2.6.32-642.1.1.el6 updates 32 M
kernel-devel x86_64 2.6.32-642.1.1.el6 updates 11 M
Updating for dependencies:
dracut noarch 004-409.el6_8.2 updates 127 k
dracut-kernel noarch 004-409.el6_8.2 updates 28 k
kernel-firmware noarch 2.6.32-642.1.1.el6 updates 28 M
Transaction Summary
========================================================================================================================================
Install 2 Package(s)
Upgrade 3 Package(s)
Total download size: 71 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): dracut-004-409.el6_8.2.noarch.rpm | 127 kB 00:01
(2/5):dracut-kernel-004-409.el6_8.2.noarch.rpm | 28 kB 00:00
(3/5): kernel-2.6.32-642.1.1.el6.x86_64.rpm | 32 MB 05:21
(4/5):kernel-devel-2.6.32-642.1.1.el6.x86_64.rpm | 11 MB 01:46
(5/5):kernel-firmware-2.6.32-642.1.1.el6.noarch.rpm | 28 MB 04:51
----------------------------------------------------------------------------------------------------------------------------------------
Total 100 kB/s | 71 MB 12:02
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating :dracut-004-409.el6_8.2.noarch 1/8
Updating :dracut-kernel-004-409.el6_8.2.noarch 2/8
Updating :kernel-firmware-2.6.32-642.1.1.el6.noarch 3/8
Installing: kernel-2.6.32-642.1.1.el6.x86_64 4/8
Installing: kernel-devel-2.6.32-642.1.1.el6.x86_64 5/8
Cleanup :dracut-kernel-004-335.el6.noarch 6/8
Cleanup :dracut-004-335.el6.noarch 7/8
Cleanup :kernel-firmware-2.6.32-431.el6.noarch 8/8
Verifying :kernel-firmware-2.6.32-642.1.1.el6.noarch 1/8
Verifying :dracut-004-409.el6_8.2.noarch 2/8
Verifying :dracut-kernel-004-409.el6_8.2.noarch 3/8
Verifying :kernel-2.6.32-642.1.1.el6.x86_64 4/8
Verifying :kernel-devel-2.6.32-642.1.1.el6.x86_64 5/8
Verifying :kernel-firmware-2.6.32-431.el6.noarch 6/8
Verifying :dracut-kernel-004-335.el6.noarch 7/8
Verifying :dracut-004-335.el6.noarch 8/8
Installed:
kernel.x86_64 0:2.6.32-642.1.1.el6 kernel-devel.x86_64 0:2.6.32-642.1.1.el6
Dependency Updated:
dracut.noarch 0:004-409.el6_8.2 dracut-kernel.noarch 0:004-409.el6_8.2 kernel-firmware.noarch0:2.6.32-642.1.1.el6
Complete!
[root@localhost ~]# yum install gcc
Loaded plugins: fastestmirror, refresh-packagekit,security
Repository c6-media is listed more than once in theconfiguration
Loading mirror speeds from cached hostfile
* base:mirror.sunnyvision.com
* extras:mirror.sunnyvision.com
* updates:ftp.cuhk.edu.hk
Setting up Install Process
No package gcc++ available.
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-17.el6 will beinstalled
--> Processing Dependency: libgomp =4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-17.el6for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: libgcc >=4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15for package: gcc-4.4.7-17.el6.x86_64
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6will be installed
--> Processing Dependency: libppl_c.so.2()(64bit)for package: cloog-ppl-0.15.7-1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit)for package: cloog-ppl-0.15.7-1.2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-17.el6 will beinstalled
--> Processing Dependency: libmpfr.so.1()(64bit)for package: cpp-4.4.7-17.el6.x86_64
---> Package libgcc.x86_64 0:4.4.7-4.el6 will beupdated
---> Package libgcc.x86_64 0:4.4.7-17.el6 willbe an update
---> Package libgomp.x86_64 0:4.4.7-4.el6 willbe updated
---> Package libgomp.x86_64 0:4.4.7-17.el6 willbe an update
--> Running transaction check
---> Package mpfr.x86_64 0:2.4.1-6.el6 will beinstalled
---> Package ppl.x86_64 0:0.10.2-11.el6 will beinstalled
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
gcc x86_64 4.4.7-17.el6 base 10 M
Installing for dependencies:
cloog-ppl x86_64 0.15.7-1.2.el6 base 93 k
cpp x86_64 4.4.7-17.el6 base 3.7 M
mpfr x86_64 2.4.1-6.el6 base 157 k
ppl x86_64 0.10.2-11.el6 base 1.3 M
Updating for dependencies:
libgcc x86_64 4.4.7-17.el6 base 103 k
libgomp x86_64 4.4.7-17.el6 base 134 k
Transaction Summary
========================================================================================================================================
Install 5 Package(s)
Upgrade 2 Package(s)
Total download size: 16 M
Is this ok [y/N]: y
Downloading Packages:
(1/7): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm | 93 kB 00:00
(2/7): cpp-4.4.7-17.el6.x86_64.rpm | 3.7 MB 00:32
(3/7): gcc-4.4.7-17.el6.x86_64.rpm | 10 MB 01:30
(4/7): libgcc-4.4.7-17.el6.x86_64.rpm | 103 kB 00:00
(5/7): libgomp-4.4.7-17.el6.x86_64.rpm |134 kB 00:00
(6/7): mpfr-2.4.1-6.el6.x86_64.rpm | 157 kB 00:01
(7/7): ppl-0.10.2-11.el6.x86_64.rpm |1.3 MB 00:11
----------------------------------------------------------------------------------------------------------------------------------------
Total 114kB/s | 16 MB 02:19
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating :libgcc-4.4.7-17.el6.x86_64 1/9
Installing: ppl-0.10.2-11.el6.x86_64 2/9
Installing: cloog-ppl-0.15.7-1.2.el6.x86_64 3/9
Updating :libgomp-4.4.7-17.el6.x86_64 4/9
Installing: mpfr-2.4.1-6.el6.x86_64 5/9
Installing: cpp-4.4.7-17.el6.x86_64 6/9
Installing: gcc-4.4.7-17.el6.x86_64 7/9
Cleanup :libgomp-4.4.7-4.el6.x86_64 8/9
Cleanup :libgcc-4.4.7-4.el6.x86_64 9/9
Verifying :libgcc-4.4.7-17.el6.x86_64 1/9
Verifying :ppl-0.10.2-11.el6.x86_64 2/9
Verifying :mpfr-2.4.1-6.el6.x86_64 3/9
Verifying :gcc-4.4.7-17.el6.x86_64 4/9
Verifying :libgomp-4.4.7-17.el6.x86_64 5/9
Verifying :cpp-4.4.7-17.el6.x86_64 6/9
Verifying :cloog-ppl-0.15.7-1.2.el6.x86_64 7/9
Verifying :libgomp-4.4.7-4.el6.x86_64 8/9
Verifying :libgcc-4.4.7-4.el6.x86_64 9/9
Installed:
gcc.x86_640:4.4.7-17.el6
Dependency Installed:
cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-17.el6 mpfr.x86_64 0:2.4.1-6.el6 ppl.x86_64 0:0.10.2-11.el6
Dependency Updated:
libgcc.x86_64 0:4.4.7-17.el6 libgomp.x86_64 0:4.4.7-17.el6
Complete!
[root@localhost ~]# yum install -y gcc gcc-c++ makekernel-devel
Loaded plugins: fastestmirror, refresh-packagekit,security
Repository c6-media is listed more than once in theconfiguration
Loading mirror speeds from cached hostfile
* base:mirror.sunnyvision.com
* extras:mirror.sunnyvision.com
* updates: ftp.cuhk.edu.hk
Setting up Install Process
Package gcc-4.4.7-17.el6.x86_64 alreadyinstalled and latest version
Package 1:make-3.81-23.el6.x86_64 alreadyinstalled and latest version
Packagekernel-devel-2.6.32-642.1.1.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.x86_64 0:4.4.7-17.el6 willbe installed
--> Processing Dependency: libstdc++-devel =4.4.7-17.el6 for package: gcc-c++-4.4.7-17.el6.x86_64
--> Processing Dependency: libstdc++ =4.4.7-17.el6 for package: gcc-c++-4.4.7-17.el6.x86_64
--> Running transaction check
---> Package libstdc++.x86_64 0:4.4.7-4.el6 willbe updated
---> Package libstdc++.x86_64 0:4.4.7-17.el6will be an update
---> Package libstdc++-devel.x86_64 0:4.4.7-17.el6will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
gcc-c++ x86_64 4.4.7-17.el6 base 4.7 M
Installing for dependencies:
libstdc++-devel x86_64 4.4.7-17.el6 base 1.6 M
Updating for dependencies:
libstdc++ x86_64 4.4.7-17.el6 base 295 k
Transaction Summary
========================================================================================================================================
Install 2 Package(s)
Upgrade 1 Package(s)
Total download size: 6.6 M
Downloading Packages:
(1/3): gcc-c++-4.4.7-17.el6.x86_64.rpm | 4.7 MB 01:10
(2/3): libstdc++-4.4.7-17.el6.x86_64.rpm | 295 kB 00:03
(3/3): libstdc++-devel-4.4.7-17.el6.x86_64.rpm | 1.6 MB 00:26
----------------------------------------------------------------------------------------------------------------------------------------
Total 67 kB/s | 6.6 MB 01:41
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : libstdc++-4.4.7-17.el6.x86_64 1/4
Installing: libstdc++-devel-4.4.7-17.el6.x86_64 2/4
Installing: gcc-c++-4.4.7-17.el6.x86_64 3/4
Cleanup : libstdc++-4.4.7-4.el6.x86_64 4/4
Verifying :gcc-c++-4.4.7-17.el6.x86_64 1/4
Verifying :libstdc++-4.4.7-17.el6.x86_64 2/4
Verifying :libstdc++-devel-4.4.7-17.el6.x86_64 3/4
Verifying :libstdc++-4.4.7-4.el6.x86_64 4/4
Installed:
gcc-c++.x86_64 0:4.4.7-17.el6
Dependency Installed:
libstdc++-devel.x86_64 0:4.4.7-17.el6
Dependency Updated:
libstdc++.x86_640:4.4.7-17.el6
Complete!
[root@localhost ~]# shutdown -r now
安装好相关内核组件,重启centos6.5并再次安装增强包即可顺利安装。
二、建立共享文件夹
1、创建共享文件夹
2、命令行操作
1)、创建共享目录
[root@localhost ~]# mkdir /mnt/share
2)、挂载共享文件
[root@localhost ~]# mount -t vboxsf share/mnt/share
[root@localhost~]# cd /mnt/share
[root@localhostshare]# ls -al
总用量 4
drwxrwxrwx. 1root root 0 6月 15 14:03 .
drwxr-xr-x. 7root root 4096 6月 15 14:06 ..
[root@localhostshare]# ls -al
总用量 12
drwxrwxrwx. 1root root 0 6月 15 2016 .
drwxr-xr-x. 7root root 4096 6月 15 14:06 ..
-rwxrwxrwx. 1root root 7277 5月 12 10:43 DNSS.txt
[root@localhostshare]#
3)、设置开机自动挂载共享文件夹,此处提供两种方法
法1,添加到/etc/fstab中
[root@localhost share]# vim /etc/fstab
#
# /etc/fstab
# Created byanaconda on Mon Jun 13 10:16:45 2016
#
# Accessiblefilesystems, by reference, are maintained under '/dev/disk'
# See manpages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=4a3834d1-7ee7-4a62-9981-02f5fd003640/ ext4 defaults 1 1
UUID=01099336-5280-425b-8f81-41eec776a624/boot ext4 defaults 1 2
UUID=19979dd3-99ed-4b33-abe9-61b5145e4b4c/home ext4 defaults 1 2
UUID=28098617-d10c-4d5e-93d8-823960863daeswap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/sr0 /mnt/iso iso9660 ro,loop 0 0
share /mnt/share vboxsf rw,gid=100,uid=1000,auto 00
[root@localhostshare]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 ext4 15G 5.1G 9.2G 36% /
tmpfs tmpfs 372M 76K 372M 1% /dev/shm
/dev/sda1 ext4 969M 54M 865M 6% /boot
/dev/sda3 ext4 14G 37M 13G 1% /home
/dev/sr0 iso9660 1.8G 1.8G 0 100% /mnt/iso
share vboxsf 222G 65G 157G 30% /mnt/share
/dev/sr1 iso9660 56M 56M 0 100% /media/VBOXADDITIONS_5.0.20_106931
[root@localhostshare]#
法2:
在系统启动时执行挂载脚本:
#vi/etc/rc.d/rc.local
在文件的最后加入上面手动挂载的命令,比如:
mount -tvboxsf share /mnt/share
[root@localhost share]# vi /etc/rc.d/rc.local
#!/bin/sh
#
# This scriptwill be executed *after* all the other init scripts.
# You can putyour own initialization stuff in here if you don't
# want to dothe full Sys V style init stuff.
touch/var/lock/subsys/local
mount -t vboxsf share /mnt/share
[root@localhost~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 ext4 15G 5.1G 9.2G 36% /
tmpfs tmpfs 372M 76K 372M 1% /dev/shm
/dev/sda1 ext4 969M 54M 865M 6% /boot
/dev/sda3 ext4 14G 37M 13G 1% /home
/dev/sr0 iso9660 1.8G 1.8G 0 100% /mnt/iso
share vboxsf 222G 65G 157G 30% /mnt/share
/dev/sr1 iso9660 56M 56M 0 100% /media/VBOXADDITIONS_5.0.20_106931
4)、取消挂载
[root@localhost ~]#umount -f /mnt/shared
5)、注意事项:
挂载时提示:/sbin/mount.vboxsf: mounting failed with the error: No suchdevice
则表示没有载入内核模块 vboxfs
[root@localhost ~]#lsmod | grep vboxsf
如果没有结果返回,说明 vboxsf确实没有载入,执行
[root@localhost ~]# modprobe vboxsf
再次执行以上步骤即可