vmware windows 挂载扩展硬盘 + 共享文件夹
-
狂創客圈 經典圖書 : 《Netty Zookeeper Redis 高并發實戰》 面試必備 + 面試必備 + 面試必備 【博客園總入口 】
-
瘋狂創客圈 經典圖書 : 《SpringCloud、Nginx高并發核心編程》 大廠必備 + 大廠必備 + 大廠必備 【博客園總入口 】
-
入大廠+漲工資必備: 高并發【 億級流量IM實戰】 實戰系列 【 SpringCloud Nginx秒殺】 實戰系列 【博客園總入口 】
《SpringCloud Nginx 高并發核心編程》 環境搭建 圖文教程和演示視頻:
| 【必須】 虛擬機Linux 開發環境準備 | |
| Linux openresty 安裝 | Linux openresty 安裝 |
| 【必須】Linux Redis 安裝(帶視頻) | Linux Redis 安裝(帶視頻) |
| 【必須】Linux Zookeeper 安裝(帶視頻) | Linux Zookeeper 安裝, 帶視頻 |
| Windows Redis 安裝(帶視頻) | Windows Redis 安裝(帶視頻) |
| RabbitMQ 離線安裝(帶視頻) | RabbitMQ 離線安裝(帶視頻) |
| ElasticSearch 安裝, 帶視頻 | ElasticSearch 安裝, 帶視頻 |
| Nacos 安裝(帶視頻) | Nacos 安裝(帶視頻) |
| 【必須】Eureka | Eureka 入門,帶視頻 |
| 【必須】springcloud Config 入門,帶視頻 | springcloud Config 入門,帶視頻 |
| 【必須】SpringCloud 腳手架打包與啟動 | SpringCloud腳手架打包與啟動 |
1 虛擬機Linux 環境準備
VMware下載和安裝
絕大多數初學者使用的是 Windows,這里僅僅介紹在 Windows 下安裝 VMware 和 Linux。
VMware 有兩個版本,分別是 VMware Workstation Pro 和 VMware Workstation Player。
VMware Workstation Pro 下載地址:https://pan.baidu.com/s/1XXhFFh0Fx0vzvcd1A543Yg,提取碼:2o19
VMware 對計算機的硬件配置要求比較高,配置低了虛擬機會很慢,甚至不能運行。理論上,配置越高越好,現在主流的計算機配置都可以達到運行 VMware 的要求。千萬不要用多年珍藏的老古董來運行 VMware,我保證你將會失去耐心。
由于 VMware 的安裝過程比較簡單,與安裝普通軟件無異,因此不再過多闡述。這里假設讀者已經下載并已安裝好 VMware,接下來直接開始使用 VMware 安裝 Linux 系統。
使用 VMware 安裝 Linux 系統
啟動 VMware,進入其主界面,如圖 1 所示。
圖 2 虛擬機設置向導界面
點擊“下一步”,進入“安裝操作系統”界面,若初學者已提前準備好 Linux 系統的映像文件(.iso 文件),此處可選擇“安裝程序光盤映像文件”,并通過“瀏覽”按鈕找到要安裝 Linux 系統的 iso 文件;否則選擇“稍后安裝操作系統”,如圖 3 所示。
- 32 位 CentOS 6.5 映像下載:http://archive.kernel.org/centos-vault/6.5/isos/i386/CentOS-6.5-i386-bin-DVD1.iso
- 64 位 CentOS 6.5 映像下載:http://archive.kernel.org/centos-vault/6.5/isos/x86_64/CentOS-6.5-x86_64-bin-DVD1.iso
點擊“下一步”,進入“選擇客戶機操作系統”,選擇“Linux”,并在“版本”下拉列表框中選擇要安裝的對應的 Linux 版本,這里選擇“CentOS 6”,如圖 4 所示。
圖 5 命名虛擬機
單擊"下一步"按鈕,進入"指定磁盤容量"界面。默認虛擬硬盤大小為 20GB(虛擬硬盤會以文件形式存放在虛擬機系統安裝目錄中)。虛擬硬盤的空間可以根據需要調整大小,但不用擔心其占用的空間,因為實際占用的空間還是以安裝的系統大小而非此處劃分的硬盤大小為依據的。
比如你設定了硬盤容量為 20GB,但是安裝 Linux 只用了 4GB,那么實際上只會在你的 Windows 分區中占用 4GB 的空間,占用空間會隨著虛擬機系統使用的空間增加而增加。
此“指定磁盤容量”界面保持默認設置即可,如圖 6 所示。
圖 6 指定磁盤容量界面
接下來進入“已準備好創建虛擬機”界面,確認虛擬機設置,不需改動則單擊"完成"按鈕,開始創建虛擬機,如圖 7 所示。
圖 12 VMware 啟動 Linux 系統
而在圖 3 中選擇“稍后安裝操作系統”的讀者,此時必須先下載某個 Linux 映像文件,并通過“編輯虛擬機設置->CD/DVD(IDE)”中,選擇“使用ISO映像文件”,手動添加 iso 文件,然后點擊“確定”即可手動開啟 Linux 系統。如圖 13 所示。
經過以上幾步,我們就成功地用 VMware 虛擬機安裝好了 Linux 系統。
2、掛載擴展硬盤
1 前言
本機vmware會老提示nospace空間不足,一般都需要掛載擴展硬盤
2.添加新硬盤
依次點擊"虛擬機"->“設置”
3.查看磁盤信息
[root@localhost ~]# fdisk -lDisk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x364f5e2eDevice Boot Start End Blocks Id System /dev/sdb1 2048 41943039 20970496 83 LinuxDisk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000cbf1eDevice Boot Start End Blocks Id System /dev/sda1 * 2048 616447 307200 83 Linux /dev/sda2 616448 4810751 2097152 82 Linux swap / Solaris /dev/sda3 4810752 41943039 18566144 83 Linux可以看到有2個磁盤,/dev/sda磁盤有3個分區,/dev/sdb磁盤為我這次新增的,1分區
4.磁盤分區
fdisk /dev/sdb分區后可以通過fdisk -l查看/dev/sdb磁盤下有一個sdb1分區
5.格式化分區
# 格式化分區 mkfs.ext4 /dev/sdb1 # 將分區掛載到根目錄 mount -t ext4 /dev/sdb1 /work掛載后
[root@localhost ~]# df -ll Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 18555904 7347232 11208672 40% / devtmpfs 1925244 0 1925244 0% /dev tmpfs 1934520 0 1934520 0% /dev/shm tmpfs 1934520 58484 1876036 4% /run tmpfs 1934520 0 1934520 0% /sys/fs/cgroup /dev/sda1 303788 109596 194192 37% /boot /dev/sdb1 20510288 11187164 8258216 58% /work tmpfs 386908 0 386908 0% /run/user/06.設置開機自動掛載
vi /etc/rc.d/rc.local #mount disk 2 掛載第二塊硬盤 /bin/mount /dev/sdb1 /work3 CentOS7 安裝VMware Tools
VMware 強烈建議你在每一臺虛擬機中完成操作系統安裝之后立即安裝 VMware Tools 套件。在客戶操作系統中安裝 VMware Tools 非常重要。
VMware Tools是VMware虛擬機中自帶的一種增強工具,相當于VirtualBox中的增強功能(Sun VirtualBox Guest Additions),是VMware提供的增強虛擬顯卡和硬盤性能、以及同步虛擬機與主機時鐘的驅動程序。
只有在VMware虛擬機中安裝好了VMware Tools,才能實現主機與虛擬機之間的文件共享,同時可支持自由拖拽的功能,鼠標也可在虛擬機與主機之前自由移動(不用再按ctrl+alt),且虛擬機屏幕也可實現全屏化。
1 安裝依賴包
[root@localhost ~]# yum -y install perl gcc gcc-c++ make cmake kernel kernel-headers kernel-devel net-tools2 加載 vmware tools 到CentOS7光驅CD-ROM
點擊菜單 `虛擬機` ——> `安裝VMware Tools(T)...`點擊加載 vmware tools 到CentOS7光驅CD-ROM
3 將CD-ROM掛載到指定目錄
通常情況下都是將設備目錄 /dev/crrom 掛載到 /mnt/cdrom 目錄,-
如果 /mnt 目錄下不存在 cdrom 目錄則創建
/mnt/cdrom則創建
[root@localhost ~]# mkdir -p /mnt/cdrom -
掛載目錄
[root@localhost ~]# mount -t auto /dev/cdrom /mnt/cdrom mount: /dev/sr0 is write-protected, mounting read-only如果掛載目錄錯了,可以輸入umout /dev/cdrom進行卸載掛載。
ps:mount命令介紹
命令格式:mount [-t vfstype] [-o options] device dir
1.-t vfstype 指定文件系統的類型,通常不必指定。mount 會自動選擇正確的類型。常用類型有:
光盤或光盤鏡像:iso9660
DOS fat16文件系統:msdos
Windows 9x fat32文件系統:vfat
Windows NT ntfs文件系統:ntfs
Mount Windows文件網絡共享:smbfs
UNIX(LINUX) 文件網絡共享:nfs
2.-o options 主要用來描述設備或檔案的掛接方式。常用的參數有:
loop:用來把一個文件當成硬盤分區掛接上系統
ro:采用只讀方式掛接設備
rw:采用讀寫方式掛接設備
iocharset:指定訪問文件系統所用字符集
3.device 要掛接(mount)的設備。
4.dir設備在系統上的掛接點(mount point)。
完整的掛載命令為
mount -t iso9660 -o ro /dev/cdrom /mnt/cdrom4 拷貝安裝包到用戶家目錄
[root@localhost ~]# cp /mnt/cdrom/VMwareTools-10.0.5-3228253.tar.gz ~5 解除掛載
[root@localhost ~]# umount /dev/cdrom6 解壓VMwareTools安裝包
[root@localhost ~]# tar -zxvf VMwareTools-10.0.5-3228253.tar.gz輸入命令tar -zxf VMwareTools-10.0.5-3228253.tar.gz 將剛剛復制的VMwareTools-10.0.5-3228253.tar.gz解壓,默認解壓到當前目錄下,此時就會多出一個命名為類似于“vmware-tools-distrib”的文件夾,這里和windows 里面的解壓結果一樣。
7 安裝VMware Tools
輸入命令 cdvmware-linux-tools 進入解壓后的目錄
[root@localhost ~]# cd vmware-tools-distrib/運行 vmware-install.pl 文件
[root@localhost vmware-tools-distrib]# ./vmware-install.pl在運行安裝過程中,它會一步一步的有問題提出要你回應,此過程中,你只要見到問題后面顯示[yes]、[no]、[yes/no]的都輸入yes,然后回車, 如果是其他的問題,不管[ ]里面是什么直接回車就好
一路Enter即可
[root@XD-ORACLE vmware-tools-distribu]# cd vmware-tools-distrib/ [root@XD-ORACLE vmware-tools-distrib]# ls bin doc etc FILES INSTALL installer lib vmware-install.pl [root@XD-ORACLE vmware-tools-distrib]# ./vmware-install.pl A previous installation of VMware Tools has been detected.The previous installation was made by the tar installer (version 4).Keeping the tar4 installer database format.You have a version of VMware Tools installed. Continuing this install will first uninstall the currently installed version. Do you wish to continue? (yes/no) [yes] yesUninstalling the tar installation of VMware Tools.Stopping services for VMware ToolsStopping VMware Tools services in the virtual machine:Guest operating system daemon: [ OK ]VMware User Agent (vmware-user): [ OK ]Blocking file system: [ OK ]Unmounting HGFS shares: [ OK ]Guest filesystem driver: [ OK ]VM communication interface socket family: [ OK ]VM communication interface: [ OK ]Stopping Thinprint services in the virtual machine:Stopping Virtual Printing daemon: done/sbin/restorecon: Warning no default label for /tmp/vmware-block-restore0/tmp_file File /etc/pulse/default.pa is backed up to /etc/pulse/default.pa.old.0.The removal of VMware Tools 9.6.1 build-1378637 for Linux completed successfully.Installing VMware Tools.In which directory do you want to install the binary files? [/usr/bin]What is the directory that contains the init directories (rc0.d/ to rc6.d/)? [/etc/rc.d]What is the directory that contains the init scripts? [/etc/rc.d/init.d]In which directory do you want to install the daemon files? [/usr/sbin]In which directory do you want to install the library files? [/usr/lib/vmware-tools]The path "/usr/lib/vmware-tools" does not exist currently. This program is going to create it, including needed parent directories. Is this what you want? [yes]yes In which directory do you want to install the documentation files? [/usr/share/doc/vmware-tools] The path "/usr/share/doc/vmware-tools" does not exist currently. This program is going to create it, including needed parent directories. Is this what you want? [yes] The installation of VMware Tools 9.6.1 build-1378637 for Linux completed successfully. You can decide to remove this software from your system at any time by invoking the following command: "/usr/bin/vmware-uninstall-tools.pl".Before running VMware Tools for the first time, you need to configure it by invoking the following command: "/usr/bin/vmware-config-tools.pl". Do you want this program to invoke the command for you now? [yes] yesInitializing.../usr/bin/xrandr: Failed to get size of gamma for output defaultMaking sure services for VMware Tools are stopped.Stopping Thinprint services in the virtual machine:Stopping Virtual Printing daemon: done Stopping VMware Tools services in the virtual machine:Guest operating system daemon: [ OK ]VMware User Agent (vmware-user): [ OK ]Blocking file system: [ OK ]Unmounting HGFS shares: [ OK ]Guest filesystem driver: [ OK ]VM communication interface socket family: [ OK ]VM communication interface: [ OK ]Found a compatible pre-built module for vmci. Installing it...Found a compatible pre-built module for vsock. Installing it...The module vmxnet3 has already been installed on this system by another installer or package and will not be modified by this installer.Use the flag --clobber-kernel-modules=vmxnet3 to override.The module pvscsi has already been installed on this system by another installer or package and will not be modified by this installer.Use the flag --clobber-kernel-modules=pvscsi to override.The module vmmemctl has already been installed on this system by another installer or package and will not be modified by this installer.Use the flag --clobber-kernel-modules=vmmemctl to override.The VMware Host-Guest Filesystem allows for shared folders between the host OS and the guest OS in a Fusion or Workstation virtual environment. Do you wish to enable this feature? [yes] yesFound a compatible pre-built module for vmhgfs. Installing it...Found a compatible pre-built module for vmxnet. Installing it...The vmblock enables dragging or copying files between host and guest in a Fusion or Workstation virtual environment. Do you wish to enable this feature? [yes] yesVMware automatic kernel modules enables automatic building and installation of VMware kernel modules at boot that are not already present. This feature can beenabled/disabled by re-running vmware-config-tools.pl.Would you like to enable VMware automatic kernel modules? [no] noThinprint provides driver-free printing. Do you wish to enable this feature? [yes] yesDisabling timer-based audio scheduling in pulseaudio.Detected X server version 1.13.0Distribution provided drivers for Xorg X server are used.Skipping X configuration because X drivers are not included.Creating a new initrd boot image for the kernel.Starting Virtual Printing daemon: doneChecking acpi hot plug [ OK ] Starting VMware Tools services in the virtual machine:Switching to guest configuration: [ OK ]VM communication interface: [ OK ]VM communication interface socket family: [ OK ]Guest filesystem driver: [ OK ]Mounting HGFS shares: [ OK ]Blocking file system: [ OK ]VMware User Agent: [ OK ]Guest operating system daemon: [ OK ] The configuration of VMware Tools 9.6.1 build-1378637 for Linux for this running kernel completed successfully.You must restart your X session before any mouse or graphics changes take effect.You can now run VMware Tools by invoking "/usr/bin/vmware-toolbox-cmd" from the command line.To enable advanced X features (e.g., guest resolution fit, drag and drop, and file and text copy/paste), you will need to do one (or more) of the following: 1. Manually start /usr/bin/vmware-user 2. Log out and log back into your desktop session; and, 3. Restart your X session.Enjoy,--the VMware teamFound VMware Tools CDROM mounted at /media/VMware Tools. Ejecting device /dev/sr0 ... /sbin/restorecon: Warning no default label for /tmp/vmware-block-restore0/tmp_file [root@XD-ORACLE vmware-tools-distrib]#安裝完成后,選擇虛擬機上方的:虛擬機-設置-選項-客戶機隔離,勾選“啟用復制粘貼”,然后重啟centos系統,就可以實現在虛擬機系統與主機系統之間復制,粘貼文字,以及文件可以直接在兩系統間拖動了。
8 啟用共享文件夾
在命令窗口輸入如下命令(ls /mnt/hgfs/)之后,會看到自己剛剛設置的共享文件夾
[root@localhost ~]# ls /mnt/hgfs/ develop [root@localhost ~]#完整的自定義開機程序 /etc/rc.d/rc.local
[root@localhost ~]# cat /etc/rc.d/rc.local #!/bin/bash # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES # # It is highly advisable to create own systemd services or udev rules # to run scripts during boot instead of using this file. # # In contrast to previous versions due to parallel execution during boot # this script will NOT be run after all other services. # # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure # that this script will be executed during boot.#start redis /usr/local/redis/bin/redis-server /usr/local/redis/redis.conf#mount disk 2 掛載第二塊硬盤 /bin/mount /dev/sdb1 /work#start nginx 以root賬號 啟動 nginx/usr/bin/su - root -c "/usr/local/openresty/nginx/sbin/nginx -c /usr/local/openresty/nginx/conf/nginx.conf"# 啟動 zookeeper /usr/bin/su - root -c "/work/zookeeper/zookeeper-1/bin/zkServer.sh start" /usr/bin/su - root -c "/work/zookeeper/zookeeper-2/bin/zkServer.sh start" sleep 10s#start springcloud 注冊中心 eureka /usr/bin/su - root -c "/work/cloud-eureka-1.0-SNAPSHOT/bin/start.sh start" sleep 20s #start springcloud 配置中心 config /usr/bin/su - root -c "/work/cloud-config-1.0-SNAPSHOT/bin/start.sh start"# 啟動 Nacos ,如果要使用的話 /usr/bin/su - root -c "/work/nacos/bin/startup.sh -m standalone"以上用到的 su命令,說明如下:
su - root -c command :
切換到root并獲得root的環境變量及執行權限并執行命令,-c是command的縮寫
回到?瘋狂創客圈?
瘋狂創客圈 - Java高并發研習社群,為大家開啟大廠之門
總結
以上是生活随笔為你收集整理的vmware windows 挂载扩展硬盘 + 共享文件夹的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android开发实用小工具十三——BM
- 下一篇: 什么是二级分销系统?