Play with Linux without changing your main OS: How to set up a VM

In this post, I’ll give you what will hopefully be a shortcut around all the nonsense I went through trying to make a Linux (specifically: Lubuntu) VM to play with. Not everything you do to make these things run well is terribly obvious, so I’m covering it for you.

I’m not going to assume you know everything, so I’m going to cover a lot of really basic info in this article. If you’re well-grounded in the basics, the tl;drs are in red.

VOCABULARY

OS: Operating System. Windows is one; Mac OS X is one; Linux is one.

RAM: aka “memory,” this isn’t the same thing as storage. RAM is like your computer’s short-term memory. Upgrading RAM often speeds up computers because it’s a common system bottleneck; that is, the system can only go as fast as its slowest component, and that’s often RAM. That’s not to say that every system will speed up if you upgrade RAM, because there are other components which could slow down a system (e.g., a fragmented hard drive, a really inefficient piece of programming). In addition, not every system needs a lot of RAM to run what it needs to run.

VM: A virtual machine is just a program that thinks it’s a real computer. It runs an operating system and has its own files. Anything you save to a VM stays there even if you shut the VM off (unlike a live USB). There are tons of uses for VMs. For instance, apart from the Linux VMs I made for fun and to mess around with, I also have a VM running Windows 7; this lets me run Windows-specific programs for school without actually having to use it as my main OS.

For more about what a VM is and why you’d want one, HowToGeek has an awfully nice look at the subject. Link opens in new tab.

64-bit; 32-bit; x86: You use 32-bit OSes on systems with = 4GB of RAM. Operating systems marked x86 are 32-bit.

Host OS: your “normal” OS, as opposed to the one that’s on the VM.

Guest OS: the OS that’s on the VM.

——————————————————————

YOU WILL NEED:

– A computer that’s pretty decent on the hardware front. If you don’t have at least 4GB of RAM and two cores, you’ll probably want to look into permanent live USBs instead. Because running a VM means that your hardware is working double-time to keep up two different OSes, plus any programs you’re running on them, things can get pretty demanding in that direction. Live USBs are less demanding because your computer doesn’t have to run your “normal” operating system alongside the new one.

– To install VirtualBox. (opens in new tab) That’s the official site; as always, it’s preferable to get your download straight from the developers’ own site so it doesn’t come with C|Net-bundled crapware or anything like that.

A Linux .iso in your favorite flavor. I used Lubuntu, which is just Ubuntu (pronounced “oo-BOON-tu”; it’s an African word) with a less fancy interface that’s easier on the VM’s limited hardware. You may want to do a little research into the different distributions and interfaces–Lubuntu’s not a bad starter, but there’s also Debian, Mint, and a whole host of others.

You’ll want the 32-bit (x86) version of your chosen distro. Linux can do a lot with a minimal amount of RAM, so don’t worry about it for now, even if you have a powerful computer that can give the VM >4GB of RAM. If, later, you decide your Linux VM really needs the extra power, you’ll know enough by then to whip up a 64-bit VM easily.

It helps the Linux developers if you use a torrent program (e.g., uTorrent) to download the .iso file that contains your chosen distro, rather than downloading straight from their site (which costs a lot of bandwidth, as the files are of course quite large). If you can’t, there are still ordinary downloads available.

If you’re at sea with all these options, just go ahead and grab the 32-bit version of Lubuntu from here. (opens in new tab)

——————————————————————

INSTALLING LINUX ON YOUR VM

1. That .iso you downloaded? Stick it somewhere you won’t lose it. I suggest putting it in your home folder. If you like, you can rename it too, but that’s usually unnecessary. You’ll want to keep the distro name and the version number (which will be something like 14.04) in the name. Don’t use spaces, but underscores and hyphens (_ or -, respectively) are okay.

2. Open up VirtualBox. Click through whatever tutorial junk it throws at you–you can read it if you want, but since this guide will take you through the steps anyway, it’s not necessary. Then go ahead and click the blue round/spiky-shaped button that says New, in order to create a new VM.

3. You need to choose a name for your VM. It doesn’t matter terribly what you name it. I name mine after awesome programmers–so far I have Adalace, Matsumoto, and Eric (points if you know who I’m referring to). Under Type, choose Linux. Under Version, you’ll need to tell it what flavor you picked out. If you’ve been following along with the Lubuntu .iso I recommended earlier, choose 32-bit Ubuntu. Remember, Lubuntu is just Ubuntu with a different user interface–the programming behind it is essentially the same. But it DOES matter that you choose the right bit version. It won’t work if you get that wrong–although if you find you accidentally checked the wrong bit version, you can change this in Settings later.

Other important note: Some Linux systems need you to mark the VM as 64-bit, or they won’t install–even if your .iso is 32-bit. Debian “Wheezy” is this way, and so are some others I’ve tried.

4. Now it wants to know how much RAM you’re going to feed the VM. This RAM gets allocated to the VM when you start it up, but it doesn’t “keep” the RAM when the VM shuts down. If you have a computer with 4GB of RAM and you decide to give your VM 1.5GB, then while the VM is running, your host computer will be running on 2.5GB of RAM and the VM will have 1.5. Then when you shut the VM off, your host will run on all 4GB again. I suggest feeding it at least 1.5GB, although you can give it more if you have more to spare. Remember: your host OS needs at least 2GB of RAM for itself.

Ah, but the slider doesn’t measure RAM in GB, does it? It’s using MB as a unit. 1024 MB = 1 GB, if you’re not familiar. It’s automatically set to 512MB, or half a gig, when you get to the screen. Probably your VM could run on that okay, as Lubuntu is pretty lightweight (this is where the different interface matters), but it’d be pretty slow. So just throw in ~1500MB RAM. Precision doesn’t terribly matter here, you don’t need to get it to 1532 MB exactly (though you can just type it in if you want).

5. Leave the radio button setting on “Create a virtual hard drive now.” Click Create.

6. Leave the radio button setting on VDI (if you knew you needed to use any of the other settings, you’d already be doing something more advanced than what this guide describes, and you wouldn’t be reading this). Click Continue.

7. Most of you will want to go with the dynamically allocated option here. VirtualBox explains the difference between them pretty well in the selection window, so I won’t rehash it. Choose, and click Continue.

8. Here’s where you set how much storage space the VM will have. If you picked dynamically allocated, you’re just setting a cap for how much room on your hard disk the VM can take up, and you can change this value later. You’ll want to think about it a bit more if you chose to make your VM a fixed size. Give yourself at least 8 GB, more if you want, and click Create again.

9. If you chose fixed size, you’ll have to wait for your computer to trundle on with its various creation processes, etc etc. If you chose dynamically allocated, you’ll almost immediately have a drive you can open up. First, though, we want to change a few settings on it. Click your VM once, and then click the Settings button.

10. Important step. There are different tabs available to you; first, go to System. You’re going to change the boot order. Basically no computers have a floppy drive any more, so uncheck that and click the down arrow three times to move it to the bottom of the list.

Leave the CD drive and the hard drive checked. Even if you don’t think you’ll use CDs on your VM, it’s important to leave it checked because (as far as I can tell) the VM thinks it’s booting from a CD in order to install the OS. Under Display, go ahead and let it use 3D acceleration. You may also want to give it more video memory; again, VirtualBox’s default settings are kind of bare-bones, so give it about 36MB instead of the default 12. If you feel the need to adjust this later, you can. The rest of the settings can be left alone until you have your own reasons to change them. Save your changes, close the Settings menu.

11. Now start up your VM with a double click or by using the green Start button. It’ll pop up with a window asking for a “virtual optical disk file.” That just means the .iso you downloaded earlier and oh-so-carefully put where you won’t lose it. Now you need to find it. Click the folder icon, navigate to it, and pull up your .iso.

12. Hit Enter to select English from the languages menu that pops up (if you’re reading this, you probably speak English), or pick your favorite language (one you understand, please) and hit Enter.

* It’s worth noting that if you click the mouse inside your VM window, it’ll pop up with a warning letting you know the VM will “capture” your mouse cursor, and telling you what key to press in order to un-capture it. It’s not a big deal, just take note of which key it says. For me, on Mac, it’s the command key. It may be the Ctrl or Windows key on Windows; I’m not sure. Pressing whatever key it is for you just tells the VM to let the host system use the cursor, instead of keeping it to itself like a greedy little bugger. Later on, your system may not need to bother you about this, and it may handle the cursor automatically. Usually it takes a minute for this feature to start up, though, so you may see the message from time to time. It’s nothing to worry about.

13. Navigate with the arrow keys and opt to install Lubuntu on your VM. Hit Enter again. It will most likely complain about your BIOS. This is because it doesn’t have a real BIOS, and its complaint does not actually matter. It’ll run anyway, just let it do its thing for a minute. You’re going to fool it into thinking it has a BIOS later.

14. Hopefully you’ll be rewarded with a lovely blue-and-purple background while the installer loads (or whatever color your chosen flavor has). Be patient; it’ll pop up. Pick English (or whatever language) again and hit Continue, unless you actually want to read the linked release notes.

15. It’ll tell you about some basic system requirements and ask that your computer should be plugged in and connected to the Internet. Your system requirements were covered when we allocated those resources to the VM when we made it, so don’t worry about that. Let it install the updates and software it wants to install; that way you don’t have to do it later. It won’t install junk. (Ha!) Click Continue.

16. It will think for a few minutes, trying to figure out if you’ve got any OSes on the disk already. Of course you don’t, as it’s a freshly minted VM. So let it wipe the nonexistent files off the drive and install Lubuntu. This won’t hurt your host (read: normal) operating system, or touch any of its files except for the VM’s personal file. Click Install Now.

17. It’ll ask for your timezone. Click your area on the map, or enter a major city in your timezone (e.g., Chicago, New York, Moscow) and hit Continue.

18. It’ll ask for your keyboard layout. If you’re using an ordinary keyboard such as might be found on a Windows laptop, keep the default settings. If you’re using a Mac, pick Macintosh. If you’re using a Dvorak keyboard, you know bloody well what setting you need. If you’re Russian, you’re gonna have to figure this one out on your own. It does have an option to detect your keyboard layout for you, but that doesn’t always work. Pick your keyboard layout and hit Continue.

19. Type in your name, re-enter your VM’s name, pick yourself a username and password, and pick whether you want to be prompted for said password. Basic stuff. Do the obvious and move on. Remember your password, even if you chose not to have the machine prompt you.

20. It’ll start really installing now. Let it run. You can leave it alone for a bit now.

21. When it declares that it’s finished installing and asks you to reboot the VM, just click the conveniently-located Restart Now button.

22. If it asks you to press Enter when it starts up, press Enter. It’ll complain about the BIOS again, and then it’ll start up for real.

23. It’s in a tiny window, though, even if you pick Fullscreen under the View options. That’s because we haven’t installed the guest additions packages yet. They’re basically a bunch of drivers and stuff that adjust Lubuntu (or whatever you’re using) to the “hardware” of the virtual machine (like the “BIOS”). If it’s not automatically handling switching your mouse and keyboard back and forth between the VM and your host machine, it may start once you install guest additions. So we’ll install those, we’ll reboot, and then hopefully it’ll show up in actual fullscreen when you fullscreen it.

The command to go in and out of fullscreen in VBox is the host key + F. For me, that means Command + F. If you don’t know what your host key is yet, Google it; it depends on your host operating system.

Lubuntu has a pretty bare interface. The taskbar is at the bottom, and probably there’s a software updater prompting you to update stuff. Guest additions first, though; we’ll update with the command line soon. So tell it to come back later. There are two ways to install guest additions. I will cover installing via the terminal; if you want to look into doing it via the GUI*, that’s your prerogative.

(*Graphical User Interface, pronounced “gooey.” A sillier name could not have been created, even by the likes of INTERCAL.)

—–INSTALLING GUEST ADDITIONS—–

This part is kind of distro-specific. In other words, if you’re using something other than Ubuntu or its alt-interface cousins Lubuntu, Xubuntu, or Kubuntu, you’re going to need to access the instructions specific to your Linux flavor here, at VirtualBox’s page on the matter.

Hit ctrl+alt+t to open the terminal. You can also access the terminal by clicking on the lower left-hand corner icon, mousing up to Accessories, and picking LXTerminal from the drop-down list. Keyboard shortcut’s faster, though.

Here are the commands you most likely need to enter. Note that they’re case-sensitive and need to be typed in exactly.

sudo apt-get update

sudo apt-get upgrade

[a little info on this pair can be found here]

sudo apt-get install dkms build-essential

[then reboot, open the terminal again, and run…]

sudo apt-get install virtualbox-guest-additions-iso virtualbox-guest-dkms

That should cover all your bases, and install anything that needs to be installed. Reboot again, try fullscreen mode and see if it works. It should.

—–TERMINAL INSTRUCTIONS FOR THOSE WHO ARE NEW TO THINGS—–

If you’re VASTLY new, you may want to have a look at this command-line tutorial made by Zed A. Shaw.

Some general information. People get intimidated by the terminal, so knowing more about it helps.

Any command you run with the sudo (“super-user do”) prefix will prompt you for your password. This is because you CAN do damaging things to your system while using this prefix (in this case, it’s not a system with anything important on it). If someone on the Internet tells you to run a command prefixed with sudo and you don’t know what it does, find out what it does first. There are people who will use these commands to help you, but there are also some people who’d like to play a nasty prank on you. So find out what the thing does from Google, or just run the command under a designated guinea-pig virtual machine, so it can’t damage any files.

You don’t need to worry *too* much about what you do to your VM (unless you put important files on it later), but if you switch to Linux as your main OS, you need to be more careful. VMs are sandboxed away from your host system and your files there, so you won’t hurt anything by screwing up a brand-new VM; if all else fails, you can delete the VM and start over. This is why VMs are a great playground for messing around with Linux–or, really, any unfamiliar piece of software.

It’s worth noting that when you type in a password, it won’t show up, even as character dots; this is a security thing. If you mistype while you’re typing the password, you can use Backspace as always. If you accidentally execute a command with a typo in it and you get that “I don’t know what the heck you’re talking about” message from the computer, you can hit the up arrow key once and it’ll pop back up, and you can correct your typo.

In addition, if you wait too long or reboot between commands, your sudo privileges will time out and you’ll have to prefix your next command with sudo again.

For both of these commands, the system will analyze how much space the suggested operation will take up on your hard disk, and it’ll ask you if you want to continue. Hit y and press enter so it can move on.

Another Linux thing: if it says [Y/n], then just pressing enter will do the same thing as pressing y and hitting enter, because the capitalized option is the default option. Conversely, if it says [y/N], hitting enter is the same as telling it no.

You can tell when your last command has finished running because the terminal will display a prompt that looks kind of like this: 

username@computername: ~$

Typing “exit” closes the terminal, and pressing ctrl+c makes it stop whatever thing it’s doing.

———————–

That should do it! You now have a working Linux VM.

If you don’t, well, Google is your friend, no? The Linux community is a broad one and someone has probably already asked your question on a forum somewhere. And if you still can’t find help, make an account on one of those forums and ask the question yourself! Be nice to the people there; they are helping you out of the goodness of their heart and are not being paid, so thank them!

Happy hacking!

Advertisements

4 thoughts on “Play with Linux without changing your main OS: How to set up a VM

  1. Thanks for this post and for your awesome blog in general. Big fan since being referred here by you know who 😉
    I had some issues with guest additions following (?) your method. I ended up going to here:

    https://www.virtualbox.org/manual/ch04.html#idp46856128490560

    and then here:

    https://www.virtualbox.org/manual/ch04.html#mountingadditionsiso

    and following those instructions got me there perfectly (after some wasted google around time).

    Just need to think up some fun stuff to do with my linux installation now. Keep up the writing.

    Liked by 1 person

  2. Hi Rebekah! Thank you so much for writing this thorough guide. I successfully installed Lubuntu on my system. You may want to update the information however; the latest Lubuntu update was July 21, 2016.

    A couple things of importance: when installing to my VirtualBox on Windows 7, I initially saw a strange colored and pixilated screen after the language selection. I researched on AskUbuntu (http://askubuntu.com/questions/541006/ubuntu-14-10-does-not-install-in-virtualbox) for a solution. I don’t know if this a bug or not. I also followed your instructions to install the Guest Additions. It did not resize my screen until I figured out how to change the display in Lubuntu to match that on my laptop monitor (1920×1080).

    Altogether, it is running smoothly. I can’t wait to customize my new OS and learn how to script with the terminal. Thanks again!

    Like

    • VirtualBox sometimes does some funny stuff. You’re running the Windows version and I’m running the Mac version, so if there’s a bug on Windows VB with Lubuntu I wouldn’t have seen it. But since you asked the question on SO and evidently found an answer that got things working again, it’s been documented and you’ve helped the community. 🙂

      Once I get the chance, I’ll add those warnings to the guide. Thanks for letting me know!

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s