When you want to learn about disk partitioning or swap space or Logical Volume management or Stratis or VDO you need to have a free disk in your system. But by default when you install Linux in either VMware or Virtual-box there is no extra disk or free disk available. In this post, we will learn “How to add virtual disk in Linux using VMware/Virtual-Box” so that the primary disk is not impacted or the existing data is safe.
Let’s consider that you want to learn about creating disk partitions. For that, you want to work on a free disk. So, you use the lsblk command to view the list of all disk and partitions. You see an output similar to the one below. There is no free disk to work with. There is only one disk /dev/sda
Now, we will learn how to add a new disk. We will learn how to add virtual disk in Linux using VMware and Virtual-Box software.
Adding Virtual disk in Linux using Virtual-Box
Before starting make sure that the virtual machine is not running. If it is running shutdown the machine and follow the below steps.
Step1: Click on settings
Step2: In the new window click on “storage”
Step3: In the storage click on “Controller: SATA”
Step4: Out of the two ‘+’ symbols, click on the right hand one
Step5: On the next window click on “create”
Step 6: Choose VDI and Click “next”
Step 7: Choose Dynamically allocated and Click “next”
Step8: Choose the disk size as you desire. For example I choose 1Gb and press “Create”
Step 9: Now click on “Choose”. By default the most recent disk is selected. So, you simple click on “Choose”. need not to do any selection
Step10: You will see that the disk is added. Now click “Ok”
Now start your machine and use the lsblk command and you will see the newly added disk. For example in my case it is sdb whose size is 1Gb.
Adding Virtual disk in Linux using VMware
Before starting make sure that the virtual machine is not running. If it is running shutdown the machine and follow the below steps.
Step 1: Select the desired virtual machine and click on “Edit virtual machine settings”
Step 2: On the next window click on “Add” at the bottom
Step3: Next, select hard disk and press “Next” button
Step 4: Select “SCSI” which is the recommended option and click “Next”
Step 5: Next select “Create a new virtual disk” and click Next
Step6: Choose the right size (e.g., 2Gb) and select Split virtual disk into multiple files and click Next
Step 7: On the next screen click “Finish”
Step 8: The new virtual disk is added. Click on “Ok”
Now you can start the machine and verify that a new disk of 2Gb is added using the lsblk command.