Setting up a Debian 11 virtual machine using VMware Player
Tags: debian, vm, vmware
Published: 2022-06-19 10:11:47

Well, this is my first post. So don't hesitate to make some remarks on its content !

Let's try to install the famous Linux distribution Debian 11 on a virtual machine, hosted on a Windows x86 64 bit platform.
To do that, I will use VMware Workstation Player as virtualization tool (free for personal use).

## A bit of context

Why using a virtual machine ? First, this Debian machine is intended to be used to develop Nintendo 64 homebrews using the old official SDK. 

However, I've read that it will be sometimes necessary to use Windows only compatible tools to develop these N64 programs. I think that a dual boot machine will make things harder when switching between the two operating systems.

Why not using Wine directly on linux ?
-> I tried some years ago, and it was a pain to get it functional ... I hope it is better now.

To conclude, my OS dev environment will be :
- A Windows 10 host machine.
- A Debian 11 guest machine.
- A share folder to work with common data.

## Installing VM Player

<u>Remark</u> : if you're using an Intel CPU, you'll need to enable virtualization in the BIOS (option named Intel VT-x).

Go to this URL to download the tool : [here](https://customerconnect.vmware.com/en/downloads/info/slug/desktop_end_user_computing/vmware_workstation_player/16_0).
The major release version right now is 16.

After the installation process succeed, you can start the tool to get the main menu :
![VM Player main menu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qx0h4oyzk4ikxv64y9do.png)

## Select a Debian installation image

Go to Debian download page [here](https://www.debian.org/distrib/index.en.html) to select the adapted image file to download.
For me, I chose a _64-bit PC netinst_ iso file as the platform I'm currently working on is intel x86_64 CPU based.

A _network install_ image means that the installation process will need an internet access. Moreover, the repository of Debian packets (.deb files) will be configured to be used through the Internet (nothing local here).

## Configuring the virtual machine

Once the Debian iso file is downloaded, you can create a virtual machine on VM Player from the main menu :
1. Clic on _Create a New Virtual Machine_.
2. Select _Installer disc image file (iso)_ radio button.
3. Browse the Debian iso file you've downloaded.
4. Clic on _Next_.
5. If not automatically detected, select the operating system of the virtual machine. In our case, choose _Linux_ for the OS, and _Debian 10.x 64 bit_ for the version (11.x not available yet).
6. Clic on _Next_.
7. Choose a name and a location for your VM data.
8. Clic on _Next_.
9. Set the type and the size for the virtual disk. 10 Gb will be enough for my project (count 2Gb for the OS itself). I recommend also to use split files to avoid allocating all the space at the beginning (almost no impact on read/write performance).
10. Clic on _Next_.
11. Clic on _Finish_.

Now you can see your VM has appeared in the list :

![VM in list](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/43xrmpcjn1es2u7ah6cu.png)

## Installing Debian 11.x on the VM

Let's start the installation process, by launching the VM (clic on _Play virtual machine_).
You'll see the Debian install main menu, once the VM has started:

![Debian Menu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y5trn338va20peb1vkzg.png)

<u>Remark</u> : I've provided my choices between parenthesis.

1. Select _Graphical install_
2. Select a language (English).
3. Clic on _Continue_.
4. Select your location (other >> Europe >> France).
5. Clic on _Continue_.
6. Configure locales (United Kingdom - en_GB.UTF-8).
7. Clic on _Continue_.
8. Configure the keyboard (French).
9. Clic on _Continue_.
10. At this step, the installer checks that it has an internet access, which is mandatory in our case.
11. Set an hostname for the VM (debian-n64).
12. Clic on _Continue_.
13. Set a domain name (empty for me).
14. Clic on _Continue_.
15. Set a password for root user. Don't forget it!
16. Clic on _Continue_.
17. Set a new user (alex) and the associated password. DON'T FORGET IT, because this password will be asked when using _sudo_ command !
18. Clic on _Continue_.
19. Select the method for partitioning file system (Guided - use entire disk). I recommend the simplest method for VM use.
20. Clic on _Continue_.
21. Select the only disk available.
22. Clic on _Continue_.
23. Select partition disk (only one partition). I do not recommend _Separate /home partition_ which broke the installation for me.
24. Clic on _Continue_.
25. Clic on _Continue_.
26. Answer _yes_ to format the disk.
27. Clic on _Continue_.
28. At this point, the Debian base system is about to be installed.
29. Answer _no_ for adding more Debian repositories (the default one is sufficient).
30. Clic on _Continue_.
31. Select the Debian Mirror (France).
32. Clic on _Continue_.
33. Select the Debian Mirror (ftp.fr.debian.org).
34. Clic on _Continue_.
35. Select the proxy if needed (no proxy for me).
34. Clic on _Continue_.
35. Answer for participating to Debian packet statistics (no).
36. Clic on _Continue_.
37. Select the desktop environnement (default).
38. Clic on _Continue_.
39. Now, you'll have to wait a little when installing all the Debian packet (~1500).
40. Answer _yes_ to install the GRUB.
41. Clic on _Continue_.
42. Select the location of GRUB : MBR of _/dev/sda1_.
41. Clic on _Continue_.

That's all !

The VM will reboot after that, and the log menu is displayed :

![Log menu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/shg64c1hc10ngtzuppbk.png)

## Configuring the Debian virtual machine

### Enable common alias

I use all the time the alias _ll_ which is not directly available.
To have that, open a terminal and type : `vi ~/.bashrc`.
Now, uncomment the alias by removing the character _#_.
Start a new shell : `bash` 

### Become a sudoer

To be able to use _sudo_ command, you've to be in the sudoers list. For that, in a terminal :

1. Log as root : `su -`
2. Type the root password, set during the installation process.
3. Edit the sudoers file : `visudo`. It opens nano as default editor.
4. Add the following line, to add your username (alex for me) :
```
alex     ALL=(ALL:ALL) ALL`
```
5. Save and quit the editor.
6. quit the root session : `exit`.

### Share a host/guest folder

On the host machine (Windows, VM is powered off), in the VMware Player main menu :
1. Select the virtual machine, on the list.
2. Clic on _Edit virtual machine settings_.
3. Clic on _Options_ tab.
4. Clic on _Shared Folders_.
5. Select _Always enabled_ radio button.
6. Add a folder, and keep in memory the name.

Now start the VM and open a terminal :
1. Edit the fstab file which list mount configuration when the OS is launched : `vi /etc/fstab`
2. Add the following line : 
```
.host:/share    /home/alex/share    fuse.vmhgfs-fuse    allow_other,uid=1000,gid=1000    0    0
```
<u>Remarks</u> : 
- the local folder /home/alex/share will contain the share folder on the VM. It has to be created using `mkdir`
- the string after `.host:/` is the name set in the VM Player configuration (for me : _share_).

## Next episode

Ok, now I've a Debian virtual machine configured.
Next step will be to build an environnement to compile N64 programs using the official SDK!