How to add disk on a virtual machine in VMware
To Add The Disk On A Virtual Machine In VMware
Introduction:
VMware Workstation is a Desktop Hypervisor product line that lets users run virtual machines, containers, and Kubernetes clusters. Several commands allow you to reset and scan one or more interconnects, potentially adding and removing multiple devices in one operation. This type of scan can be disruptive, as it can cause delays while I/O operations timeout, and remove devices unexpectedly.
Procedure:
Step 1: First power on the virtual machine and open the terminal.
Step 2: Switch to the root user by using following command then enter the globalt user password
globalt@linuxhelp:~/Desktop$ sudo su
[sudo] password for globalt:
root@linuxhelp:/home/globalt/Desktop#
Step 3: Before add the device list the block device by using the below command
root@linuxhelp:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 4K 1 loop /snap/bare/5
loop1 7:1 0 63.9M 1 loop /snap/core20/2182
loop2 7:2 0 73.9M 1 loop /snap/core22/864
loop3 7:3 0 497M 1 loop /snap/gnome-42-2204/141
loop4 7:4 0 400.8M 1 loop /snap/gnome-3-38-2004/112
loop5 7:5 0 163.3M 1 loop /snap/firefox/1635
loop6 7:6 0 349.7M 1 loop /snap/gnome-3-38-2004/143
loop7 7:7 0 63.5M 1 loop /snap/core20/2015
loop8 7:8 0 45.9M 1 loop /snap/snap-store/582
loop9 7:9 0 91.7M 1 loop /snap/gtk-common-themes/1535
loop10 7:10 0 40.9M 1 loop /snap/snapd/20290
loop11 7:11 0 40.4M 1 loop /snap/snapd/20671
loop12 7:12 0 12.3M 1 loop /snap/snap-store/959
loop13 7:13 0 452K 1 loop /snap/snapd-desktop-integration/83
loop14 7:14 0 284K 1 loop /snap/snapd-desktop-integration/14
loop15 7:15 0 74.2M 1 loop /snap/core22/1122
sda 8:0 0 40G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 513M 0 part /boot/efi
└─sda3 8:3 0 39.5G 0 part /
sr0 11:0 1 1024M 0 rom
Step 4: Now right click on the virtual machine and click settings as shown in the below image
Step 5: Click Add button as shown in the below image
Step 6: Select Hardware type as Hard Disk and click next as shown in the below image
Step 7: Select Virtual Disk type and click next as shown in the below image
Step 8: Select Disk and click next as shown in the below image
Step 9: Enter disk size and click next as shown in the below image
Step 10: Enter Disk file name and click finish button as shown in the below image
Step 11: Now click ok button to add the disk as shown in the below image
Step 12: After the disk added, now list the devices using lsblk by using the below command
root@linuxhelp:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 4K 1 loop /snap/bare/5
loop1 7:1 0 63.9M 1 loop /snap/core20/2182
loop2 7:2 0 73.9M 1 loop /snap/core22/864
loop3 7:3 0 497M 1 loop /snap/gnome-42-2204/141
loop4 7:4 0 400.8M 1 loop /snap/gnome-3-38-2004/112
loop5 7:5 0 163.3M 1 loop /snap/firefox/1635
loop6 7:6 0 349.7M 1 loop /snap/gnome-3-38-2004/143
loop7 7:7 0 63.5M 1 loop /snap/core20/2015
loop8 7:8 0 45.9M 1 loop /snap/snap-store/582
loop9 7:9 0 91.7M 1 loop /snap/gtk-common-themes/1535
loop10 7:10 0 40.9M 1 loop /snap/snapd/20290
loop11 7:11 0 40.4M 1 loop /snap/snapd/20671
loop12 7:12 0 12.3M 1 loop /snap/snap-store/959
loop13 7:13 0 452K 1 loop /snap/snapd-desktop-integration/83
loop14 7:14 0 284K 1 loop /snap/snapd-desktop-integration/14
loop15 7:15 0 74.2M 1 loop /snap/core22/1122
sda 8:0 0 40G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 513M 0 part /boot/efi
└─sda3 8:3 0 39.5G 0 part /
sr0 11:0 1 1024M 0 rom
Step 13: Now list the partition table using fdisk
root@linuxhelp:~# fdisk -l
Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F747C239-799C-4F59-A541-2CADC6E836C5
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 1054719 1050624 513M EFI System
/dev/sda3 1054720 83884031 82829312 39.5G Linux filesystem
Step 14: Below script to scan all your host. This script will scan each and every SCSI host.
root@linuxhelp:~# for x in `ls /sys/class/scsi_host/` ; do echo "-----$x Scanned-----"; echo "- - -" > /sys/class/scsi_host/$x/scan ; done
-----host0 Scanned-----
-----host1 Scanned-----
-----host10 Scanned-----
-----host11 Scanned-----
-----host12 Scanned-----
-----host13 Scanned-----
-----host14 Scanned-----
-----host15 Scanned-----
-----host16 Scanned-----
-----host17 Scanned-----
-----host18 Scanned-----
-----host19 Scanned-----
-----host2 Scanned-----
-----host20 Scanned-----
-----host21 Scanned-----
-----host22 Scanned-----
-----host23 Scanned-----
-----host24 Scanned-----
-----host25 Scanned-----
-----host26 Scanned-----
-----host27 Scanned-----
-----host28 Scanned-----
-----host29 Scanned-----
-----host3 Scanned-----
-----host30 Scanned-----
-----host31 Scanned-----
-----host32 Scanned-----
-----host4 Scanned-----
-----host5 Scanned-----
-----host6 Scanned-----
-----host7 Scanned-----
-----host8 Scanned-----
-----host9 Scanned-----
Step 15: Now use lsblk command again to see newly added disk.
root@linuxhelp:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 4K 1 loop /snap/bare/5
loop1 7:1 0 63.9M 1 loop /snap/core20/2182
loop2 7:2 0 73.9M 1 loop /snap/core22/864
loop3 7:3 0 497M 1 loop /snap/gnome-42-2204/141
loop4 7:4 0 400.8M 1 loop /snap/gnome-3-38-2004/112
loop5 7:5 0 163.3M 1 loop /snap/firefox/1635
loop6 7:6 0 349.7M 1 loop /snap/gnome-3-38-2004/143
loop7 7:7 0 63.5M 1 loop /snap/core20/2015
loop8 7:8 0 45.9M 1 loop /snap/snap-store/582
loop9 7:9 0 91.7M 1 loop /snap/gtk-common-themes/1535
loop10 7:10 0 40.9M 1 loop /snap/snapd/20290
loop11 7:11 0 40.4M 1 loop /snap/snapd/20671
loop12 7:12 0 12.3M 1 loop /snap/snap-store/959
loop13 7:13 0 452K 1 loop /snap/snapd-desktop-integration/83
loop14 7:14 0 284K 1 loop /snap/snapd-desktop-integration/14
loop15 7:15 0 74.2M 1 loop /snap/core22/1122
sda 8:0 0 40G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 513M 0 part /boot/efi
└─sda3 8:3 0 39.5G 0 part /
sdb 8:16 0 5G 0 disk
sr0 11:0 1 1024M 0 rom
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to add disk on virtual machine in VMware without reboot. Your feedback is much welcome.
# fdisk -l
# lsblk