Ah, the moment of triumph!!!
I had installed Fedora before in Virtual Box. In fact, I had done it several times. I have also installed Guest Addition to Ubuntu to correct display resolution problem. But this time? Not only did I ran into trouble with installing Fedora, but the Guest Addition for it as well! I have never had so trouble before!
So, what happened?
Well, at first there was problem with the hard disk installation refusing to stick. I would installed it, and it would me to re-install each time it boots! Turns out the optical drive was being booted first, and because I am on a VM, I can’t use F12 to choose the boot drive. So instead, I just went to Settings->Storage and remove the optical drive. That worked for a while… than I decided to install Guest Addition.
When I attempt to mount Guest Addition, it tells me that my optical drive is empty.
Ok. Optical drive. Optical drive. Wasn’t that what the Fedora iso was on? Am I suppose to keep the Fedora iso as an optical drive for some reason? But the VM boots the optical drive before the hard drive every time. Did I missed something? Luckily(?), I realized that I can changed the boot order while Settings->System->Boot Order. Then I added Fedora’s iso back as virtual optical drive (Some of you may already realized what happened and is laughing at my idiocy. For the others? Yep, that was not the right train of thought.). Yea! I did it, right?
Then my Guest Addition refused to mount.
*Head hits table*
The “Force Unmount” button and the “VERR_PDM_MEDIA_LOCKED” under “Details” led me to deduce the process failed because there is something locking the media drive. Then I though, “Did I accidentally mounted the Guest Additions already?” So, I tried both clicking the “Force Unmount” button and entering a umount VBoxGuestAdditions.iso command. Neither worked.
I did a mount and grep for the Guest Addition file, but it’s not in the list. I tried to check what’s in /dev/cdrom. There is a README.MD file there, so there is something… I did another mount, but grep for dev. Then, the light-bulb lit – /dev/sr0, which is where the symlink of /dev/cdrom connect to, is not mounted to the Guest Addition. Some of you who may have noticed about my mistake earlier – I did mounted something to virtual optical drive… I created a virtual optical drive by mounting the Fedora iso, which mean the drive was occupied with another mount already. I should had created an empty virtual optical drive, or created a virtual optical drive with the GuestAddition.iso .
I did a umount of sr0, and this time the install was success, and upon reboot, the resolution of screen is correct.
*sigh with relieve*
Here are the the steps:
Creating the Virtual Machine VDI file:
- Open VirtualBox. Click New.
- In “Name and operation system”, enter something for Name. Make sure the Operation System is Fedora.
- In “Memory Size”, enter 2048. (1024 works at first, but I started having mouse problem. Seems like 2048 works fine.)
- Stay with default for “Hard Disk”, “Hard Disk File Type”, “Storage on physical hard disk”, and “File Location and size”.
Install Fedora in the Virtual Machine you created:
- Make sure the iso file for Fedora Workstation had been downloaded. Start the VM. When it ask you to select a virtual optical drive, select the downloaded Fedora iso.
- Select “Install to Hard Drive”. Select your choice of language.
- Click on Installation Destination. Confirm that you are fine with “Automatic partition” by clicking done (unless you want to change the partition).
- Click “Begin Installation” at the bottom right.
- As Fedora install, there are options to add root password and create user, which I did.
- Once installation is complete, click Quit. Instead of rebooting, power off here.
Correct Boot Order and Change Setting
- Right click VM in Virtual Box Manager. Select ‘Settings’. Change the following:
- In System -> Boot Order, there is an up and down button. Use that to push Hard Disk to the top.
- In Display -> Video Memory, increase the memory to 24MB. In Acceleration, click to turn on “Enable 3D Acceleration”.
- In Storage, there should be the Fedora iso file under “Controller IDE” and the distro’s vdi file under “Controller: SATA”. Remove the iso file. In order to install Guest Addition later, add an empty virtual optical drive to “Controller: IDE”.
- Make sure you click “Ok”, or the options you changed wouldn’t be saved!
Prepare and Install Guest Addition to Fix Display Resolution
- Boot VM. Open the Terminal.
- If you are not root user, su – to become root user.
- Optional: If you added root password and created user during installation, your account may not have sudo permission. If you don’t want to su – every time you need to do things as root, do the following:
- Enter visudo -f /etc/sudoers (Note that this uses a vi editor. If you don’t how to do basic Insert and Save, look it up!).
- At the bottom, add the needed line to give yourself permission to use sudo. For me, my line was username ALL=(ALL) ALL, with username for my account name.
- Save file. Try logging out of root with command exit, then do a sudo visudo -f /etc/sudoers. You should be able to enter your password and view the file.
- Enter command sudo dnf -y update. It’s going to take a while. Go eat.
- Finished? Ok, now enter sudo dnf install dkms gcc kernel-devel kernel-headers. When done, reboot Fedora.
- Go to Devices -> Insert Guest Additions CD image.
- Errors?: If you get the error I came across earlier, you have either forgotten to remove the iso for Fedora, or your cdrom is preoccupy with another mount for some reason. If clicking “Force Unmount” doesn’t work, do the following:
- Enter mount | grep dev. See if the mount on /dev/sr0 is the GuestAddition.iso. If there is nothing, ls -l /dev/cdrom to find what directory is the cdrom symlink to. If you still can’t find it, try mount | grep iso – your Fedora iso have to be mounted somewhere.
- Whatever your iso is mounted to, umount it. In my case, it was umount /dev/sr0. After that, do Devices -> Insert Guest Additions CD image again. This time, it should work.
- Reboot Fedora. Your resolution should now be fixed.