Resizing the disk space on Ubuntu Server VMs running on VMware ESXi 5

Resizing the disk space on Ubuntu Server VMs running on VMware ESXi 5

We generally do both dedicated and VPS hosting for our websites, apps and some premium projects we run for others.When we choose to have VPS servers (aka virtual machines or VMs for short) instead of dedicated servers, we usually opt for VMware‘s free ESXi 5 and install Ubuntu Server as the OS for the VPSs we create on top of ESXi 5. It may not be as friendly as some VPS providers like Amazon, Rackspace etc. but you got more control and it’s on YOUR hardware (pretty important actually!)…

Now, when you build a VPS on VMware, you start with say 40GBs of hard disk space. You install the OS, setup the server, move the sites on this new server and you’re on. But what happens when there’s no more room on the server for your site or sites and you need to add more disk space?

The process is quite simple:

a) Connect to the VMware ESXi 5 server using the vShpere Client. Edit the VM’s properties to increase the hard disk size (VM has to be off) – I won’t get into details on that, if you have the experience on managing ESXi you know what to do… I’m assuming the process is the same for ESXi 4. Now restart the VM.

b) Login via SSH to the VM and follow this process.
– First list all partitions:
$ ls -al /dev/sda*

– Create new partition using fdisk:
$ fdisk /dev/sda
type p – to list all your partitions
type n – to create a new partition
type l – for “logical”
then give it a number (e.g. if you got 2 partitions listed as /dev/sda1 & /dev/sda2, for the new partition simply type “3” to create /dev/sda3)
type t – to change the partition type to “Linux LVM”
provide the partition number you previously created
type 8e – for the “Linux LVM” type
type p – to list the new partition table
type w – to write changes and exit

– Reboot server:
$ reboot

– Assuming you created partition /dev/sda3, let’s now create the physical volume in that partition:
$ pvcreate /dev/sda3

– Now let’s extend the server’s Volume Group to that physical volume.
$ vgdisplay
This will give you the info on your current Volume Group. Note down the entry next to “VG Name”. That’s your Volume Group name.
$ vgextend EnterVolumeGroupNameHere /dev/sda3

Keep in mind
If you get a message saying /dev/sda3 could not be added to your Volume Group, you need to remove the physical volume and recreate it. Metadata might have gotten corrupt and thus the volume cannot be added to your Volume Group. So just do:
$ pvremove /dev/sda3
And then again:
$ pvcreate /dev/sda3

– Since we’re (essentially) extending the main logical volume, let’s get the name of that:
$ lvdisplay
and note down the entry next to “LV Name”. This is your logical volume’s name (e.g. /dev/srv/root), which you’ll now extend to the newly added partition/physical volume.

– Extend the logical volume by X GBs:
$ lvextend -L +XG yourLogicalVolumeName
Make sure you replace X above with the actual number of GBs you’ve added in your VM’s settings. So if you increased your VM by 20GBs, the command becomes:
$ lvextend -L +20G yourLogicalVolumeName

– Finally, let’s resize the file system to the new allocated space:
$ resize2fs yourLogicalVolumeName
(this may take some time depending on number of GBs added to the file system.

– Check the new file system sizes:
$ df -hT
You should now see an increased disk space for your primary logical volume.


Installing VMware Tools in an Ubuntu virtual machine with only a command line interface

Ubuntu Server with only a command line interface

  1. Go to Virtual Machine > Install VMware Tools (or VM > Install VMware Tools).Note: If you are running the light version of Fusion, or a version of Workstation without VMware Tools, or VMware Player, you are prompted to download the Tools before they can be installed. Click Download Now to begin the download.
  2. In the Ubuntu guest, run these commands:
    1. Run this command to create a directory to mount the CD-ROM:sudo mkdir /mnt/cdrom

      When prompted for a password, enter your Ubuntu admin user password.

      Note: For security reasons, the typed password is not displayed. You do not need to enter your password again for the next five minutes.

    2. Run this command to mount the CD-ROM:sudo mount /dev/cdrom /mnt/cdrom or sudo mount /dev/sr0 /mnt/cdrom
    3. The file name of the VMware Tools bundle varies depending on your version of the VMware product. Run this command to find the exact name:ls /mnt/cdrom
    4. Run this command to extract the contents of the VMware Tools bundle:tar xzvf /mnt/cdrom/VMwareTools-x.x.x-xxxx.tar.gz -C /tmp/

      Note: x.x.x-xxxx is the version discovered in the previous step.

    5. Run this command to change directories into the VMware Tools distribution:cd /tmp/vmware-tools-distrib/
    6. Run this command to install VMware Tools:sudo ./ -d

      Note: The -d switch assumes that you want to accept the defaults. If you do not use -d, press Return to accept each default or supply your own answers.

  3. Run this command to reboot the virtual machine after the installation completes:sudo reboot

Taken from:


NAV – Native database to SQL Migration

One of them that effect most of the customer is Support to NATIVE Database. So today we will discuss about Native to SQL Migration which is one of the steps during upgrade to NAV 2013.

Let’s See why we cannot restore a backup of Native Database into SQL Server Database.

For Demo Purpose i have taken a demo database and intentionally created some issues which normally occurs during SQL Migration.

So i have NAV 2009 SP1 Native DB with Errors. I took NAV backup and trying to restore same on SQL Server NAV 2009 SP1 Database.

Here is the error message that i get –

The Cust. Ledger Entry table contains a field with a date value that cannot be used with SQL Server:
Record: Entry No.=’1820′
Field: Posting Date=’01-01-0101′ (WHICH I CHANGED intentionally)

Reason –
SQL Date Starts From 01-01-1754.

*There are other errors too during restoring Native Backup to SQL.


We will follow the procedure given by Microsoft.

For this you will require Product DVD & Developer Licensce.

1) Navigate to Upgrade Toolkit ->SQL Migration in Product DVD.

2) you will find Migrate.fob.

3) Import Migrate.fob in Native Database(10 objects will be imported).

4) Run Codeunit 104010 Create Field Checking Code (This will create a text file in C Drive named as FIELDCHK.TXT.

5) If you are using windows 7 and the codeunit gives you an error message saying – “The operating system cannot access to the file C:\FIELDCHK.TXT .Verify that the file type and attributes are correct”.

Then design the codeunit and onRun Trigger change the Path of the File Name to some other drive.

6) A message will popup which confirm that file is created.

7) Import the txt file into the database. (you require Developer Licensce to do that).

8) After importing compile Codeunit 104015 Field Check. After compilation Run Codeunit 104015 Field Check.

9) This process will take time as per the size of your database and no. of companies in your database.

10) The will will keep you updated about number of errors that have been found yet.

11) Once completed it will display a message with count of total number of errors.

12) Once clicked OK a form will get open which will contain the incorrect value and suggested values from tool.

13) You can change the New value as per discussion with client.

14) After doing all rectification just click ESC and the message will confirm that you want to update the new values in tables.

15) Delete all records from table 104010 Incorrect Data Value & 104011 Code Field Information FROM ALL COMPANIES.

16) If selected yes the new values will be applied.

17) After completion mark Codeunit 104015 and then filter based on version @*MIG* and mark all listed records.

18) Remove the filter and select all marked objects.

19) Delete all objects(Total object count should be 10).

20) Take Navision backup and restore on SQL Server Database.


Taken from:

How to migrate data between DPM disks

MigrateDatasourceDataFromDPM is a command-line script that lets you migrate DPM data for a data source  (e.g. replica volumes and recovery point volumes) across disks. Such a migration might be necessary when your disk is full and cannot expand, your disk is due for replacement, or disk errors show up.

Depending on how you have configured your environment, this could mean one or more of the following scenarios for moving data source data:

  1. DPM disk to DPM disk
  2. Data source to DPM disk
  3. Data source to custom volume

DPM disk to DPM disk Migration

When I migrate DPM disk to DPM disk, I received errors mentioning there wasn’t enough disk space. After research and reference I found out it is because of the data sources I used span across multiple disks. The best explanation for this behaviour I found was located in this article: Space needed to migrate a disk.  More detailed information on DPM disk to DPM disk migration can be found in the following article: How to Use The Migratedatasourcedatafromdpm.Ps1 DPM Powershell Script to Move Data.

Data Source to DPM Disk Migration

I want to emphasize the second scenario (Data Source to DPM Disk) for which I wasn’t able to find many relevant articles. When I used this option had a few issues.

From the articles mentioned above, these were outlined as the required steps: the first 3 lines set the variables required for the migrateddatasourcedatafromdpm script, as follows:

  • $PG is the protection group available in your DPM.
  • $DS are the data sources
  • $disk is the disk available on the server.

Please take note that the first disk is $disk[0]. The first protection group is $pg[0] and first data source is $ds[0]

$pg = Get-ProtectionGroup DPMTestServer 
$ds = Get-Datasource $pg[0] 
$disk = Get-DPMDisk –DPMServerName DPMTestServer

The following step is the script which runs the migration of data source (no 1) to disk assign (disk no 2):

./MigrateDatasourceDataFromDPM.ps1 –DPMServerName DPMTestServer –Source $ds[0] –Destination $disk[2]

If you have multiple data sources in one protection group, then change the value [0] to [1] and so on.

Here’s a screen shot of a sample DPMDisk output:

Screen shot of a sample DPMDisk output

Once the script has finished executing, you’ll need to run consistency check. This is expected as there have been changes made to the volume, and these will need to be re-synchronized by running a synchronization job with consistency checking.


Taken from:

Remotely enable Remote Desktop in Windows 7/8/8.1

Step 1: Open ports in the Windows firewall

There is no native way to change the settings of a remote Windows firewall. However, you can use PsExec from SysInternals to disable it or change some rules.

If you download the app and drop it into your c:\ drive, you can run this command and get command line access for that remote box.

c:\psexec \\remote_machine_name cmd

Once you have that command line open, you can run this command to disable the firewall:

netsh advfirewall set currentprofile state off

Alternatively you can run this command to allow only Remote Desktop while still leaving the rest of the firewall as is:

netsh advfirewall firewall set rule group=”remote desktop” new enable=Yes

Step 2: Start the Remote Registry service

Load up the Services MMC (Control Panel > Administrative Tools > Services), right click on “Services (Local)” and choose “Connect to another computer”. Enter the name of your remote machine and connect to it. You should now be able to find the “Remote Registry” service and start it.

Depending on your environment, this may already be running, but I have found it generally isn’t on fresh computers.

Step 3: Change a registry setting to enable Remote Desktop

It’s time to make use of the Remote Registry and actually enable RDP. Load up regedit and go to File > Connect Network Registry. Enter the name of your remote computer and connect to it. Navigate to HKEY_LOCAL_MACHINE > System > CurrentControlSet > Control > Terminal Server. Change the value of “fDenyTSConnections” to “0”.

Step 4: Start the Remote Desktop service

Go back to the Services MMC you used in Step 2. Find the service “Remote Desktop Services” and start it (or restart if it is already running).

Step 5: Connect

By this point you should be able to connect to a remote desktop session on your remote computer. Remember that only administrative users can connect to an out-of-the-box Remote Desktop setup. If you have got this far and still can’t connect, it is worth checking your firewall rules to ensure nothing is being blocked.


Taken from:

Mikrotik – Basic universal firewall script

This is a basic script I always use when setting up Mikrotik firewalls from scratch.

/ip firewall address-list add address= disabled=no list=support

/ip firewall address-list

add address= comment=”Self-Identification [RFC 3330]” disabled=no list=bogons
add address= comment=”Private[RFC 1918] – CLASS A # Check if you need this subnet before enable it” disabled=yes list=bogons
add address= comment=”Loopback [RFC 3330]” disabled=no list=bogons
add address= comment=”Link Local [RFC 3330]” disabled=no list=bogons
add address= comment=”Private[RFC 1918] – CLASS B # Check if you need this subnet before enable it” disabled=yes list=bogons
add address= comment=”Private[RFC 1918] – CLASS C # Check if you need this subnet before enable it” disabled=yes list=bogons
add address= comment=”Reserved – IANA – TestNet1″ disabled=no list=bogons
add address= comment=”6to4 Relay Anycast [RFC 3068]” disabled=no list=bogons
add address= comment=”NIDB Testing” disabled=no list=bogons
add address= comment=”Reserved – IANA – TestNet2″ disabled=no list=bogons
add address= comment=”Reserved – IANA – TestNet3″ disabled=no list=bogons
add address= comment=”MC, Class D, IANA # Check if you need this subnet before enable it” disabled=yes list=bogons
/ip firewall filter

add action=add-src-to-address-list address-list=Syn_Flooder address-list-timeout=30m chain=input comment=”Add Syn Flood IP to the list” connection-limit=30,32 disabled=no protocol=tcp tcp-flags=syn
add action=drop chain=input comment=”Drop to syn flood list” disabled=no src-address-list=Syn_Flooder
add action=add-src-to-address-list address-list=Port_Scanner address-list-timeout=1w chain=input comment=”Port Scanner Detect” disabled=no protocol=tcp psd=21,3s,3,1
add action=drop chain=input comment=”Drop to port scan list” disabled=no src-address-list=Port_Scanner
add action=jump chain=input comment=”Jump for icmp input flow” disabled=no jump-target=ICMP protocol=icmp
add action=drop chain=input comment=”Block all access to the winbox – except to support list # DO NOT ENABLE THIS RULE BEFORE ADD YOUR SUBNET IN THE SUPPORT ADDRESS LIST” disabled=yes dst-port=8291 protocol=tcp src-address-list=!support
add action=jump chain=forward comment=”Jump for icmp forward flow” disabled=no jump-target=ICMP protocol=icmp
add action=drop chain=forward comment=”Drop to bogon list” disabled=no dst-address-list=bogons
add action=add-src-to-address-list address-list=spammers address-list-timeout=3h chain=forward comment=”Add Spammers to the list for 3 hours” connection-limit=30,32 disabled=no dst-port=25,587 limit=30/1m,0 protocol=tcp
add action=drop chain=forward comment=”Avoid spammers action” disabled=no dst-port=25,587 protocol=tcp src-address-list=spammers
add action=accept chain=input comment=”Accept DNS – UDP” disabled=no port=53 protocol=udp
add action=accept chain=input comment=”Accept DNS – TCP” disabled=no port=53 protocol=tcp
add action=accept chain=input comment=”Accept to established connections” connection-state=established disabled=no
add action=accept chain=input comment=”Accept to related connections” connection-state=related disabled=no
add action=accept chain=input comment=”Full access to SUPPORT address list” disabled=no src-address-list=support
add action=drop chain=input comment=”Drop anything else! # DO NOT ENABLE THIS RULE BEFORE YOU MAKE SURE ABOUT ALL ACCEPT RULES YOU NEED” disabled=yes
add action=accept chain=ICMP comment=”Echo request – Avoiding Ping Flood” disabled=no icmp-options=8:0 limit=1,5 protocol=icmp
add action=accept chain=ICMP comment=”Echo reply” disabled=no icmp-options=0:0 protocol=icmp
add action=accept chain=ICMP comment=”Time Exceeded” disabled=no icmp-options=11:0 protocol=icmp
add action=accept chain=ICMP comment=”Destination unreachable” disabled=no icmp-options=3:0-1 protocol=icmp
add action=accept chain=ICMP comment=PMTUD disabled=no icmp-options=3:4 protocol=icmp
add action=drop chain=ICMP comment=”Drop to the other ICMPs” disabled=no protocol=icmp
add action=jump chain=output comment=”Jump for icmp output” disabled=no jump-target=ICMP protocol=icmp



Taken from :