Sometimes we got the situation when we have already built a host on the VMware virtual machine, then we are asked to change or add new disks on it. The changes/disk addition are usually proposed by our business users, their needs, for examples are : disks addition for adding new Oracle data files , adding new databases or also for backup/archiving data, and other purpose. In this article, we will explain how to create/add new virtual disks on Ubuntu hosted on VMware. It will be explained the steps for adding a new SCSI based virtual disk on a Ubuntu Linux virtual machine. We are assuming that the we are using VMware workstation which is running on Windows 10.
The Steps To Add New Disks To an Existing Ubuntu Virtual Machine on VMware
To add a new virtual disk for an existing Linux virtual machine, there are two main steps to be taken : preparing new disk from host machine and then configuring new disk on virtual machine. The most important things before doing this is to ensure the disk avaibality on host machine. If there was an insuficient disk on host machine, just do adding new phisical disks on it. Here’s the step of adding disks on Ubuntu VMware.
Preparing New Disks From Host Machine
Before adding new disk on VM host, we have to shutdown first the virtual machine which will be added, and then following these steps :
- Right click the VM and select Edit Settings, it will show the “Virtual Machine Settings” dialog box :
2. By clicking the “Add…” button it will show the “Add Hardware Wizard” dialog box, select the “Hard Disk”.
3. Select the SCSI as virtual disk type.
4. Select ‘Create a new virtual disk‘
5. Spesify disk capacity for new disk, at this example the value will be 20GB.
6. Specify the location for this new disk on hosted phisical machine, by clicking ‘Browse…‘ button.
7. Verify new disks has been added to the VM.
After configuring new disks on VM, we then configure these new disk on guest host virtual machine. The step will be explained on next steps.
Configuring New Disk on Virtual Machine
- Lists all existing hard disks attached to the VM, its meant finding new attached disk to this VM. At this case, the new disk is labeled as
ramans@ubuntu:~$ ls /dev/sd*
/dev/sda /dev/sda1 /dev/sdb
2. By using several generic Linux/Unix commands, do the following steps. switch to be a
root user for doing it.
pvcreate initializes a PV so that it is recognized as belonging to LVM, and allows the PV to be used in a VG (Volume Group).
vgcreate creates a new VG on block devices.
root@ubuntu:~# pvcreate /dev/sdb root@ubuntu:~# vgcreate vgdata01 /dev/sdb root@ubuntu:~# lvcreate -L 10GB lvdata01 vgdata01 root@ubuntu:~# lvcreate -L 9GB lvdata02 vgdata01 root@ubuntu:~# mkfs.xfs /dev/vgdta01/lvdata01 root@ubuntu:~# mkfs.xfs /dev/vgdata01/lvdata02
We will give the new name for this logical volume as new mountpoint as /oracle and /data01, and mount all new volume with its new mountpoint Do it with command :
root@ubuntu:~# mkidir /oracle root@ubuntu:~# mkdir /data01 root@ubuntu:~# mount /dev/mapper/gadata01-lvdata01 /oracle root@ubuntu:~# mount /dev/mapper/gadata01-lvdata02 /data01
For permanent soultion, we have to put it to
/etc/fstab file. Just edit this file and append the file.
Now, the new disk has been mounted with two new mountpoint /oracle and /data01, each having size 10GB and 9GB.