VMware vSphere Command Line Interface – vmware-cmd & vicfg-*

底下在 CentOS 7.x 操作
ESXi Server IP:192.168.131.234

列出 ESXi Server 上的虛擬機器
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 -l
Enter username: root
Enter password:

/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ob2d/ob2d.vmx
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Custom CentOS 7.x/Custom CentOS 7.x.vmx
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/OpenNMS/OpenNMS.vmx
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Nginx/Nginx.vmx
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Ubuntu 16.04.2/Ubuntu 16.04.2.vmx
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux/ArchLinux.vmx
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Windows 10 1607 14393.969/Windows 10 1607 14393.969.vmx
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Windows 10 x64 1607 Build 14393.0/Windows 10 x64 1607 Build 14393.0.vmx

[@more@]列出 ESXi Server 上的 VM 資訊
[root@esxi:~] vim-cmd vmsvc/getallvms
Vmid Name File Guest OS Version Annotation
1 OB2D Linux 2017 1.0 [ST500G] ob2d/ob2d.vmx other26xLinux64Guest vmx-13
2 Custom CentOS 7.x [ST500G] Custom CentOS 7.x/Custom CentOS 7.x.vmx centos7_64Guest vmx-13
21 OpenNMS [ST500G] OpenNMS/OpenNMS.vmx centos7_64Guest vmx-13
22 Nginx [ST500G] Nginx/Nginx.vmx centos7_64Guest vmx-13
24 Ubuntu 16.04.2 [ST500G] Ubuntu 16.04.2/Ubuntu 16.04.2.vmx ubuntu64Guest vmx-13
25 ArchLinux [ST500G] ArchLinux/ArchLinux.vmx other26xLinux64Guest vmx-13
26 Windows 10 1607 14393.969 [ST500G] Windows 10 1607 14393.969/Windows 10 1607 14393.969.vmx windows9_64Guest vmx-13
28 Windows 10 x64 1607 Build 14393.0 [ST500G] Windows 10 x64 1607 Build 14393.0/Windows 10 x64 1607 Build 14393.0.vmx windows9_64Guest vmx-12

列出某一部虛擬機器有無做過 snapshot,1 代表有做過 snapshot
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ob2d/ob2d.vmx hassnapshot
Enter username: root
Enter password:
hassnapshot () = 1

顯示虛擬機器是否有開機 off 代表沒有開機
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Nginx/Nginx.vmx getstate
Enter username: root
Enter password:
getstate() = off

顯示虛擬機器是否有開機 off 代表有開機
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux/ArchLinux.vmx getstate
Enter username: root
Enter password:
getstate() = on

傳回值:on, off, suspended, or unknown.

顯示虛擬機器開機的時間
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux/ArchLinux.vmx getuptime
Enter username: root
Enter password:
getuptime() = 82404

查詢 ESXi Server 版本資訊
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux/ArchLinux.vmx getproductinfo product
Enter username: root
Enter password:
getproductinfo(product) = embeddedEsx
傳回值 esx for VMware ESX, embeddedESX for VMware ESXi, or unknown.

查詢安裝的 VM 安裝平台
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux/ArchLinux.vmx getproductinfo platform
Enter username: root
Enter password:
getproductinfo(platform) = vmnix-x86
傳回值 win32-x86 for an x86-based Windows system, linux-x86 for an x86-based Linux system, or vmnix-x86 for an x86-based ESXi microkernel.

檢查 VM 是否有安裝 VMware Tools
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux/ArchLinux.vmx gettoolslastactive
Enter username: root
Enter password:
gettoolslastactive() = 1
傳回值
0 – VMware Tools is not installed or not running.
1 – Guest operating system is responding normally.
5 – Intermittent heartbeat. There might be a problem with the guest operating system.
100 – No heartbeat. Guest operating system might have stopped responding.

將 VM 關機
[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux stop soft

[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux start soft

[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux reset soft

[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux suspend hard

[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux suspend soft

建立 Snapshot 快照
quiesce flag (0 or 1) and memory flag (0 or 1).
[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux createsnapshot ArchLinuxOK ‘ArchLinux OK 2017.04.01’ 0 0

還原快照
[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux revertsnapshot

刪除快照
[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux removesnapshots

查詢 DNS Server 設定
[root@localhost ~]# vicfg-dns –server 192.168.131.234
Enter username: root
Enter password:
DNS Configuration

Host Name esxi
Domain Name test.ilc.edu.tw
DHCP false
DNS Servers
140.111.66.10
168.95.1.1

將 VMware ESXi Server 關機
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation shutdown –force
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation shutdown
Enter username: root
Enter password:
Host esxi.localdomain shutdown successfully.

將 VMware ESXi Server 重新啟動
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation reboot –force
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation reboot
Enter username: root
Enter password:
Host esxi.localdomain rebooted successfully.

顯示 VMware ESXi Server 資訊
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation info
Enter username: root
Enter password:

Host Name : esxi.localdomain
Manufacturer : VMware, Inc.
Model : VMware Virtual Platform
Processor Type : Intel(R) Core(TM) i3-3225 CPU @ 3.30GHz
CPU Cores : 2 CPUs x 3300 GHz
Memory Capacity : 4095.48828125 MB
VMotion Enabled : no
In Maintenance Mode : no
Last Boot Time : 2017-03-29T07:05:37.890796Z

進入維護模式
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation enter
Enter username: root
Enter password:
Host esxi.localdomain entered into maintenance mode successfully.

退出維護模式
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation exit
Enter username: root
Enter password:
Host esxi.localdomain exited from maintenance mode successfully.

顯示和設置一台主機從所有路徑到達它的儲存設備
[root@localhost ~]# vicfg-mpath –server 192.168.131.234 –list
Enter username: root
Enter password:
vmhba0:C0:T5:L0
Runtime Name: vmhba0:C0:T5:L0
Device: vmhba0:C0:T5:L0
Device Display Name:
Adapter: vmhba0 Channel: 0 Target: 5 LUN: 0
Adapter Identifier: sata.vmhba0
Target Identifier: sata.0:5
Plugin: NMP
State: active
Transport: sata

vmhba1:C0:T0:L0
Runtime Name: vmhba1:C0:T0:L0
Device: vmhba1:C0:T0:L0
Device Display Name:
Adapter: vmhba1 Channel: 0 Target: 0 LUN: 0
Adapter Identifier: sata.vmhba1
Target Identifier: sata.0:0
Plugin: NMP
State: active
Transport: sata

[root@localhost ~]# vicfg-nas –server 192.168.131.234 -l
Enter username: root
Enter password:
SynologyNAS is /volume1/homes/test/Server/esxi from 192.168.231.4 mounted

[root@esxi:~] esxcli storage nfs list
Volume Name Host Share Accessible Mounted Read-Only isPE Hardware Acceleration
———– ———— ———————————- ———- ——- ——— —– ———————
SynologyNAS 192.168.131.4 /volume1/homes/test/Server/esxi true true false false Not Supported

列出使用者
[root@localhost ~]# vicfg-user –server 192.168.131.234 -e user -o list
Enter username: root
Enter password:
USERS
—————–
Principal -: root
Full Name -: Administrator
UID -: 0
Shell Access -:1

—————–
Principal -: dcui
Full Name -: DCUI User
UID -: 100
Shell Access -:0

—————–
Principal -: vpxuser
Full Name -: VMware VirtualCenter administration account
UID -: 500
Shell Access -:0

—————–

增加一個新的使用者
[root@localhost ~]# vicfg-user –server 192.168.131.234 -e user -o add -l user27 -p 27_password
Enter username: root
Enter password:
Created user user27 successfully.

修改使用者密碼
[root@localhost ~]# vicfg-user –server 192.168.131.234 -e user -o modify -l user27 -p 27_password2
Enter username: root
Enter password:
Updated user user27 successfully.

將使用者改成唯讀
[root@localhost ~]# vicfg-user –server 192.168.131.234 -e user -o modify -l user27 –role read-only
Enter username: root
Enter password:
Do you want to change the password (y/n): n
Updated user user27 successfully.

刪除使用者
[root@localhost ~]# vicfg-user –server 192.168.131.234 -e user -o delete -l user27
Enter username: root
Enter password:
Removed the user user27 successfully.

VMware ESXi – Arch Linux 安裝 vm-tools

安裝在 ESXi Server 中的 Arch Linux 也安裝了 open-vm-tools,但系統上還是顯示未安裝

安裝 open-vm-tools
# pcman -S open-vm-tools

檢查系統是否有安裝
# pacman -Qs open-vm-tools
local/open-vm-tools 6:10.1.0-2
    The Open Virtual Machine Tools (open-vm-tools) are the open source
    implementation of VMware Tools[@more@]原因是未啟動 vmtoolsd 服務,啟用了就正常了!
# systemctl list-unit-files | grep vmtools
vmtoolsd.service                                                       disabled
# systemctl enable vmtoolsd.service
Created symlink /etc/systemd/system/multi-user.target.wants/vmtoolsd.service → /usr/lib/systemd/system/vmtoolsd.service.
# systemctl start vmtoolsd.service

VMware ESXi – 系統設定備份與回復 – CentOS 7

如果要備份或回復 VMware ESXi 的設定,可以安裝 VMware vSphere Command Line Interface。
1. 登入 VMware 官方網站下載 VMware vSphere Command Line Interface
     1 – For Windows
     2 – For Linux x86_64
     3 – For Linux x86

[@more@]參考網頁:
vmware-vsphere-cli-centos7.sh · GitHub
The Pain and Fury of vmware-cli on CentOS 7 | Morgajel.net
Install vCLI 6 on CentOS 7 – vSphere SDK for Perl
[VMware] 在 CentOS7 上安裝 VMware vSphere CLI (vcli) 操作 VM @ 亂打一通的心情日記 :: 痞客邦 PIXNET ::
在 CentOS7 上安裝 VMware vSphere CLI (vcli) – IT閱讀

2. 安裝必備套件
# yum install epel-release
# yum update
# yum install openssl-devel cpan perl-Devel-StackTrace perl-Class-Data-Inheritable perl-Convert-ASN1 perl-Crypt-OpenSSL-RSA perl-Exception-Class perl-Archive-Zip perl-Try-Tiny perl-Crypt-SSLeay perl-XML-SAX perl-XML-NamespaceSupport perl-libxml-perl perl-XML-LibXML perl-Socket6 perl-IO-Socket-INET6 libuuid-devel perl-Crypt-OpenSSL-X509 perl-Path-Class perl-Class-MethodMaker perl-Data-UUID perl-Data-Dump perl-SOAP-Lite perl-Net-INET6Glue

# PERL_MM_USE_DEFAULT=1 cpan install BINGOS/ExtUtils-MakeMaker-6.96.tar.gz LEONT/Module-Build-0.4205.tar.gz GBARR/libnet-1.22.tar.gz GAAS/libwww-perl-5.837.tar.gz PERLER/UUID-Random-0.04.tar.gz

3. 解壓縮
# tar xvzf VMware-vSphere-CLI-6.5.0-4566394.x86_64.tar.gz

4. 切換目錄
# cd vmware-vsphere-cli-distrib

5. 進行安裝
# ./vmware-install.pl –prefix=/opt/vmwarecli EULA_AGREED=yes –default
Creating a new vSphere CLI installer database using the tar4 format.

Installing vSphere CLI 6.5.0 build-4566394 for Linux.

This vSphere CLI installer includes precompiled Perl modules for RHEL.
Answering yes will install the precompiled modules, and answering no will
install from CPAN.
Do you want to install precompiled Perl modules for RHEL?
[yes]

Please wait while copying vSphere CLI files…

The installation of vSphere CLI 6.5.0 build-4566394 for Linux completed
successfully. You can decide to remove this software from your system at any
time by invoking the following command:
“/opt/vmwarecli/bin/vmware-uninstall-vSphere-CLI.pl”.

This installer has successfully installed both vSphere CLI and the vSphere SDK
for Perl.

The following Perl modules were found on the system but may be too old to work
with vSphere CLI:

Devel::StackTrace 1.31 or newer
MIME::Base64 3.14 or newer
Try::Tiny 0.22 or newer
LWP 6.15 or newer
Socket6  0.23 or newer
IO::Socket::INET6 2.71 or newer
Net::HTTP 6.09 or newer

Enjoy,

–the VMware team

6. 程式安裝路徑
# ls -l /opt/vmwarecli/bin/vicfg-*
-r-xr-xr-x. 1 root root  9632  3月 28 19:23 /opt/vmwarecli/bin/vicfg-advcfg
-r-xr-xr-x. 1 root root 11645  3月 28 19:23 /opt/vmwarecli/bin/vicfg-authconfig
-r-xr-xr-x. 1 root root  8920  3月 28 19:23 /opt/vmwarecli/bin/vicfg-cfgbackup
-r-xr-xr-x. 1 root root  9140  3月 28 19:23 /opt/vmwarecli/bin/vicfg-dns
-r-xr-xr-x. 1 root root 12580  3月 28 19:23 /opt/vmwarecli/bin/vicfg-dumppart
-r-xr-xr-x. 1 root root 16564  3月 28 19:23 /opt/vmwarecli/bin/vicfg-hostops
-r-xr-xr-x. 1 root root 24199  3月 28 19:23 /opt/vmwarecli/bin/vicfg-ipsec
-r-xr-xr-x. 1 root root 76696  3月 28 19:23 /opt/vmwarecli/bin/vicfg-iscsi
-r-xr-xr-x. 1 root root  6872  3月 28 19:23 /opt/vmwarecli/bin/vicfg-module
-r-xr-xr-x. 1 root root 20543  3月 28 19:23 /opt/vmwarecli/bin/vicfg-mpath
-r-xr-xr-x. 1 root root 17871  3月 28 19:23 /opt/vmwarecli/bin/vicfg-mpath35
-r-xr-xr-x. 1 root root  8314  3月 28 19:23 /opt/vmwarecli/bin/vicfg-nas
-r-xr-xr-x. 1 root root  9364  3月 28 19:23 /opt/vmwarecli/bin/vicfg-nics
-r-xr-xr-x. 1 root root  7144  3月 28 19:23 /opt/vmwarecli/bin/vicfg-ntp
-r-xr-xr-x. 1 root root  2874  3月 28 19:23 /opt/vmwarecli/bin/vicfg-rescan
-r-xr-xr-x. 1 root root 13481  3月 28 19:23 /opt/vmwarecli/bin/vicfg-route
-r-xr-xr-x. 1 root root 21745  3月 28 19:23 /opt/vmwarecli/bin/vicfg-scsidevs
-r-xr-xr-x. 1 root root 12387  3月 28 19:23 /opt/vmwarecli/bin/vicfg-snmp
-r-xr-xr-x. 1 root root  5643  3月 28 19:23 /opt/vmwarecli/bin/vicfg-syslog
-r-xr-xr-x. 1 root root 22531  3月 28 19:23 /opt/vmwarecli/bin/vicfg-user
-r-xr-xr-x. 1 root root 26398  3月 28 19:23 /opt/vmwarecli/bin/vicfg-vmknic
-r-xr-xr-x. 1 root root 13010  3月 28 19:23 /opt/vmwarecli/bin/vicfg-volume
-r-xr-xr-x. 1 root root 36078  3月 28 19:23 /opt/vmwarecli/bin/vicfg-vswitch

# ls -l /opt/vmwarecli/bin/vm*
-r-xr-xr-x. 1 root root  40411  3月 28 19:23 /opt/vmwarecli/bin/vmkfstools
-r-xr-xr-x. 1 root root  59908  3月 28 19:23 /opt/vmwarecli/bin/vmware-cmd
-r-xr-xr-x. 1 root root 128151  3月 28 19:23 /opt/vmwarecli/bin/vmware-uninstall-vSphere-CLI.pl

7. 進行備份
    –server Server’IP
    -s 備份設定
# /opt/vmwarecli/bin/vicfg-cfgbackup –server 192.168.1.234 -s /root/esx.cfg
Enter username: root
Enter password:
Saving firmware configuration to /root/esx.cfg …

8. 還原設定值,ESXi Server 會重新啟動
# /opt/vmwarecli/bin/vicfg-cfgbackup –server 192.168.1.234 -l /root/esx.cfg
Enter username: root
Enter password:
The restore operation will reboot the host.
Type ‘yes’ to continue:
yes
Uploading config bundle to configBundle.tgz …
Performing restore …
系統重新開機

9. 指令用法
# /opt/vmwarecli/bin/vicfg-cfgbackup –help
Synopsis: /opt/vmwarecli/bin/vicfg-cfgbackup OPTIONS [<backupfile>]

Command-specific options:
   –force
    -f
        Force the restore of the configuration.
   –load
    -l
        Restore configuration onto the host
   –quiet
    -q
        Do not prompt for user confirmation.
   –reset
    -r
        Resets host, restore to factory settings.
   –save
    -s
        Backup the host configuration.

VMware ESXi – 登錄虛擬機器

參考網頁:
无法打开磁盘 scsi0:0: 磁盘类型 7 不受支持或无效。请确保磁盘已导入 – systems – 51CTO技术博客

匯入 Kali Linux 官方網站上提供的 VM
1. 下載後解壓縮,上傳到資料存放區
     在 .vmx 上按滑鼠右鍵,選擇 登錄虛擬機器

2. 完成之後,選擇 關閉

3. 虛擬機器上多出一台 Kail Linux

[@more@]4. 啟動虛擬機器

5. 選擇 我已將其複製

6. 出現錯誤訊息

7. 以 ssh 登入 ESXi Server,進行轉檔
[root@esxi:~] cd /vmfs/volumes/ST500G/Kali-Linux-2016.2-VM-x64/   
[root@esxi:/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Kali-Linux-2016.2-VM-x64] /bin/vmkfstools -i Kali-Linux-2016.2-vm-amd64.vmdk Kali-Linux-2016.2-vm-amd64_N.vmdk -d thin

8. 轉換完成

9. 新產生的檔案
[root@esxi:/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Kali-Linux-2016.2-VM-x64] ls -lt
total 20546576
-rw——-    1 root     root     42949672960 Apr 11 15:08 Kali-Linux-2016.2-vm-amd64_N-flat.vmdk
-rw——-    1 root     root           595 Apr 11 15:08 Kali-Linux-2016.2-vm-amd64_N.vmdk

10. 備份舊的檔案,再搬移新的檔案
[root@esxi:/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Kali-Linux-2016.2-VM-x64] mv Kali-Linux-2016.2-vm-amd64.vmdk Kali-Linux-2016.2-vm-amd64.vmdk.org
[root@esxi:/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Kali-Linux-2016.2-VM-x64] mv Kali-Linux-2016.2-vm-amd64_N.vmdk Kali-Linux-2016.2-vm-amd64.vmdk

11. 重新開機,已經可以使用,預設登入的帳號及密碼:root / toor

12. 確定可以正常開機,就可以刪除一些檔案
[root@esxi:/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Kali-Linux-2016.2-VM-x64] ls -l Kali-Linux-2016.2-vm-amd64-s*
-rw-r–r–    1 root     root     3803316224 Apr 11 14:39 Kali-Linux-2016.2-vm-amd64-s001.vmdk
-rw-r–r–    1 root     root     2840068096 Apr 11 14:36 Kali-Linux-2016.2-vm-amd64-s002.vmdk
-rw-r–r–    1 root     root     1462173696 Apr 11 14:42 Kali-Linux-2016.2-vm-amd64-s004.vmdk
-rw-r–r–    1 root     root     694091776 Apr 11 14:41 Kali-Linux-2016.2-vm-amd64-s005.vmdk
-rw-r–r–    1 root     root     677249024 Apr 11 14:38 Kali-Linux-2016.2-vm-amd64-s003.vmdk
-rw-r–r–    1 root     root     640483328 Apr 11 14:44 Kali-Linux-2016.2-vm-amd64-s007.vmdk
-rw-r–r–    1 root     root     509280256 Apr 11 14:44 Kali-Linux-2016.2-vm-amd64-s008.vmdk
-rw-r–r–    1 root     root     490340352 Apr 11 14:42 Kali-Linux-2016.2-vm-amd64-s006.vmdk
-rw-r–r–    1 root     root     431882240 Apr 11 14:45 Kali-Linux-2016.2-vm-amd64-s009.vmdk
-rw-r–r–    1 root     root      13172736 Apr 11 14:44 Kali-Linux-2016.2-vm-amd64-s010.vmdk
-rw-r–r–    1 root     root         65536 Apr 11 14:44 Kali-Linux-2016.2-vm-amd64-s011.vmdk

[root@esxi:/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Kali-Linux-2016.2-VM-x64] rm -rf Kali-Linux-2016.2-vm-amd64-s*

Proxmox – 匯入 ESXi 匯出的 OVF 檔案

1. 將產生的 .vmdk 上傳到 Proxmox Server

2. 進行轉換
-f 來源格式
-O 轉換格式
-p 顯示進度
# qemu-img convert -f vmdk Nginx-disk1.vmdk -O qcow2 Nginx.qcow2 -p
    (100.00/100%)

3. 轉換後比較
# ls -l Nginx*
-rw-r–r– 1 root root  872952320 Mar 28 10:24 Nginx-disk1.vmdk
-rw-r–r– 1 root root 2101805056 Mar 28 10:43 Nginx.qcow2[@more@]
4. 使用 Proxmox 建立一個 KVM,設定依 ESXi Server 上的設定
    再用轉換完成的 .qcow2 檔替換掉 KVM 上的檔案

# cp Nginx.qcow2 /VM/images/400/vm-400-disk-1.qcow2

VMware ESXi – 虛擬硬碟格式

在 VMware vSphere Client 新增虛擬機器時,在做磁碟設定時,有三種模式可以選擇,在新版的 vSphere Web Client 則似乎沒有特別顯示這個選項。
這三者的差別:
參考網頁:(VMesxi 備份篇-Day19) VMware vSphere(ESXi) 虛擬硬碟格式介紹 – iT 邦幫忙::一起幫忙解決難題,拯救 IT 人的一天
[@more@]完整佈建消極式歸零 Thick Provision Lazy Zeroed (zeroedthick)
在建立虛擬硬碟時會一次給足所設定的硬碟大小,虛擬硬碟一開始時只會將目前所使用到的部分先進行初始化,其它的部分只是當有用到時才會做初始化的動作。

完整佈建積極性歸零 Thick Provision Eager Zeroed (eagerzeroedthick)
在建立虛擬硬碟時會一次給足所設定的硬碟大小,虛擬硬碟一開始時就會將所有的部分先行初始化,所以開始時會耗費一些時間,但後續使用時,不用在做初始化,所以效能會稍微好一些。

精簡佈建 Thin Provision
會隨著虛擬硬碟的使用量而增加硬碟的大小,直到達到當時建立的磁碟空間上限為止。

VMware ESXi – 匯入OVF 範本

將由 VMware 匯出的 OVF 檔案,匯入到 ESXi Server。
1. 選擇 檔案 / 部署 OVF 範本

2. 選擇 瀏覽

[@more@]3. 選擇 OVF 格式檔所在的位置

4. 選擇 下一步

5. 選擇 下一步

6. 選擇 下一步

7. 選擇資料存放區,選擇 下一步

8. 選擇虛擬硬碟格式,選擇 下一步

9. 選擇 完成

10. 還原過程

11. 部署成功完成

12. 多出剛新增完成的虛擬機器

13. 可以正常開機

VMware ESXi – 將虛擬機器匯出成 OVF 範本

1. 首先先將要匯出的虛擬機器關機

2. 選擇 檔案 / 匯出 / 匯出 OVF 範本

[@more@]3. 格式可以選擇 OVF 檔案資料夾或是 OVA 單一檔案

4. 選擇要匯出的本機端目錄

5. 選擇 確定

6. 匯出中

7. 匯出成功

8. OVF 和 OVA 比較
OVF

OVA

不知道是為什麼,匯出成 OVA 竟然比 OVF 檔案大小還大,不過所差無幾。

將 VMware 虛擬機器匯出成 OVF 範本

主要是要將 VMware 的虛擬機器匯出成 OVF 格式,再匯入到 VMware ESXi。
OVF(Open Virtualization Format) 開放虛擬化格式,是一種具有開放、安全、高效率的格式,OVF 格式可以在不同的虛擬機器平台(VMware、Xen、KVM…)之間做轉移。
OVF 格式是以壓縮及封裝的方式來做備份,所以備份出來的檔案會比較小一些,但備份的時間就會耗費比較久一些,而且 OVF 備份時,虛擬機器必須要先關機,才能進行後續的備份工作。
1. 選擇 File / Export to OVF

[@more@]2. 選擇匯出 OVF 檔要存放的位置

3. 匯出的時間視虛擬機器的大小及電腦及磁碟機效能而定

4. 匯出完成

5. 磁碟空間使用比較
匯出前大小

匯出後大小

VMware ESXi – 版本資訊及維護模式

[root@esxi:/etc] /bin/vmware -v
VMware ESXi 6.5.0 build-4887370

[root@esxi:/etc] /bin/vmware -vl
VMware ESXi 6.5.0 build-4887370
VMware ESXi 6.5.0 GA

[root@esxi:/etc] /bin/esxcli software profile get
ESXi-6.5.0-20170104001-standard
   Name: ESXi-6.5.0-20170104001-standard
   Vendor: VMware, Inc.
   Creation Time: 2017-03-20T06:05:13
   Modification Time: 2017-03-20T06:08:07
   Stateless Ready: True
   Description:

[@more@]進入維護模式

提示訊息

畫面會顯示狀態是在 維護模式

使用指令進入維護模式
[root@esxi:/etc] /bin/vim-cmd /hostsvc/maintenance_mode_enter

退出維護

畫面會顯示狀態是在 正常模式

使用指令模式退出
[root@esxi:/etc] /bin/vim-cmd /hostsvc/maintenance_mode_exit