参考文章:
http://blog.csdn.net/hang_zheng/article/details/41520271
环境:
1.VMware Workstation10.0.1
2.rhel-server-7.0-x86_64
3.超户身份
说明:
1.默认原则:一路按回车选择默认配置
2.绿字安装,红字卸载
步骤:
1.挂载光驱
2.找到压缩的tar存档并复制到指定目录下
3.解除挂载
4.解压第2步中的tar压缩存档文件
5.到vmware-tools-distrib目录下卸载open-vm-tools-desktop(解决依赖包报错)
6.到lib/modules/source目录下展开归档文件vmhgfs.tar
7.修改vmhgfs-only/file.c文件的内容(解决赋值时类型不兼容):
修改为:684 HgfsSetUidGid(iparent, file->f_dentry, 685 current_fsuid(), current_fsgid());
684 HgfsSetUidGid(iparent, file->f_dentry, 685 __kuid_val(current_fsuid()), __kgid_val(current_fsgid()));
8.修改vmhgfs-only/filesystem.c文件的内容(解决赋值时类型不兼容):
修改为:231 if (si->uidSet) { 232 si->uid = mountInfo->uid; 233 } else { 234 si->uid = current_uid(); 235 } 236 si->gidSet = mountInfo->gidSet; 237 if (si->gidSet) { 238 si->gid = mountInfo->gid; 239 } else { 240 si->gid = current_gid(); 241 }
231 if (si->uidSet) { 232 si->uid = mountInfo->uid; 233 } else { 234 si->uid = __kuid_val(current_uid()); 235 } 236 si->gidSet = mountInfo->gidSet; 237 if (si->gidSet) { 238 si->gid = mountInfo->gid; 239 } else { 240 si->gid = __kgid_val(current_gid()); 241 }
9.修改vmhgfs-only/fsutil.c文件的内容(解决赋值时类型不兼容):
679 if (si->uidSet || (attr->mask & HGFS_ATTR_VALID_USERID) == 0) { 680 inode->i_uid = si->uid; 681 } else { 682 inode->i_uid = attr->userId; 683 } 684 if (si->gidSet || (attr->mask & HGFS_ATTR_VALID_GROUPID) == 0) { 685 inode->i_gid = si->gid; 686 } else { 687 inode->i_gid = attr->groupId; 688 }
修改为:
679 if (si->uidSet || (attr->mask & HGFS_ATTR_VALID_USERID) == 0) { 680 inode->i_uid = KUIDT_INIT(si->uid); 681 } else { 682 inode->i_uid = KUIDT_INIT(attr->userId); 683 } 684 if (si->gidSet || (attr->mask & HGFS_ATTR_VALID_GROUPID) == 0) { 685 inode->i_gid = KGIDT_INIT(si->gid); 686 } else { 687 inode->i_gid = KGIDT_INIT(attr->groupId); 688 }
1662 setUidGid.ia_valid = ATTR_UID; 1663 setUidGid.ia_uid = uid; 1664 1665 /* 1666 * Only set the gid if the host file system wouldn't have for us. See the 1667 * comment in the function header. 1668 */ 1669 if (!parent || !(parent->i_mode & S_ISGID)) { 1670 setUidGid.ia_valid |= ATTR_GID; 1671 setUidGid.ia_gid = gid; 1672 }
修改为:
1662 setUidGid.ia_valid = ATTR_UID; 1663 setUidGid.ia_uid = KUIDT_INIT(uid); 1664 1665 /* 1666 * Only set the gid if the host file system wouldn't have for us. See the 1667 * comment in the function header. 1668 */ 1669 if (!parent || !(parent->i_mode & S_ISGID)) { 1670 setUidGid.ia_valid |= ATTR_GID; 1671 setUidGid.ia_gid = KGIDT_INIT(gid); 1672 }
10.修改vmhgfs-only/inode.c文件的内容(解决赋值时类型不兼容):
修改为:515 if (valid & ATTR_UID) { 516 attrV2->mask |= HGFS_ATTR_VALID_USERID; 517 attrV2->userId = iattr->ia_uid; 518 *changed = TRUE; 519 } 520 521 if (valid & ATTR_GID) { 522 attrV2->mask |= HGFS_ATTR_VALID_GROUPID; 523 attrV2->groupId = iattr->ia_gid; 524 *changed = TRUE; 525 }
515 if (valid & ATTR_UID) { 516 attrV2->mask |= HGFS_ATTR_VALID_USERID; 517 attrV2->userId = __kuid_val(iattr->ia_uid); 518 *changed = TRUE; 519 } 520 521 if (valid & ATTR_GID) { 522 attrV2->mask |= HGFS_ATTR_VALID_GROUPID; 523 attrV2->groupId = __kgid_val(iattr->ia_gid); 524 *changed = TRUE; 525 }
618 if (valid & ATTR_UID) { 619 attrV2->mask |= HGFS_ATTR_VALID_USERID; 620 attrV2->userId = iattr->ia_uid; 621 *changed = TRUE; 622 } 623 624 if (valid & ATTR_GID) { 625 attrV2->mask |= HGFS_ATTR_VALID_GROUPID; 626 attrV2->groupId = iattr->ia_gid; 627 *changed = TRUE; 628 }
修改为:
618 if (valid & ATTR_UID) { 619 attrV2->mask |= HGFS_ATTR_VALID_USERID; 620 attrV2->userId = __kuid_val(iattr->ia_uid); 621 *changed = TRUE; 622 } 623 624 if (valid & ATTR_GID) { 625 attrV2->mask |= HGFS_ATTR_VALID_GROUPID; 626 attrV2->groupId = __kgid_val(iattr->ia_gid); 627 *changed = TRUE; 628 }
1219 HgfsSetUidGid(dir, dentry, current_fsuid(),current_fsgid());
修改为:
1219 HgfsSetUidGid(dir, dentry, __kuid_val(current_fsuid()), __kgid_val(current_fsgid()));
11.修改vmhgfs-only/shared/compat_dcache.h文件的内容(解决内核版本不兼容):
54 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
修改为:
54 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
12.将vmhgfs-only/目录归档为vmhgfs.tar以覆盖原来的归档文件
13.到/tmp/vmtools/vmware-tools-distrib目录下执行安装脚本vmware-install.pl,安装过程中一直回车默认,中间没报错的情况下直到出现
说明安装成功Enjoy, --the VMware team
14.重启系统
15.进入vmware-tools-distrib/bin目录下,执行卸载脚本vmware-uninstall-tools.pl,卸载过程没报错的情况下直到出现
The removal of VMware Tools 9.6.1 build-1378637 for Linux completed successfully. Thank you for having tried this software.
说明卸载成功
16.重启系统
操作:
1.在VMware Workstation工作界面中依次按下Alt,m,t
su -
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
2. mkdir /tmp/vmtools
cp /mnt/cdrom/VM* /tmp/vmtools
3. umount /mnt/cdrom
rmdir /mnt/cdrom
4. cd /tmp/vmtools
tar zxf VM*
5. cd vmware-tools-distrib
rpm -e open-vm-tools-desktop
6.cd lib/modules/source
tar xf vmhgfs.tar
7.vim vmhgfs-only/file.c
8.vim vmhgfs-only/filesystem.c
9.vim vmhgfs-only/fsutil.c
10.vim vmhgfs-only/inode.c
11.vim vmhgfs-only/shared/compat_dcache.h
12.tar cf vmhgfs.tar vmhgfs-only/
13.cd /tmp/vmtools/vmware-tools-distrib
./vmware-install.pl
14.reboot
15.su -
cd vmware-tools-distrib/bin
./vmware-uninstall-tools.pl
16.reboot