Monday, July 15, 2013

How to increase your Virtual Disk size running inside an ESX Server

This is something we all have face time and again. We configure and install an OS only to find later on that more space is needed on the primary partition. Well one could argue why not install one more virtual hard drive and use it. Well there are a number of softwares that will work only from the primary partition. Bad design, in my humble opinion, but nevertheless since the software works and solves the purpose so we might as well increase the disk space and give it more leg room.

It is pretty simple. Just run the following command from your ESX server console. Note: Take the following precautions before you attempt this operation:
  1. You should be logged in as an administrator to the ESX Console,
  2. You need to make sure that you do not have any snapshots. If you perform this operation on a virtual machine with a snapshot, your machine will fail to boot up later on.
  3. And make sure to back up your actual virtual machines files before doing anything.
The command to run on ESX server is:
vmkfstools -X [newsize] [your vmdk file]

and for VMware workstations, the command is:
vmware-vdiskmanager -X [newsize] [your vmdk file]

The vmware-vdiskmanager application will be available in the directory where VMware Workstation is installed. \VMware\VMware Workstation. So you should change (cd) to this directory and then execute the vmware-vdiskmanager command.

For example,
you have a Windows Server 2003 machine which was originally created with 20 GB of virtual HDD, however no you need more space and you now want a total space of 300G, so the command you will use:

vmkfstools -X 300g /vmfs/volumes/yourdatastore/your.vmdk,

where g in the 300 means 300 GB, for kilobytes use k, for mega bytes use M and that's it.

Now power up your machine, login and if you are running OS above Windows Vista and Windows Server 2008, from the disk management utility you could just say extend and it will work, however for Windows Server 2003 and Windows XP, the disk management tool does not have any extend functionality. I recommend the following tools:
  1. AOMEI Partition Assistant Standard (free) vailable at http://www.disk-partition.com.I have used this tool and can confidently say that it does its job.
  2. ExtPart.exe available from Dell. http://www.dell.com/support/drivers/in/en/19/driverdetails?driverid=R64398. I have not used this tool, however have read about it in a number of online blogs and other posts.
Hope this works out for you readers

Thursday, July 11, 2013

How to make iptables rules permanent

Linux distributions come with a pretty good firewall, called iptables. However one drawback with iptables is that changes made to the iptables are temporary i.e., they will be lost in the next reboot unless you save them.

There are couple of commands iptables-save and iptables-restore to save and restore the iptables. It is simple to use once you are done making your changes to the iptables, you can use the command iptables-save > [your file] to save your firewall rules to a file and later on restore the iptables rules by using the command iptables-restore < [your file].

However the restore command has to be executed by someone when the machine reboots. There are two approaches to handle this:
  • You execute the iptables-restore command manually every-time you reboot your linux OS, or
  • Make changes in your OS so that the iptables-restore command is executed automatically.
In this blog post I will list out the various mechanisms you can use to run the iptables-restore command. Note: This assumes that you do not install any other packages for managing the iptables.
  1. Add the iptables-restore command to your /etc/rc.local file. The /etc/rc.local file is a quick and easy way to restore your iptables, but be advised this is not the best place to put the iptables-restore command. Check this link on why not to use /etc/rc.local file. Anyways if you want to use it, simply add this to your /etc/rc.local file: /sbin/iptables-restore < /etc/iptables.rules, assuming you had saved your iptables rules in the /etc/iptables.rules file.
  2. The approach I recommend is to add a script in one of the following directories as per your need:
    • /etc/network/if-pre-up.d/: Scripts placed in this directory are executed just before the network is brought up.
    • /etc/network/if-up.d/: Scripts placed in this directory are executed just after the network has been brought up. I recommend using this directory for firewall rules. Create a file called iptables and give it execute permissions and add the following line in it
                  /sbin/iptables-restore < /etc/iptables.rules

There are other software packages for various linux distributions which also can be used to manage your firewalls. On ubuntu based distros, you can even use iptables-persistent application, which can help you manager your iptables based firewall. Some other firewall applications are ufw (Uncomplicated Fire Wall).