Our articles usually show you how to do things on a Raspberry Pi. This time, we’re changing things up: we’re going to show you how to use a PC or Mac to run the Raspberry Pi Foundation’s desktop operating system, Debian with Raspberry Pi Desktop (for brevity’s sake, we’ll call it just “Raspberry Pi Desktop” from now on). This Raspbian-like OS (as the names imply, both operating systems are based on Debian) allows you to use your PC or Mac as a kind of substitute for your Raspberry Pi. That makes it useful for testing out projects when your Pi isn’t handy. It’s also fun because it backs the familiar Raspbian interface with your PC or Mac’s hardware, which is much more powerful than the little Pi.
The simplest way to get Raspberry Pi Desktop up and running is to install the operating system, but that will require you to dedicate a computer to the project (or at least to partition a hard drive). If you want to keep running Windows or macOS on your computer, your best bet is to run Raspberry Pi Desktop on a virtual machine – which is exactly what we’ll show you how to do in this guide.
How to run Raspberry Pi Desktop on Windows or macOS
Step 1: Download and install VirtualBox
Because we’re going to run Raspberry Pi Desktop on a virtual machine, we’ll need to download Oracle VM VirtualBox. In Oracle’s own words, “VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise as well as home use.”
You can download the software from VirtualBox’s Downloads page. Just choose the right version for your operation system (there are two: a Windows version and a macOS version). After you’ve downloaded the executable, install VirtualBox by following the installation wizard’s instructions.
Step 2: Download Debian with Raspberry Pi Desktop
Next, you’ll need to download the image file of Raspberry Pi Desktop from the Raspberry Pi Foundation’s site.
Step 3: Launch VirtualBox and create a new virtual machine
Now that we’ve both VirtualBox and Raspberry Pi Desktop downloaded, we’re ready to launch VirtualBox and create a new virtual machine.
Click “New,” and you should see a screen like this:
We don’t want to create a Windows virtual machine, of course, so let’s change the settings a bit. First, choose a descriptive name for your virtual machine (for example, “Raspberry Pi”), then select Linux from the Type dropdown menu and Debian (64-bit) from the Version dropdown menu. After that, click Next.
On the next screen, you can use the recommended memory size of 1024 MB – this corresponds to the Raspberry Pi 3’s memory size.
The next screen is about adding a hard disk to your new virtual machine. Just click Create, unless you have some reason to modify the settings. Then, click Next on this screen and again on the next.
Finally, you can choose the size of your hard disk. We used the recommended size of 8 GB, but you may want to have a larger hard disk. When you’re ready, click Create.
Now we have the settings of our virtual machine in place.
Step 4: Install Raspberry Pi Desktop
Click Start to start the installation of Raspberry Pi Desktop. You should see a screen like this:
Browse to the folder where you saved the image file of Raspberry Pi Desktop, select the file, and click Start. What you should see next is a menu titled “Debian GNU/Linux installer boot menu.” Use the arrow keys – or i – and Enter to select Install.
On the next screen, select your preferred keyboard layout and continue by pressing Enter.
Choose Guided – use the entire disk and keep pressing Enter to Select disk to partition and choose the Partitioning scheme. Finally, Finish partitioning and write changes to disk.
You might want to grab a cup of coffee or tea while the system is installing.
After a while, the installation wizard prompt you: “Install the GRYB boot loader to the master boot record?” Select Yes, and choose /dev/sda.
When the installation wizard has installed everything, you should see a screen like this:
Look familiar? If you’ve used Raspbian before, it should!
Step 5: Make the virtual machine interactive
Our virtual machine is successfully running Raspberry Desktop now, but the screen size is a bit small, and it doesn’t get bigger when you click Maximize. We can make our machine more interactive by installing VirtualBox Guest Additions. Guest Additions makes it possible for us to resize the screen, use the clipboard, and share files between our PC or Mac and the virtual machine.
To do this, first open Terminal and make sure that your system is up to date:
sudo apt-get update sudo apt-get upgrade
You’ll have to type the commands because our virtual machine isn’t very cooperative, yet.
Now we’re ready to install VirtualBox Guest Additions:
sudo apt-get install linux-headers-$(uname -r) virtualbox-guest-dkms virtualbox-guest-x11
With Guest Extensions installed, click on the Devices menu and select Shared Clipboard > Bidirectional.
If you rebooted your virtual machine now, you would be able to use the same clipboard on both your PC or Mac and the virtual machine. You would also be able to resize the screen. But let’s not reboot, yet. Instead, let’s first to add our user to the vboxsf group to enable file sharing between the virtual machine and PC or Mac:
sudo adduser pi vboxsf
Now we’re ready to shut down our virtual machine and set up a shared folder. This the shutdown command:
shutdown -h now
Step 6: Set up a shared folder
To set up a shared folder, right-click on your virtual machines name and select Settings…, or press Ctrl+S with your virtual machine selected.
From the menu that opens, select Shared Folders.
Click the button with the green plus sign that adds a new shared folder.
From the Folder Path dropdown many, select Other… and then the folder you’d like to share. When you’re ready, click OK and check Auto-mount.
If you start your virtual machine again and launch the file manager, you should see your shared folder with the prefix “sf_” in the /media directory. Any file you put in that folder will also show up in the corresponding folder in/on your PC or Mac, and vice versa.
And that’s it! You now have Raspberry Pi Desktop running on a virtual machine on your PC or Mac, and you can easily use the clipboard and manage folders while you’re working on your next project.
Sorry – relative beginner here.
Can I run it from a 32 GB USB3 memory stick?
My MacBook’s HDD is rather full and I keep getting ‘HDD space is low’ messages.
You can run it from a USB stick. When you are asked to create a virtual hard drive, just change the location.
(Also, he didn’t mention it, but there are significant performance benefits to using a fixed-size hard drive rather than a dynamically allocated one. When asked to create a virtual hard drive, just select ‘Fixed’. It will take longer to create but be quicker to use.)
How can I change the screen resolution of Raspian in the virtual machine? I have tried many things but I did not succeed. Although I can maximize the screen, the resolution is very small. When I use Raspberry Pi the resolution is much better.
Outstanding. Thanks for the hard work to create one simple VB process that works perfectly.
VB
I have installed The Pi with the VirtualBox on my iMac (macOS High Sierra). The PI is working great with one exception. I don’t get clear with Step 6: Set up a shared folder. When I do exactly as written no shared folder with prefix “sf_” is showing up. Do I missing something?
Running a RPi VM, then I change RPi System Configuration (e.g. keyboard, locale…) and I also “apt-get update/upgrade”. At restart all preferences and settings are lost: it appeared that the changes are not stored between restarts. I tried to find appropriate options but without success.
Any clue?
I’m trying to install virtualbox guest additions, but after I entered the first line and press enter, it always says
“e: unable to locate package virtualbox-guest-dkms”
What should I do? Thanks!
Me too. Can someone help?
If you have problems installing the guest-additions:
“In Raspbian Stretch (late 2017 onwards), the VirtualBox Guest Extensions are no longer in the standard Raspbian repositories. You need to enable the Debian Backports repsitory. To do this, you will also need to install the Debian authentication keys. Type in the following. Press Enter at the end of each line.
sudo apt update
sudo apt install -y dirmngr
sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-key 8B48AD6246925553
sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-key 7638D0442B90D010
echo “deb http://ftp.debian.org/debian stretch-backports main contrib non-free” \
| sudo tee /etc/apt/sources.list.d/backports.list
sudo chmod 644 /etc/apt/sources.list.d/backports.list
from: http://www.aoakley.com/articles/2017-07-04-raspbian-x86-virtualbox.php
Step 5: Make the virtual machine interactive
When running into troubles with adding VB Guest Extensions, you should:
1. Follow the instructions as listed by Christoff on January 13 , 2018;
2. AGAIN go through the instructions as listed in Step 5.
For Debian 9, you have to the backport to the /etc/apt/sources.list. See https://unix.stackexchange.com/questions/286934/how-to-install-virtualbox-guest-additions-in-a-debian-virtual-machine
This works for me until the following:
sudo apt-get install linux-headers-$(uname -r) virtualbox-guest-dkms virtualbox-guest-x11
Like the previous commenter, I get an error message for this. It’s annoying as you cannot resize the screen – it’s tiny.
As per previous comment by MJ – “e:unable to locate package virtualbox-guest-dkms” everything up to there went perfectly…
I’ve had a similar experience to Jan Kromhout with regard to Step 6: Set up a shared folder. When I do exactly as written, no shared folder with prefix “sf_” is showing up in the file manager /media directory or anywhere else. Does anyone know a fix? Thanks!
Thank you, this really brought me further.
One issue: When I enter the command:
“sudo apt-get install linux-headers-$(uname -r) virtualbox-guest-dkms virtualbox-guest-x11”
the system responds with
“Reading package list … Done
Building dependency tree
Reading state information … Done
Package virtualbox-guest-x11 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only available for another source.
E: Unable to locate package virtualbox-guest-dkms
E: Package ‘virtualbox-guest-x11’has no installation candidate.”
Please, advice.
Best solution after installing guest extensions CD on the host side:
https://www.neontribe.co.uk/debian-virtualbox-guest-additions/
Hi all,
The only thing that worked for me to install the Guest Additions:
Please note that I am working on a French MacBook, so my translation may not be accurate.
I have selected the menu “Périphériques” which translate “Peripherals” or “Devices” in the menu bar of VirtualBox itself, not the menubar of the Raspberry VM.
The last menu action is “Insérer l’image CD des Additions Invité …” which may translate to “Insert Guest Additions CD-ROM Image”.
This inserts a CDROM disk inside the Raspberry VM, that you may visualize on the Raspberry Desktop if you check the “Visualize Mounted Disks in the “Appearance Settings of your Raspberry VM”.
Then I opened this CD-ROM in a Terminal (right click on the CD-ROM icon and choose “Open in a Terminal”). There are other ways, but this one is faster.
Next, I made myself as root by typing ‘sudo su’ in the terminal.
It is the only way to execute the Guest Additions installation script. A simple sudo did not work.
Then I typed ‘ sh VBoxLinuAdditions.run’ and the installation took place.
I have then be able to resize the Raspberry VM and, which was vital for me, validate the French Macintosh keyboard.
Hope this will help others.
Regards.
C. Brunel
Step 4: Install Raspberry Pi Desktop
IMHO it would be helpful to include an extra picture in Step 4 showing the Debian GNU/Linux Boot Menu and stressing the user should select **Install** (instead of “Run with persistence”).