用VMWare workstation自带工具包“VMware Tools/”中的脚本:VMwareTools/vmware-tools-distrib/vmware-install.pl,安装VMwareTools失败,由于版本不匹配报错如下:
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-45-generic'
Makefile:975: "Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel"
CC [M] /tmp/modconfig-CFDksW/vmhgfs-only/message.o
CC [M] /tmp/modconfig-CFDksW/vmhgfs-only/dir.o
/tmp/modconfig-CFDksW/vmhgfs-only/dir.c: In function ‘HgfsDirLlseek’:
/tmp/modconfig-CFDksW/vmhgfs-only/dir.c:717:16: error: ‘struct inode’ has no member named ‘i_mutex’
mtx = &inode->i_mutex;
^
scripts/Makefile.build:332: recipe for target '/tmp/modconfig-CFDksW/vmhgfs-only/dir.o' failed
make[2]: *** [/tmp/modconfig-CFDksW/vmhgfs-only/dir.o] Error 1
Makefile:1551: recipe for target '_module_/tmp/modconfig-CFDksW/vmhgfs-only' failed
make[1]: *** [_module_/tmp/modconfig-CFDksW/vmhgfs-only] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-45-generic'
Makefile:120: recipe for target 'vmhgfs.ko' failed
make: *** [vmhgfs.ko] Error 2
make: Leaving directory '/tmp/modconfig-CFDksW/vmhgfs-only'
虽然有解决方法,但是比较繁琐,因此不采用自带脚本安装旧版本,而是从git库中获取新版本补丁,采用傻瓜式方法执行脚本来安装:
#确保 open-vm-tools没有安装
sudo apt-get remove open-vm-tools
#确保完成更新
sudo apt-get update
#确保安装git
sudo apt-get install git
#获取patch
sudo git clone https://github.com/rasa/vmware-tools-patches.git
#进入patch目录
cd vmware-tools-patches
#下载最新版本(补丁)
sudo ./download-tools.sh latest
#解压缩包
sudo ./untar-and-patch.sh
#运行编译脚本,编译并安装VMware Tools
sudo ./compile.sh
#脚本内容
kangruojin@kangruojin:~/vmware-tools-patches$ cat compile.sh
#!/usr/bin/env bash# compile and install VMware Tools
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ ! -d vmware-tools-distrib ]]; then
echo $0: Error: Directory not found: vmware-tools-distrib >&2
exit 3
fiif hash vmware-uninstall-tools.pl >/dev/null 2>&1; then
sudo vmware-uninstall-tools.pl
fiif [[ -n "$1" ]]; then
VMWARE_INSTALL_OPTIONS="$1"
fipushd vmware-tools-distrib >/dev/null
if hash systemctl >/dev/null 2>&1; then
echo "Creating empty init dirs for backwards compatibility"
for x in {0..6}; do mkdir -p /etc/init.d/rc${x}.d; done
sudo cp $SCRIPT_DIR/patches/vmware-tools.service /etc/systemd/system/
sudo systemctl enable vmware-tools.service
echo "Added and enabled VMware Tools systemd service"
fiif sudo ./vmware-install.pl --help 2>&1 | grep -q 'force-install'; then
VMWARE_INSTALL_OPTIONS="--force-install"
fisudo ./vmware-install.pl --default $VMWARE_INSTALL_OPTIONS
sudo ./bin/vmware-config-tools.pl --defaultpopd >/dev/null
kangruojin@kangruojin:~/vmware-tools-patches$
安装完毕,通过(虚拟机-->设置-->选项-->共享文件夹-->总是启用-->添加-->选择路径并设定共享文件夹名称-->下一步-->完成-->确定):
在/mnt/hgfs下便是共享的文件夹/目录:
#未挂载共享目录之前
kangruojin@kangruojin:/$ ls /mnt/hgfs/
ls: 无法访问'/mnt/hgfs/': 输入/输出错误
#挂载共享目录之后
kangruojin@kangruojin:/$ ls /mnt/hgfs/
workspace
kangruojin@kangruojin:/$
kangruojin@kangruojin:~$ cd /mnt/hgfs/workspace/
kangruojin@kangruojin:/mnt/hgfs/workspace$ ll
总用量 53
drwxrwxrwx 1 root root 4096 10月 20 15:52 ./
dr-xr-xr-x 1 root root 4192 3月 29 22:29 ../
drwxrwxrwx 1 root root 4096 9月 13 2018 linux-2.6.24/
drwxrwxrwx 1 root root 4096 9月 13 2018 pgp262ii/
drwxrwxrwx 1 root root 4096 9月 14 2018 sdk-xgs-robo-5.6.1/
drwxrwxrwx 1 root root 4096 9月 13 2018 SourceCode/
drwxrwxrwx 1 root root 28672 7月 20 2018 wireshark-2.6.2-source-code/
kangruojin@kangruojin:/mnt/hgfs/workspace$
参考Blog:ubuntu 客户机安装VMware tools时出现编译错误,无法与主机共享文件
后来觉得把要共享给Ubuntu的S3C2440,放在原来的H:/workspace/S3C2440/下再共享,不太安全,结构也不太清晰,所以在Windows上创建了一个VHD,将该VHD拆了几个盘(O、P、Q)再把S3C2440放在O盘下,进行共享;之后再在Linux中用户根目录下,执行"ln /mnt/hgfs/O/S3C2440/ -s workspace"为挂载的目标目录在默认用户根目录下创建一个软链接,便于访问: