Wednesday, January 9, 2013

Add New Disk Space to a Virtual Machine in Linux - in VMware

Among many FAQ; very familiar question in VM is how to add new disks. Here are the plain and simple steps to do that:

Objective: Add new disk space in a virtual machine in Linux.

Step 1: Open/Edit virtual machine settings:
Select your virtual machine, and press “Edit virtual machine settings’
Open/Edit Virtual Machine Settings

Step 2: Add new hardware:
From Hardware section click "Add" > "Next"
Add Hardware

Step 3: Select new Hard Disk:
From Hardware type select Hard Disk and click "Next"
Add Hardware

Step 4: Create the Disk Type:
Recommended Virtual Disk Type should be SCSI (don't know why :-P). Select the Disk type from available options:
Disk Type

Step 5: Set Disk Capacity & Options:
Now set the capacity you want to create. One of the nice features of VMWare is that you don’t have to allocate all of the disk space when you create it. So if you create a 20GB disk it won't take all spaces right away (unless you check the box), the disk will grow as your virtual machine needs it. Lastly, you can split the files into 2GB sizes, while this isn’t necessary, it just makes all the disks much easier to manage and move around. In example we are adding 20GB.
Disk Capacity

Step 6: Specify VM Disk File:
VM Disk File

Step 7: Ensure newly add Disk exists in Hardware Option:
HDD Added

Step 8: Boot & Power On the Virtual Machine.

Step 9: Create new Partition:
Login as root. In Linux the first SCSI drive is sda, the second sdb, the third sdc, etc. since this was the second SCSI drive we added in the VM, the device is known as /dev/sdb

[root@localhost ~]# fdisk /dev/sdb
Press m for help
To create a new partition, press n
This is going to be a primary partition so press p
Partition number is 1
Enter first Cylinder Number:
Enter Last Cylinder number: +20480M (as because our disk size is 20GB)
Press w for write and save the partition table.

Step 10: Format the partition:
Now we have to format the partition with new file system. We’ve decided to use ext3 file system for newly added disk.

[root@localhost ~]# mkfs -t ext3 /dev/sdb1
Above command changes the file system type to ext3 for /dev/sdb1 partition (-t fstype) (man mkfs)

Step 11: Creating Mount Point for new partition:
Create a new directory named app under /
[root@localhost ~]# mkdir -p /app
[root@localhost ~]# mount -t ext3 /dev/sdb1 /app


check whether the partition is properly mounted by running the following command
[root@localhost ~]# df -k

Step 12: Edit fstab for permanent entry:
mounting wont be permanent unless you add a fstab entry
/dev/sdb1 /app ext3 defaults 1 1

ENJOY :-)

Restore Archived Log into VMware Aria Operations for Logs (formerly known as vRealize Log Insight - vRLI)

As we cannot keep all logs in searchable space in vRLI production system due to performance and slowness issue, it is always recommended to ...