(HOW-TO) Add disks in VirtualBox and extend disk space using LVM for Linux guests

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to my video describing how to add virtual disks to an existing virtual machine and then using common LVM or logical volume management tools inside Linux we will extend the size of this space we have for 104 your virtual machine now there's a couple of ways to create additional disk space for a virtual machine there is a tool on your host machine for a virtual box called V box managed and you can modify HD you could expand the size right now I just have the default size of 12 gig for my virtual disk I could make this bigger if I want but I'll show you another method to do all that instead of expanding out we'll just we'll just create new drives in here the particular distribution I'm using is linux mint 17.3 the command lines I'm going to show you really work for any distribution it really doesn't matter if you have a GUI or not it doesn't matter if it's Debian based or RPM based everything should work as long as your kernel is I think at least version 2.4 or later I think that's one LVM or LVM version - i think became common in all linux kernels so i'll go right in to show you my image here so here is i'm we're inside a vm right now and I'll do it just free to come in to show you how much space we have in here so I have 65 percent usage that's plenty of disk space but let's just pretend I want more disk space in here now I happen to know that the default way that Linux Mint partitions are drive and then configures everything it creates a logical volume that creates two of them actually so we're going to do LV display which is to show which will display all of the logical volumes you currently have in there and there's two by default it creates there's a single volume group called mint VG the VG means volume group this one is root so this root logical volume is mounted to the root filesystem and then down here a swap one again on the mint VG volume group has two gigabytes so 9.73 gig plus two gigabytes here is very very close to the twelve gigabytes total virtual disk I have in here and the other remaining looks like 236 MIT goes into the boot that's attached to the first partition of the virtual disk and all of this is just standard Linux Mint stuff in here and by the way if you want to have a website you can go to refer to all the commands I'm going to use how-to geek has a really great article on here it's called how to manage and use LVM in in boon to you you can ignore the in boon to part because like I said everything here is command-line and all of this is common to Linux it doesn't really matter what distribution you are in fact their own instructions are you they use command lines for everything too and I'm going to do almost everything that they're using in this article so I will shut down my VM and I'll whenever we can get started and we're back so I just power down my VM and now the very first thing you want to do because we're going to VM we can take snapshots so as you can see I took one already I took this one one minute ago I have my own way that I create snapshots I just put the current date and I just put a brief description there before adding new VMs in here so let's add the new virtual disks in here so we go into settings storage expand this out a little bit and then you click on the controller itself and this little green button over here the plus sign on it add add a hard disk we want to create a new one and I'm going to make 2/3 gigabyte disks on here just to show you that you can add multiple disks in here then you can combine all them together to form one volume group so you could make like one huge file system if you wanted out of many small disks or you could just make one I could make this as big as I wanted to and just add that one in there but I'll just show you I'll just do 2/3 gigabyte disks just for demonstration purposes I'll call them Mint LVM 0 3 gigabytes VDI dynamically allocated and will create I'll create another one make it a gigabyte I'll call this one Mint LVM 1 and there we go and it's that easy I created two new virtual disks disks I added them into this mint 17.3 virtual machine itself and I will save that and then I will power up ok I'm back I'm powered up now and right now I put the focus of my video recorder just in the VM itself so I will show you real quick that my new hard disks are in there we'll just look at the SD s d stands for SATA disks and you can see that we have the is this is the original virtual disk ahead in there and there's three partitions in there one two and five and then these are my new decided SD b and SD c so the first thing we got to do is we got a format or I'm sorry partition X I'm just going to go right into root because I get sick of typing sudo and every single thing I got to do and I got a type sudo for every single command I'm going to do so I'm just going to go right into I'm just going to become route itself I'm going to use the F disk utility to partition the first one s DB and I will use M for help and I want to create a new partition primary partition partition number one first sector it's fine I'm going to use up the entire disk and how do I change system ID there we go change the system ID I happen to just remember eyes that Xcode 8e means a Linux VM and I think I want to do W to write the table to the disk and I'm going to do the same thing for the second hard drive we created I'm going to create new partition new primary partition number one for sector default for the entire drive and I want to change the type to Linux LVM and partition table now if I do LS dash L of Asti all again you can see that two new partitions were created so so s DB is the drive itself stb-1 is that the new primary number one partition that I created same thing for this just down here as well so that's how you use F disk I just creates partitions for you next thing we're going to do is going to do something called PV display and you can see I only have a single physical volume so it's just the first virtual disk which is SDA and that v that just means it's not actually partition v it's SD a 2 is actually a logical partition and v is just a extended extended partition Linux Mint does this by default whenever it extols whatever installs your OS for the first time so what we want to do is do PV create because we want to want to add these two new virtual disks that we did so I'm going to add them both at the same time but would you be one first and then we'll do SDC one so we successfully created those so we'll just do PV display again and we see that we have the stb-1 is a new physical volume of three gigabytes and SDC c1 is a new physical volume of three gigabytes and now we're going to go to just show the existing volume groups that are in there so we'll do VG display and you can see there is one existing volume group the met volume group now what we're going to do is we're going to add these two new physical volumes that we just created into this one existing volume group called met VG so we do is we do VG extend and we're going to I'm going to use the minus T which means test the nice thing about LVM tools is that all of them have a dash T option where you can test everything you can put a command in there and it'll run through your command but it won't actually commit anything or change anything so that way you can kind of see the output before before it actually does it for real the volume group is going to be mint VG into BG I'm gonna do this on basically add in the volume groups that we just created onto the physical volumes Stevi one st c1 and we'll see what happens now you can see in here it says test mode metadata will not be updated so everything looks like mint VG was successfully extended so we'll do the same command this time but without the test option in there and client group was successfully extended I would do a VG display again to take a look at it now this is a important thing to note here the volume group name is met VG the important thing to know is the free PE PE stands for physical extent and 1541 is the number we we have we have to remember this number because we were we have 6 gig is currently free this is the eleven point seven gig that's currently allocated in the volume group this is the original amount that we started with we added two new three gigabyte disks and that's what's represented down here so the free physical extents are the amount of essentially unallocated space that's inside this volume group in here so what we want to do is we see yeah so that's that's the physical extents we want we want to add these into the logical volume so we're going to do when switch into tabs over here to another terminal display so we're going to do LV display LV means logical volume OOP see I hate doing I hate sudo so I'm just going to come root and just do LV display so at the moment there's only two logical volumes in here there's the route 1 and the Swap one the route is the one that we're going to extend so right now it's LV size at seven point nine point seventy three we want to extend that so we're going to do is LV extend - ow - L means the amount of size you want we're going to add a P for adding and then we're going to add in the physical extents number which over here it was 1541 you come back here we're going to add yes this doesn't work like putty does 1541 - r means that we are going to after it extends we want to it to automatically resize the file system the ext4 filesystem that's under - t for the test and then - V to define the volume group my volume group is dev mint VG root and let's see what happens here so all this comes out and we can see now this FSM or this FS admin thing you can kind of ignore the failed part of it resizing filesystem device so everything everything that looks like it worked on here all this kind of ugly output on here and now the one really important thing I want you to note is that we are extending the root filesystem so everything is the root filesystem is mounted always by default we're doing all of this in the command line on a live VM as it's running and it will extend it for us even though it's mounted it will still extend it for us so if we do the we just get rid of the dash T to do get rid of the test part and just do it for real and there you go looks like it did it so if I do a DF - H again we can see that on the root partition I now have 16 gigabytes 25.8 or still use and 8.9 are available and that's it really we're all done with this it really was that easy it all we did was added two new disks in there and a couple of commands and it extended and did everything for us all while the filesystem was mounted and running so thanks a lot for viewing my video and please be sure to like it and hopefully I'll make another one bye
Info
Channel: MrMalchore
Views: 16,850
Rating: undefined out of 5
Keywords: vbox, virtual box, linux, lvm, lvm2, linux mint, extend lvm partition
Id: hugEkh50Ynk
Channel Id: undefined
Length: 14min 15sec (855 seconds)
Published: Wed Jun 15 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.