Showing posts with label VMWare. Show all posts
Showing posts with label VMWare. Show all posts

Friday, April 2, 2010

How to extend LVM on VMWare Guest running Linux

Recently I found my one of virtual Linux machine which running on VMWare ESX server have run out of disk space. And after I googled the Internet, I think it's quite simple as my virtual Linux machine is running on LVM.

And I also found the following solution will also apply to any VMWare virtual machine which running Linux OS with LVM.

Expand the disk

Turn off the virtual machine that you wish to extend disk space.


You can expand the virtual disk size by entering ESX server hidden console mode or using VMware Infrastructure Client to remote manage your ESX Server. I will introduce both way here.

  1. Method One:

    Since the GUI mode is easy. Click Your VMWare Guest Machine in your remote management console from VMware Infrastructure Client. Then click "Edit Virtual Machine Settings" from "Getting Started" which is in the Right Panel. Select Hardware -> Hard Disk 1 -> Capacity - New Size (at Right Side), and then expand the Capacity to whatever size that you need. In our case, I expanded from 100GB to 200GB. Then press "OK".


  2. Method Two:

    For ESXi Server, using the following command to enter ESXi hidden console mode after press "Alt"+"F1":

    unsupported



    Then press "Enter", now enter your ESXi server root password. You should be able to successfully log into the hidden ESXi Server console.

    For ESX Server, If you press Alt-F1, you can get access to the Linux login prompt of the ESX service console and login to a command prompt.


Now enter the following command to expand the VM Disk:

vmkfstools -X 200G "Your VMDK file here"


To extend an existing Virtual Disk to 200GB.

Note:

If you are running VMware workstation product, then you can expand the virtual disk to expand the virtual disk on your Windows machine by running this command:

vmware-vdiskmanager -x 200G "My harddisk.vmdk"


After above steps, you finished preparing the extra virtual disk space. Now we can start your VMware virtual machine and open a terminal session to continue expanding your LVM.

Issue the df -k command which shows us that the logical volume is at 100% usage. We need to create a partition on /dev/sda. Type ls -al /dev/sda* which lists the existing partitions. Our new partition will be /dev/sda3.

# ls -al /dev/sda*
brw-r----- 1 root disk 8, 0 Apr 2 19:26 /dev/sda
brw-r----- 1 root disk 8, 1 Apr 2 19:26 /dev/sda1
brw-r----- 1 root disk 8, 2 Apr 2 19:26 /dev/sda2


Type fdisk /dev/sda then type n for new partition. Enter p and 3 for the partition number (in this instance, obviously enter the partition number that matches your environment.) Also accept the default First and Last cylinders. Finally type w to write table to disk and exit.

If prompted to reboot then do so to ensure that the new partition table is written. After a restart, type ls -al /dev/sda* to verify whether the new partition was created successfully.

# ls -al /dev/sda*
brw-r----- 1 root disk 8, 0 Apr 2 19:26 /dev/sda
brw-r----- 1 root disk 8, 1 Apr 2 19:26 /dev/sda1
brw-r----- 1 root disk 8, 2 Apr 2 19:26 /dev/sda2
brw-r----- 1 root disk 8, 3 Apr 2 19:26 /dev/sda3


After verification of new partition, we need to create a physical volume and add it to the volume group.

Type pvcreate /dev/sda3

[root@rhel5 ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created


Type vgextend VolGroup00 /dev/sda3

# vgextend VolGroup00 /dev/sda3
Volume group "VolGroup00" successfully extended


We need to extend the logical volume. Type vgdisplay:

# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 99.84 GB
PE Size 32.00 MB
Total PE 3345
Alloc PE / Size 2868 / 99.88 GB
Free PE / Size 2870 / 99.97 GB
VG UUID MkluWy-e5PA-QTGN-fF7k-ZxO3-6bC7-qxfCii


Which shows that there is 99.97GB free that we can add to the volume group. To extend the volume type lvextend -L +99.97G /dev/VolGroup00/LogVol00. If you got an error message that stated that there was "Insufficient free space: 2871 extends needed but only 2870 evailable". After a quick google: Insufficient Free Extents for a Logical Volume. It seems that we needed to select a lightly smaller size. So we changed to 99GB rather than 99.97GB which solved this problem.

# lvextend -L+99G /dev/VolGroup00/LogVol00
Rounding up size to full physical extent 99 GB
Extending logical volume LogVol00 to 198 GB
Logical volume LogVol00 successfully resized


Finally we need to resize the file system by typing resize2fs /dev/VolGroup00/LogVol00.

resize2fs /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 20101888 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 20101888 blocks long.


Type df -k to see if the new space is available to the logical volume.

df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
1713916000 82428400 88250280 48% /
/dev/sda1 101086 24538 71329 26% /boot
tmpfs 1037744 0 1037744 0% /dev/shm


The logical volume has now been resized and now has used space of just 48%!

Friday, February 19, 2010

Cannot create a VM file larger than 256GB in ESX 4.0

When I tried to create a 500GB virtual disk on a local storage in ESX 4.0 Server, I got the error message "Cannot create a VM file or virtual disk larger than 256GB" in vSphere Client.

I googled the Internet, I only found the solution is to Increase block size of local storage in ESX 4.0. And you only can do it during the ESX 4.0 installation.


Increasing block size of local storage in ESX 4.0

Symptoms

* You cannot create a file (virtual disk) larger than 256 GB on local storage.
* You cannot reformat local storage (device or resource busy).

Resolution

ESX 4.0 uses a different installer than previous versions of ESX, and uses default block size of 1 megabyte when creating the local VMFS volume. The largest file that can be created with a 1 megabyte block size is 256 GB in size.

To create a file bigger than 256 GB, the VMFS filesystem needs to have a block size larger than 1 MB. The maximums are as follows:






Block SizeMaximum File Size
1 MB256 GB
2 MB512 GB
4 MB1 TB
8 MB2 TB


For more information about block sizes, see Verifying the block size of a VMFS data store (1003565).

The service console in ESX 4.0 runs as a virtual machine on local storage. As such, you cannot reformat this volume.

To resolve this issue, perform one of these workarounds:

  • Re-install the ESX host on a different drive (for example, a second RAID set or boot from SAN), and leave the original disk for the VMFS volume. You can then choose your blocksize when creating the second datastore.

  • Install ESX 3.5, create the volume with desired blocksize, then upgrade to ESX 4.0.

  • Carve out a new LUN or RAID set on the local controller for a new volume. Add physical disks as necessary.


You cannot create a second datastore on the same drive via the ESX GUI. You must use the following command:

Note: You may need to create a partition on the free space first with fdisk.

vmkfstools -C vmfs -b Xm -S local2mBS /vmfs/devices/disks/naa.xxxxxxxxxx:y


where:

  • Xm is the blocksize (1m, 2m, 4m, or 8m).

  • local2mBS is your volume name. If the volume name has a space (for example, volume name), enclose it in quotation marks (for example, "volume name").

  • naa is the naa identifier, and y is the partition number. To determine this, run ls -la in the /vmfs/devices/disks folder.


Note: Depending on your disk controller type, naa. may be replaced with eui., t10., or mpx.. For more information, see Identifying disks when working with VMware ESX (1014953).

Alternatively, you can reconfigure the installer to install ESX 4.0 with a different blocksize:

  1. Boot the ESX installation DVD.

  2. Press Ctrl+Alt+F2 to switch to the shell.

  3. Run:

    ps | grep Xorg


  4. Kill the PID which shows Xorg -br -logfile ....

    For example, run:

    kill 590


    where 590 is the PID.

    Note: If you specified the a GUI mode installation, killing the process identified as Xorg may switch you back to another console. If this occurs, press Ctrl+Alt+F2 to return to the console.

  5. To switch to the configuration directory, run:

    cd /usr/lib/vmware/weasel


  6. To edit the configuration script, run:

    vi fsset.py


    Note: For more information on editing files, see Editing configuration files in VMware ESX (1017022).

  7. Locate class vmfs3FileSystem(FileSystemType):.

  8. Edit the blockSizeMB parameter to the block size that you want. It is currently be set to 1. The only values that work correctly are 1, 2, 4, and 8.

    Note: Press i for insert mode.

  9. To save and close the file, press Esc, type :wq, then press Enter.

  10. To switch back to the root directory, run:

    cd /


  11. To launch the installer with the new configuration, run:

    /bin/weasel


    And continue the ESX 4.0 installation.

Thursday, June 25, 2009

Install VMWare ESXi 4.0 on Dell Precision WS 390

Today I just found another Desktop with faster CPU and more memory - Dell Precision WorkStation 390 at work. Since the old IBM NetCenter M50 (8189KJU) is too slow to have any OS running on VMWare ESXi 3.5 Server.

First I tried a few times to install version 3.5, the installation of VMWare ESXi 3.5 was fine. But during Windows XP installation on Virtual Machine, I got stuck when I try to load Windows XP driver for the 2801GR/GH(ICH7 Family) Serial ATA Storage Controller RAID Card. I managed to find the driver and load the driver during Windows XP installation, but the setup always tells me it couldn't find the available space to install. I also tried different combination of RAID configuration and different Widnows XP drivers. But all have same results, I don't know why.


By the end, I did some research on the Internet, then I found this Dell machine is a 64-bit machine. Silly me! But the lucky thing is that I download the latest VMWare ESXi 4.0 which is 64-bit also a few days ago, so I can use it right away. The installation is went through quite smoothly without any problem, and also the installation of Windows XP Professional 32bit. I even didn't load any extra drivers during the installation.

So here is my test configuration:

Dell Precision WorkStation 390

CPU: Intel(R) Core(TM)2 6700 @ 2.66GHz
Memory: 2GB RAM
Storage Adapters: 2801GR/GH(ICH7 Family) Serial ATA Storage Controller RAID
Storage: 1 PC 80GB WDC, 2 PCs 250GB WDC with RAID1
Network Adapter: Precision 390 (100MB)

Software:
VMWare ESXi 4.0.0, 164009

Virtual Machine:
Windows XP Professional 32-Bit
Ubuntu Desktop 9.04

Wednesday, June 24, 2009

Install WinXP Virtual Machine on VMWare ESXi 3.5

Today I just tried to create a virtual machine and install Windows XP Professional with SP3 on a VMWare ESXi 3.5 Server. I though it will be easy since I already tried Windows 2003 Server on IBM eServer XSeries 345 with VMWare ESX Server 3.5 before. The only difference is this time I am installing the VMWare ESXi Server 3.5 on an IDE Hard Disk Drive, not SCSI. That's no a problem for me, since I also did the installation on IDE HDD in Feb. 2009, please see my post Install VMWare ESXi 3.5 to an IDE drive. So the installation for the ESXi Server was quite smooth. But when I try to install Windows XP Professional after I created new virtual machine. The installation was stopped and give the following error message.

"Setup did not find any hard disk drives installed in your computer."





After I did some homework via the Internet, finally I found this is because the necessary hard disk controller drivers have not been installed.

Within ESX and ESXi there are two types of SCSI controller types available. These are ‘BusLogic’ or ‘LSI Logic’.

When installing Windows XP the ESX VM will assign the ‘BusLogic’ SCSI controller type as the default. The Windows XP installation media doesn’t contain the drivers for either of these controllers so unless they are provided via floppy disk at the start of the installation process then XP will not know about any of the disks attached to the controller (which it doesn’t have drivers for).

Using an LSI Logic SCSI controller type has been shown to provide faster performance over that of a BusLogic controller type.

So here is the solutions:

1. Using the VMWare SCSI Disk Driver which provided by VMWare. You can download flp image from here:

http://www.vmware.com/download/server/drivers_tools.html

And press F6 quickly once you boot up the Windows XP professional setup CD/image, and select the driver from floppy image.

2. Or you can use the default driver which provided by Microsoft. But you also need to press F6 to load special driver.

After that you should be able to install Windows XP as usual.

Good Luck!

Monday, February 23, 2009

Install VMWare ESXi 3.5 on an IDE drive

When I tried to install VMWare ESXi 3.5 on IBM NetVista, but the installation was crashed. Then I tried to install it on IBM ThinkCentre. I got the error message "Unable to find a supported device to write the VMware ESX Server 3i 3.5.0 image to".

After I googled, I found the following article which helps me to correct the installation on IDE Drive.

http://www.vm-help.com/esx/esx3i/ESXi_install_to_IDE_drive/ESXi_install_to_IDE_drive.php


Here is the whole article:

By default, if the ESXi install can not find a supported device to install to, then the installer will quit with the error message: "Unable to find a supported device to write the VMware ESX Server 3i 3.5.0 image to." If it is the case that the IDE drive in your host is recognized by ESXi, then you will be able to modify the install script TargetFilter.py to recognize your IDE device as a supported install device.

Install Process:

  1. If you have encountered the error shown above, you can press ALT-F1 to access the console of the ESXi install. You'll be prompted for a login and you can use 'root'. The password for root with be blank. As mentioned above, this process assumes you have an IDE drive that ESXi can recognize. You can use the command lspci to show the list of devices that ESXi can recognize and then compare that with this list of devices. Also if you run fdisk -l, you should see your IDE drive listed.


  2. After you have console access you will enter the command

    vi /usr/lib/vmware/installer/Core/TargetFilter.py


    (note that the path and filename are case-sensitive).


  3. Scroll down in the document until you find the section "def IDEFilter(lun)". You will be changing the text:

    return interface.GetInterfaceType() == ScsiInterface.SCSI_IFACE_TYPE_IDE


    to

    return interface.GetInterfaceType() == ScsiInterface.SCSI_IFACE_TYPE_ISCSI


    If you have not used vi before, move the cursor to the end of "TYPE_IDE" and the press the Insert key. The press backspace to delete IDE and type in ISCSI. Then press the ESC key, type in the command :wq and press Enter to save the file and exit.


  4. You will now be back at the console. If you had stopped the installer at the screen show below, you can press ALT-F2 to return to the screen and press Enter to start the install, but it will still generate the error shown in the image above. You will need to press ALT-F1 and then type in install and press enter.


  5. When you run the install command, it is important to note that the installer will switch you back to the ALT-F2 (DCUI) screen. Press ALT-F1 to return to the console again. You will see the below screen again with the prompt to press Enter to install. Do so and the install will proceed.


  6. Press F11 on the next screen and you should then see your IDE drive as show below. Press Enter to continue and after a few minutes the install should complete and you will be prompted to reboot.


  7. After the reboot, you will be able to connect with the VI client and see that ESXi has installed to and created a VMFS partition on your IDE drive.



Comments System

Disqus Shortname