分类 VMware 下的文章

参考页面信息:https://openwrt.org/docs/guide-user/virtualization/vmware?s%5B%5D=esxi

在Linux下调整img文件的分区大小

1.准备工作

本操作需要用到qemu-img fdisk e2fsck resize2fs等工具,在ubuntu系统中,可以用下列命令安装

sudo apt-get install -y qemu-utils parted e2fsprogs

2.获取img文件

http://www.openwrt.org

3.扩展img文件大小

使用qemu-img工具扩展openwrt的img文件大小。本次扩展到1GB。

qemu-img resize -f raw 2openwrt.img 1G

4.调整img文件分区大小

  • 使用losetup将img文件挂载为环回设备:

    sudo losetup -fP ./2openwrt.img
    sudo losetup -a
    /dev/loop9: [64768]:6561801 (/home/user/openwrt-24.10/2openwrt.img)
  • 查看当前img文件的分区信息

    sudo parted /dev/loop9 unit s print
    Model: Loopback device (loopback)
    Disk /dev/loop9: 2097152s
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags: 
    
    Number  Start   End      Size     Type     File system  Flags
     1      512s    33279s   32768s   primary  ext2         boot
     2      33792s  246783s  212992s  primary  ext4
    
  • 用parted调整分区大小,不要删除分区,直接resizepart分区大小,不然如果你用的是EFI安装包的话,删除了分区后分区的uuid会发生变化。

    parted /dev/loop9
    print free
    resizepart 1GB
  • 同步分区信息

    sudo partx -u /dev/loop9

5.扩展新的root分区大小

  • 使用e2fsck 和 resize2fs 扩展新的root分区。

    sudo e2fsck -f /dev/loop9p2
    sudo resize2fs  /dev/loop9p2
    
    yangbo@homeserver2:~/openwrt-24.10$ sudo e2fsck -f /dev/loop9p2
    e2fsck 1.45.5 (07-Jan-2020)
    Pass 1: Checking inodes, blocks, and sizes
    Pass 2: Checking directory structure
    Pass 3: Checking directory connectivity
    Pass 4: Checking reference counts
    Pass 5: Checking group summary information
    Padding at end of inode bitmap is not set. Fix<y>? yes
    
    rootfs: ***** FILE SYSTEM WAS MODIFIED *****
    rootfs: 1573/6656 files (0.0% non-contiguous), 7887/32768 blocks
    yangbo@homeserver2:~/openwrt-24.10$ 
    yangbo@homeserver2:~/openwrt-24.10$ sudo resize2fs  /dev/loop9p2
    resize2fs 1.45.5 (07-Jan-2020)
    Resizing the filesystem on /dev/loop9p2 to 257920 (4k) blocks.
    The filesystem on /dev/loop9p2 is now 257920 (4k) blocks long.
    
    yangbo@homeserver2:~/openwrt-24.10$ 

将img文件转换为VMDK文件

openwrt的img文件不论是直接下载的还是扩容后的,都不能直接用于VMware ESXi。需要将其转换为vmware 的vmdk文件。使用qemu-img文件,命令如下

qemu-img convert -f raw -O vmdk 2openwrt.img 2openwrt.vmdk

在ESXi中创建虚拟机并使用扩容后的VMDK文件

这个就不写了,无非不过上传VMDK文件,创建虚拟机,使用已存在的虚拟硬盘即可。

问题

如果partuudi发生了变化,1.可以查看新的partuuid,然后修改boot分区grub.cfg文件的内容。2.重新操作,注意不要让partuuid发生变化。

https://vspherecentral.vmware.com/t/resource-management-and-availability/vsphere-resources-and-availability/drs-additional-option-cpu-over-commitment/

https://www.vcdx200.com/2018/01/vsphere-65-drs-cpu-over-commitment.html

A lot of VMware vSphere architects and engineers are designing their vSphere clusters for some overbooking ratios to define some level of the service (SLA or OLA) and differentiate between different compute tiers. They usually want to achieve something like

  • Tier 1 cluster (mission-critical applications) - 1:1 vCPU / pCPU ratio
  • Tier 2 cluster (business-critical applications) - 3:1 vCPU / pCPU ratio
  • Tier 3 cluster (supporting applications) - 5:1 vCPU / pCPU ratio
  • Tier 4 cluster (virtual desktops) - 10:1 vCPU / pCPU ratio

Before vSphere 6.5 we have to monitor it externally by vROps or some other monitoring tool. Some time ago I have blogged how to achieve it with PowerCLI and LogInsight - ESXi host vCPU/pCPU reporting via PowerCLI to LogInsight.

- 阅读剩余部分 -

原文:https://rvdnieuwendijk.com/2011/07/18/how-to-use-vmware-vsphere-powercli-to-find-a-virtual-machine-by-mac-address/

Sometimes you need to find a virtual machine by MAC address. This can be very time consuming if you have to do this by hand using the VMware vSphere Client. PowerCLI can do this task for you in only a few seconds. The script presented in this blogpost will retrieve the virtual machine that has a certain MAC address.

You can find the virtual machine with a certain MAC address by just using the PowerCLI Get-VM and Get-NetworkAdapter cmdlets and piping these together. E.g. to find the virtual machine with MAC address “00:0c:29:1d:5c:ec” you can give the following PowerCLI command:

 Get-VM | `
Get-NetworkAdapter | `
Where-Object {$_.MacAddress -eq "00:0c:29:1d:5c:ec"} | `
Format-List -Property *

- 阅读剩余部分 -