Virt-Manager Tips and Tricks from a VM Junkie

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so i do a lot with virtual machines i install a ton of operating systems in virtual machines and it's great for testing out new linux distributions or sometimes testing out potentially dangerous things that you wouldn't want to do on physical hardware on your production machine it makes sense sometimes just to spin up a virtual machine to test things out in and i have two virtualization programs installed on my system i have virtualbox which works on windows mac and linux and i also have vert manager which is a virtualization program specifically designed for linux and most of the virtual machines i create i actually use vert manager for i much prefer it to virtualbox the reason i like virtualbox and often mention virtualbox on my videos is because i know many people that watch my content are windows users or mac users that are thinking about coming over to linux and if those guys want to try out a linux distribution for example inside a virtual machine then they would want to use something like virtualbox because they can't actually use vert manager verb manager has to be run on a linux host now i've done a previous video about vert manager in the past on how to install it and set it up on linux today i want to dive a little deeper i want to cover just a few quick topics today i want to talk about cloning virtual machines i want to talk about how to convert your existing virtual box images over to images that vert manager can handle i'm also going to talk about how to connect your usb devices and we're going to create shared folders between your host machine and your guest machines as well so let me switch over to my desktop and i've got vert manager open here you can see i have a number of virtual machines here that i keep around for testing purposes and you can see that all of these virtual machines are qemu kvm type virtual machines so what is kvm that is the kernel virtual machine meaning that inside the linux kernel itself there are certain modules that are actually virtualization modules meaning essentially the linux kernel has the ability to create virtual machines and that is why these kvm virtual machines that run invert manager they have some performance increases compared to virtual machines that you would run in virtualbox for example because virtualbox of course can't really access the linux kernel in any way so that is the advantage if you're a linux user of using vert manager and these kvm virtual machines now the first thing i want to show you guys is how to connect a usb device because that's one of the most common things when i tell people about virtual machines when they first start trying them out is hey how do i connect my usb external hard drive or my my thumb drive or various usb peripherals to my virtual machines well and vert manager makes this really easy it's much easier than even in virtual box because really it's taking one thing in a menu and your usb devices should just work so i'm going to plug this into my computer that is a usb drive that has arco linux actually installed on that and i'm telling you what's installed on it so you can verify it when i connect to this virtual machine so i'm going to start this manjaro kde virtual machine and let's make that full screen i'm not going to make it entirely full screen i'm going to keep the menu up for a second because we will need this menu in a second so let me login all right now that we have logged in to manjaro kde what i'm going to do is i'm going to go up here and i'm going to go to redirect usb device and when you click on that you have all the current usb devices that are connected to my computer and i can turn any of them on oddly enough there are a couple of devices in here that are actually working inside the vm currently like my moon lander which is my keyboard and then my kensington expert which is my trackball mouse i mean i'm using the trackball right now so i don't actually have to tick these on they're already working but some things are not going to work for example this sandisk 16 gigabyte usb stick that i plugged in it's not currently going to be shown inside manjaro unless i tick that on and then i close this and now let me go ahead and make this properly full screen and you saw the discs and devices uh pop up here in kde that was letting me know hey we just plugged in a new device i could also go into the dolphin file manager here and in the far left hand corner here you see arco linux b extended edition and if i click on it yeah there is what is actually on that usb stick that we plugged in so that is how you connect your usb devices now i shut down that virtual machine the kde manjoro virtual machine now i want to show you how to clone a virtual machine because this is dead simple to do and it's something i don't think enough people fully utilize because when i'm testing things when i'm testing software when i'm testing scripts and things like that that i don't want to necessarily execute inside a physical machine on real hardware i want to do this inside a virtual machine but here's the thing say i test something that's kind of dangerous and then it completely hoses my virtual machine well then i've got to reinstall in this case manjaro kde set up a new virtual machine now the linux installations these days they only take 10 15 minutes typically but that's still 10 or 15 minutes worth of time that is wasted now because i have to go and set up a new virtual machine to test that piece of software again and it may break the virtual machine again so what you want to do is keep clones of your vms around for example i do a lot of testing on these arch based distributions that's why i have so many arch based vms here and specifically i keep these around for dtos testing so what i do is i set up a fresh installation of manjaro kde i know it's up to date and then i right click on it and i choose clone and then i could give it a different name by default it's going to call it manjaro kde clone that's fine now this is going to take about a minute or two and that took about a minute and now we have this new manjaro kde clone vm and again i i think that's very important it's one of the things and i don't do enough sometimes stressing the importance of this because i often tell you guys to if it's your very first time installing something like arch or gen 2 or you know some distribution like that nyx hey try it out in a virtual machine you know you guys that are playing around with linux from scratch for example that are going to take several days or several weeks sometimes to install that particular distribution you're typically doing that in a vm and it's nice sometimes when you get to a stopping point and you know you're good up to this point clone the virtual machine that way if from that point you do something dumb and actually break things well at least you kind of have a snapshot to go back to i find this i often use this with gen 2 installations inside virtual machines where i do the gen 2 base install and then i clone it that way i've got that forever and then i do the xorg install which takes a long time and if i get xorg up and running i get a graphical server then i take a snapshot of gen2 at that point that way i've got a couple of snapshots that i can always go back to if i need to now let me show you how to get shared folders working a shared folder is a folder on your physical machine your host machine that is available inside your virtual machine that way you can edit the same files you know on both the host machine and the guest machine it's actually a really nice feature so once again let me switch over to my desktop here so obviously this is my host machine you see vert manager running let me go ahead and open a terminal here on my host machine and the first thing you need to do on your host machine is make a directory that you know is going to be shared it can be named anything i'm going to make a directory and i'm going to call it share that's just typically what i always call this directory the next thing i want to do is i want a chmod 777 share so we've set the permissions for read write execute anybody can do anything in this directory and this is very important we want any user to be able to do anything in that directory because the user names could be different between the host machine and the virtual machine so if i did a ls right now in my home directory i should see somewhere in here a folder called share now if i cd into share and do an ls there is nothing in it so let me clear the screen here what i'm going to do inside our new share directory is i'm going to just create a new file i'll call it test.txt and i'm just going to insert some text this is a test exclamation let me go ahead and write and quit out of that so now that we have this share folder and we have a test file in it let me close the terminal i won't need that anymore on the host machine now the virtual machine so i think i'm going to do this manjaro kde clone that we just cloned so this is a fresh clone vm and then i'm going to go into the hardware details so this second box here and let me make this full screen here and then i'm going to go down at the bottom add hardware let's add and we want to add a file system so click on file system and type as mount mode is mapped leave that you definitely want mode to be mapped because that gives you right access to the guest so and then you have source path which is the folder on your host machine and the target path which is the folder or the mount point actually in the vm so the source path is easy just click browse browse local and then just find that directory you created if you called your directory share look for share and just click on it click open and you see slash home slash dt slash share that is the source path and then the target path you can name this anything this is going to be a mount point what i'm going to do is i'm going to do slash share point so inside the vm i'm going to create a mount point at some point and it's going to be sharepoint and then click finish and then click play to start the vm let me switch over to the virtual machine view i'll make it full screen here all right and manjaro has started up now inside manjaro kde i'm going to ctrl alt t to bring up a terminal and let me zoom way in so you guys can see what i'm going to do here so what i'm going to do here is i i need to make a directory on this machine as well so i'm going to mkdir make deer and it needs to be share by doing ls you see our new share directory right there and then the next command we're going to enter is a long and convoluted command it's one of those things you probably want to jot it down in some notes for me i have it saved in some vert manager notes that i have saved in an org mode document because i use this command all the time but it's too long i never remember the exact flags or the order of things but it is sudo space mount and you could do this either as the root user or as your home user using sudo privileges i'm going to use sudo space mount space dash t for type space n p so this is i think the file system type is just letting it know that this is a virtualized file system i believe i think 9p actually has something to do with plan 9. i could actually look in the man page of mount and probably find that information out but it's not really important just know that anytime you're doing the shared folders inside vert manager it's mount space dash t space nine p and then space dash o and then after the dash o flag we're gonna do trans equals vert io no spaces in between the equals so trans equals vert i o space and then the mount point remember it was slash sharepoint that is what we put as the target source in the settings of the vm right remember that and then space and then the name of the folder we created remember that is share and if everything works correctly yeah no errors were returned if i did a ls here in the home directory there is the share directory that we made earlier by cd into share and do a ls how about that there is test.txt remember we just made this directory it should have been empty but when we mounted it it is actually connecting that shared directory to the share directory on my host machine and there is the file we created earlier remember the first line of it is this is a test exclamation there it is this is a test exclamation if i wanted to add something this is a new line exclamation and i could write and quit if i wanted to let me get to a new workspace here and this is my host machine i'm going to cd into the share directory on my host machine and once again vm well if i can type test.txt we do not have privileges though if i did an ls you see the owner of this file is nobody so i either have to open this as root because root has root permissions or i would have to change the owner of this file to the dt user i would just do a sudo vm test.txt and you see now i can actually read the file i could edit the file and any edits that i make would take effect on the virtual machine as well so that is one way to do shared folders now another way to do shared folders is instead of having to always mount every time you open this virtual machine wouldn't it be great if it just auto mounted every time you launch the virtual machine and of course to have a drive auto mount and that's essentially what the shared folder is is like an auto mounting drive of course you need to edit the fstab the file system table so what i'm going to do is i'm going to sudo vim xc fstab and what we're going to do is we're going to create a entry for this shared folder and it needs to read like this it's going to be slash sharepoint and then tab over and then it's going to be the path to the directory uh in my case i think it's going to be slash home slash dt slash share and then tab over and that should be the type remember the type is 9p and then tab one more time and then add the trends equals vert io comma version equals 9p 2000 dot capital l comma rw and yes i had that saved in my notes too that was a rather lengthy thing to type to and then tab over zero tab over zero and then write and quit that and if this works let's see if this actually works what i'm gonna do is i'll force the vm to shut down just to make the shutdown a little quicker and then i will restart the vm and the machine has rebooted i don't think the mounting worked let me get into the home directory that's there is share if i click on it yeah we're still mounted because there is test.txt if i created something here so let me create a new text file and i'll call this dot test2.ta and let's go back to the host machine and actually see if that took effect so let me switch to a new workspace cd into share ls yeah test.txt and test2.txt so it did work i was a little concerned that it didn't work because when i rebooted the machine it actually did complain a little bit that it could not mount slash home slash dt share but i don't know why the error message came up up on boot because it clearly was able to mount it because otherwise we wouldn't have the ability to share these files so that is a couple of different ways that you can set up your shared folders and of course that'll allow you to share files between the host machine and the guest machine of course you can also share files between the host and the guest using the usb method i showed you earlier because now you have the ability to plug in your usb sticks or your usb external hard drives and things like that to move files and folders around if you need it and the last tip i want to leave you guys with is i'm going to show you the command to convert your virtual box virtual machines over to vert manager virtual machines so let me switch back over to my desktop of course this is vert manager let me go ahead and launch virtualbox because i'm not sure what machines i have inside virtualbox i don't use it that often and i have this ubuntu virtual machine here inside virtualbox so what i'm going to do is i'm going to convert that ubuntu virtual machine over to vert manager so let me open a terminal let me make the terminal full screen and i'm going to zoom way in i've got to run a long kind of convoluted command once again but it's one of those things again just write it down save it in your notes that way you have this command if and when you need it so as root or with sudo privileges i'm going to use sudo because i have sudo privileges on this machine i'm going to do sudo space qemu-img so qemu image right and space convert space dash f space vdi so we're going to convert a vdi image which is the virtualbox disk image and what are we going to convert it to dash capital o space we're going to convert it to the q cal 2 format that is the format for the disk images that vert manager uses and then we need to give it the name of the virtual virtualbox disk image and i believe the vm was called luboon2 with a capital l dot vdi if there would have been numbers and spaces in there it would have been one thing i could actually verify that that is the correct path i'm going to open a second terminal and a cd into virtual box vms in my home directory i do a ls you can see that is where the vms actually live by cd into the ubuntu folder and do an ls there is the disk image ubuntu dot vdi so that was the correct name so i guessed right but you should probably verify that before trying the command and then what we need to do is give it the path to the disk image when it's converted over to a vert manager image now verb manager saves everything as slash var slash lib slash libvert slash images slash and then if i tab complete you can see the names are uh usually the virtual machine name that i gave it dot qcal2 so in this case i'm going to call this new vm luboon 2 dot qcal 2. if i hit enter it's going to ask for a root password and i got an error because it says it could not open lubuntu.vdi what it is is we need to actually cd into virtualbox vms and probably even cd into laboontube because that is where the ubuntu.vdi file is and then what i'm going to do is i'm going to up arrow and rerun this command and now it's going to work it's going to take a few minutes you know it's because it's converting basically a hard drive a hard disk image even though it's a virtual disk image to another on my threadripper actually it didn't take that long but on weaker machines it could actually take quite some time and of course the conversion time is going to depend on how big the vms are as well that lubuntu vm wasn't very big so now let me get out of the full screen here i'm going to close that terminal and now that we've got that luboon 2 disk image what i would need to do is i would need to go up in here and do new virtual machine from iso or cd-rom actually nope what we need to do is import existing disk image and then forward and then browse for that disk image i'm going to browse local and you remember where we need to browse i'm going to go into the root file system and we need to browse slash var slash lib slash libvert slash images and then look for the new luboon2 qcal image and choose the operating system this is an ubuntu based operating system i think it's one of the older ones probably the ubuntu lts click forward give it the cpu and the ram and i will call this luboon 2 i'm not sure what version it is i'll just call it luboon2 and then finish and then if our conversion from the virtual box disk image over to the qcal format actually worked we should actually yeah this is lubuntu so that converting that only took just a few minutes and actually i wasted several seconds by not typing the full path to that disk image so really really easy to convert virtualbox over to vert manager so that's just a few tips and tricks with vert manager again i use it all the time because i create so many virtual machines and i know a lot of you guys are probably using it many of you guys probably have already discovered some of what i talked about today but hopefully a few of you guys gleaned some extra knowledge maybe you didn't have before watching this video now before i go i want to thank a few special people i want to thank the producers of this episode devin gabe james matt michael mitchell paul scott wes i also want to thank akami allen linux ninja chuck commander angry curt dioco david dilling gregory hi co cosco lee max and mike nitric surya alexander p sergeant fedor polite raver red prophet stephen and willie these guys they're my highest tiered patrons over on patreon without these guys this episode you just watched would not have been possible the show's also brought to you by each and every one of these ladies and gentlemen as well all these names you're seeing on the screen these are all my supporters over on patreon because i don't have any corporate sponsors i'm just sponsored by you guys the community so if you like my work and want to support me well i should probably do the ending scenes in the correct order if you like my work and want to support my work please subscribe to distro tube over on patreon this time i will actually switch to the ending scene at the right time alright peace you're slipping dt you're slipping
Info
Channel: DistroTube
Views: 61,176
Rating: undefined out of 5
Keywords: virtual machine, virtual machine manager, virtual machines, kernel-based virtual machine, virt manager, gnu linux, virtual machine tutorial, kvm qemu, convert virtualbox, oracle virtualbox, gnome boxes, linux virtual machines, test linux distros, setup virtual machine, windows vs linux, linux, virt manager tutorial, virt manager linux, virtual machines on linux, testing linux, try linux, switch to linux, distrotube
Id: 9FBhcOnCxM8
Channel Id: undefined
Length: 22min 28sec (1348 seconds)
Published: Fri Dec 03 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.