How to Add Extra Disks on KVM based VM
Solution 1
You can use the virsh
option mentioned above (probably faster, in fact) or you can use the "Add Hardware" option in virt-manager
to either add new space or assign existing space.
Simply open the VM, go to "Details" (top left), and select "Add Hardware" (bottom left):
Storage is the default type of hardware, so it should already be selected by default.
FWIW, since it's a new disk, if the guest is Linux, you probably want to add it as VirtIO instead of IDE. VirtIO has better performance but non-Linux platforms need special drivers installed to be able to use VirtIO drives.
The GUI is pretty self-explanatory. Since you've already created the .img
file you probably want to select the "managed or existing storage" radio and go browsing for it. After that, it should be visible to the guest.
Solution 2
Adding a virtual disk can be done either using virt-manager
(A graphical interface for KVM) or virsh
.
Using virsh:
virsh edit VM-name
Modify your configuration file as needed and save the configuration file (See your vda
configuration line).
NOTE: You need to reboot the VM so the virtual disk is recognized.
Shutdown your VM using virsh destroy VM-name
and start the vm again using virsh start VM-name
Once you have logged in to the VM check fdisk -l
as root, otherwise it will not show anything.
Finally use mkfs.ext3 /dev/vdb
or mkfs.ext4 /dev/vdb
to assign a file system to the virtual disk.
Related videos on Youtube
Comments
-
OmiPenguin over 1 year
I installed Redhat 6.4 on KVM Server. Right Now there is only One Disk /dev/vda. Now I need to add extra Disk like /dev/vdb I tried adding New Volume but it is not showing when I do fdisk -l
How to add extra Volumes to existing running VMs
-
Marek Zakrzewski over 10 yearsYou are adding storage but it is not linked with a virtual machine. It is just a volume in the volume pool. Your VM does not know
Newpart.img
belongs to it. You need to point to this location/var/lib/libvirt/images/Newpart.img
in yourvirsh edit vm-name
file. -
Bratchley over 10 yearsThis is kind of wandering outside the question, but you might also think about creating a storage group backed by an LVM Volume Group instead of flat files. Flat files are useful if you can't anticipate how much space you'll need and need to economize storage space, or you want a least hassle initial set-up but LVM can ease management issues later on. For example, expanding these volumes or migrating them to a new storage device without turning any of the VM's off. Just my two cents, though.
-
-
OmiPenguin over 10 yearsI did tried to Add New Disk using virt-manager but it ain't working. As you can see in the image I uploaded it is already added but it is not attached to Server thats why it is not showing and there is no option to connect to server
-
OmiPenguin over 10 yearsYours GUI and my VMs GUI is different check the snap i added in the Question Section.
-
Bratchley over 10 yearsYou're just on a different screen. Close out of that window and open up the VM you want to modify (by double clicking on it) and go to "details" on it and you should see the screen I'm referencing up there.
-
OmiPenguin over 10 yearsHahhahaaha, It was right there all the time in menu and i didn't notice it. I will do a lot of practice on Double -Clicking. Thanks it worked.
-
Marek Zakrzewski over 10 years+1 On the answer. I did not have virt-manager so I could not demonstrate it. Well done Joel Davis.