We recently updated our hardware (old ESX server) and had to export and import the virtual machines to the new server

In achieving this goal, we had to use an external USB drive to backup and transfer VMDK files from an old ESX server to the new one.

Requirements:

  • External USB drive with enough capacity
  • The drive has to be formated (preferably ext3 or ext4)
  • Coffee, cigarett or anything but no alcohol ;-)

Format and Mount the Drive:

 Steps:

  • Connect the external drive to the ESX server
  • Login to the server console using ssh connection (e.g putty)
  • To find out where the device is connected, enter “fdisk -l” (without the quotes ” “)
  1. fdisk -l

 

 

 

 

Note: As seen above, a partition has been created and only need to be formated

  • Format the new drive by typing these commands

  mkfs.ext3 -m 1 /dev/sdb1

 e2label /dev/sdb1 /ExtUSB (optional)

  where sdb1 is the partition shown above and 1 for 1% of the partition for administrative purposes

  for more information, type man mkfs.ext3   

  • Create a folder (mount point) where you want to mount the new drive (Example: mkdir /ExtUSB)
  • mount -t ext3 /dev/sdb1 /ExtUSB

  To make this permanet, type vi /etc/fstab and enter:

  LABEL=/ExtUSB1  /ExtUSB   ext3   defaults        0 0

  Save the file (type  :wq and press ENTER)

  • mount the partition

  mount -a

  • Check the to see that the new partition is mounted as expected by typing

  mount

Export the VM files and Logs to the external USB drive:

Vmktools is the VMware ESX Server file system management tool we used for this task. It is a program for creating and manipulating virtual disks, files systems, logical volumes and physical storage devices on the VMware ESX Server. To export or import VMDK (virtual disk) files, the command to use is ‘vmkstools’.

Export:

  • Enter the following comands as it is to export the VMDK files

  vmkfstools -i /vmfs/volumes/[datastore_name]/[vm_name]/[vm_name].vmdk /mnt/usb/[vm_name].vmdk -d 2gbsparse

  • To also export the configuration files for the virtual machine, just copy all those files with the following extentions: *.vmx, /.log, *.nvram, *.vmxf and *.vmsd. The best way to do this, is to first zip the files in tar.gz format and then copy to the external USB drive as follows:

  cd /vmfs/volumes/[datastore_name]/[vm_name]/

  tar -czvf [vm_name].tar.gz *.vmx *.log *.nvram *.vmxf *.vmsd

  cp [vm_name].tar.gz /mnt/usb/

Import:

Prior to importing the exported files, make sure you have created a new virtual machine (name it whatever you want). The VMDK and other files in the newly created virtual machine must be deleted to avoid conflicts with the ones to be imported. Take a look at these images to get an idea where to find these files:

Browse Data Storage

Browse the Data Storage

Delete VMDK Files

Delete all files from the VM folder as shown above

  • Enter the following comands to import the VMDK files

 vmkfstools -i /[path_to_USB_mount]/[vm_name].vmdk /vmfs/volumes/[datastore_name]/[vm_name]/[vm_name].vmdk

  • To also import the configuration files for the virtual machine, first extract [vm_name].tar.gz file to a folder (should be created first) and just copy all those files with the following extentions: *.vmx, /.log, *.nvram, *.vmxf and *.vmsd to /vmfs/volumes/[datastore_name]/[vm_name]/. The following comands should take care of this task:

  cd ~ (change to home directory)

  mkdir VMDK-Files

  cp /ExtUSB/[vm_name].tar.gz VMK-Files/

  cd VMDK-Files/

 tar -xzvf [vm_name].tar.gz

  rm -rf [vm_name].tar.gz

    cp * /vmfs/volumes/[datastore_name]/[vm_name]/

You can check to see if all files are imported as shown below:

Imported VMDK Files

Now, go ahead and start your VM machine. If carefully done, it should work as expected.

Related Site:

http://www.vladan.fr/

Written on December 25th, 2012 , ESX, ESXi, Linux, Recent Posts
 
There are many methods to do this and I will be covering some of these methods here
These methods has been successfully tested on RHEL and CentOS but I am also sure it will work on many other Linux distributions.
 
Disabling CD/DVD ROM
 
1. Method:
 
A more practical and reversible way is to rename the kernel module
Log into the linux system and enter the following inputs on the system console
 
[root@lnxesx ~]# cd /lib/modules/$(uname -r)/kernel/drivers/cdrom
[root@lnxesx cdrom]# ls
cdrom.ko-ok
[root@lnxesx cdrom]# mv cdrom.ko cdrom.ko-ok
 
Disabling USB Port

1. Method:

Similarly to the method used above for CD/DVD ROM, USB ports can be disabled using same method as well.
 
[root@lnxesx ~]# cd /lib/modules/$(uname -r)/kernel/drivers/usb/storage
[root@lnxesx storage]# ls
ums-alauda.ko   ums-datafab.ko  ums-isd200.ko    ums-karma.ko     ums-sddr09.ko  ums-usbat.ko
ums-cypress.ko  ums-freecom.ko  ums-jumpshot.ko  ums-onetouch.ko  ums-sddr55.ko  usb-storage.ko-ok
[root@lnxesx storage]# mv usb-storage.ko usb-storage.ko-ok
 
2. Method:
 
Grub option
 
You can get rid of all USB devices by disabling kernel support for USB via GRUB. Open grub.conf or menu.lst (Under Debian / Ubuntu Linux) and append “nousb” to the kernel line as follows:
 
kernel /vmlinuz-2.6.18-128.1.1.el5 ro root=LABEL=/ console=tty0 console=ttyS1,19200n8 nousb
 
Written on December 25th, 2012 , Linux, Recent Posts
A common security concern at organizations is allowing users to plug in a usb flash drive, because they could so easily copy corporate data.
 
To Enable or Disable USB port:
 
1. Method:
 
1. Click Start, and then click Run.
2. In the Open box, type regedit, and then click OK.
3. Locate, and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor
4. In the right pane, double-click Start.
5. In the Value data box, type 3 to Enable and 4 to disable, click Hexadecimal (if it is not already selected), and then click OK.
6. Quit Registry Editor.
 
2. Method:
 
Since Windows XP SP2, you can disable writing to USB devices altogether using a simple registry hack. Here it is:
 
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies]
“WriteProtect”=dword:00000001
 
You can also just download one of the following registry tweaks to enable or disable writing to USB drives.
 
Enable USB Write
 
Disable USB Write
 
Once you use the registry hack, you will have to reboot for the changes to take effect. One should also note that if you are using this trick, you should make sure that the users are not administrators on the computer, because they could easily change this setting back.
 
This works on Windows Vista as well. Here’s the window you’ll get when you try and write to a USB drive: 
 
 
To Enable or Disable CD/DVD  ROMport:
 
1. Click Start, and then click Run.
2. In the Open box, type regedit, and then click OK.
3. Locate, and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\cdrom
4. In the right pane, double-click Start.
5. In the Value data box, type 1 to Enable and 4 to disable, click Hexadecimal (if it is not already selected), and then click OK.
6. Quit Registry Editor.
 

I must admit, I have never had this bug for a very loong time. I thought It must have been fixed or rather removed all together. It was first reported with RHEL 6.1 and was removed as commented here by the developers.

However, I came accross this bug again while trying configure one of my DNS servers running on CentOS 6.3. The DNS (named) service always stopped on the following

Problem:

#service named restart

Generating /etc/rndc.key:

Solution:

Just exceute the following command:

#rndc-confgen -a -r /dev/urandom

and if you’re runing chroot under /var/named/chroot, you must add “-t /var/named/chroot” to the command above. It should look like this:

#rndc-confgen -a -r /dev/urandom -t /var/named/chroot

More description to rndc-confgen can be found here

You should be able to start DNS (named) service after executing these commands.

Good luck ;-)

Written on November 27th, 2012 , DNS, Linux, Recent Posts

Download the network installation iso file and burn to CD.

Place the CD in the CD-Rom and reboot the system.

When ask to select the network install method, choose “HTTP” and enter the following:

1) for 32 Bit
Host: mirror.centos.org
Directory: centos/6.3/os/i386

2) for 64 Bit
Host: mirror.centos.org
Directory: centos/6.3/os/x86_64

Written on November 13th, 2012 , CentOS, Linux, Linux Installation, Recent Posts

OMOTECH Tips & Tricks is proudly powered by WordPress and the Theme Adventure by Eric Schwarz
Entries (RSS) and Comments (RSS).

OMOTECH Tips & Tricks

this blog offers tutorials based on various it-subjects