Saturday, September 05, 2020

Expand Your Virtualbox Virtual Hard Drives

This How To will walk you through expanding the virtual hard drive size of a guest Windows 10 virtual which is being hosted on an Ubuntu 20.04 machine running Virtualbox 6.1.

There are three sections to this guide.  

Section I is work that needs done from a Terminal Window inside your Linux Host System and from inside the Virtualbox 6.1 program.

Section II is work that needs done from inside you virtual Windows 10.

Section III is work done inside your virtual Windows 10 in an Admin Command Prompt but only needs done if you encounter certain problems in Section II. 

------------------------------------------------------------------------------------------------------------------

SECTION I
Work done in Linux and Virtualbox


1.  Make sure your virtual is shut off.

2. Locate your Windows 10 virtual image file (.vdi).  Mine is located in "/Home/username/VirtualBox VMs/Windows 10 Home/Windows 10 Home.vdi"

3. Make a backup copy of the .vdi file and put it in a safe place (this will take a little time since it is probably several gigs in size, mine was 60gb).

4. Open Virtualbox (not your virtual Windows 10, but Virtualbox itself).

5. Once in Virtualbox, Right Click on your Windows 10 virtual and select SETTINGS.

6. In settings, select STORAGE, then Right Click on your .vdi file (mines called "Windows 10 Home.vdi") and then click on the REMOVE ATTACHMENT.  

NOTE:  Don't worry this does not delete anything it just disconnects it from this virtual.  Think of it as taking the hard drive out of your computer, you can put it back in whenever you want, nothing is lost)

8.  With the .vdi file detached, close Virtualbox

9. Open a Terminal Window and navigate to the location where your .vdi file is located (Mine is in /Home/username/VirtualBox VMs/Windows 10 Home/Windows 10 Home.vdi) (from Step 2).

10 Once you are in the same folder as your .vdi file, type the following into your Terminal Window.

vboxmanage modifyhd "NameOfYourVDIfile.vdi" --resize 128000

NOTE: You will need to replace "NameOfYourVDIfile.vdi" with the actual name of your .vdi file. The 128000 at the end is the new size you want your virtual hard drive to become.  This number is in megabytes (mb) so in this case 128000 mb equals 128gbs.  This number has to be bigger than your original virtual hard drive size (you can't make it smaller this way) and has to be able to fit in your actual physical hard drive's free space (this is your physical computer's physical hard drive). 

11. Once you've made the changes needed to the above command, hit ENTER.  You will then see something that looks like this:

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

12.  You can now close your Terminal Window, you have resized your virtual hard drive, now you have to reconnect it to your Virtual Windows 10.

13. Open Virtualbox, Right Click on your Windows 10 virtual and select SETTINGS.


14. Once Settings opens select STORAGE then Single Left Click on CONTROLLER:SATA, then Double Left Click on the little picture of a hard drive (circled in red in this slide)


15. Once you've clicked on the little hard disk icon you will be present with the option to pick the .vdi file you want to attach to your Windows 10 Virtual.  Pick your Windows 10's .vdi file that we just expanded.  Mine is called "Windows 10 Home.vdi" and shows up under NOT ATTACHED in the popup window.


16.  If you've done everything right so far you should now see your newly expanded virtual hard drive (.vdi file) reattached to your Windows 10 Virtual like in the slide below.




Congratulation you've expanded your virtual hard drive for your virtual Windows 10 and your Windows 10 virtual machine will now boot but you will not see any difference in the amount of space on your virtual hard drive.  Now we have to tell Windows 10 that it has more hard drive space and we have to expand it's virtual hard drive though Windows 10.

------------------------------------------------------------------------------------------------------------------

SECTION II
Working inside your Virtual


1. Start your Windows 10 Virtual.


2. Once logged in click on START then ADMINISTRATION TOOL then COMPUTER MANAGEMENT and select DISK MANAGEMENT.  You should see something like this slide:


NOTE:  You may see a 4th partition between your C: and the Unallocated block, named Windows Recovery Partition.  If you see this 4th partition (Windows Recovery Partition) you will need to skip to Section III labeled Remove Windows Recovery Partition below this section.  Once you complete all the steps in the Remove Windows Recovery Partition section return to this point and proceed with the remaining steps in this section.

3. Assuming that your partitions look like the slide in Step 2 (Just 3 partitions; System Reserved, C:, and unallocated).  If so, great.  Right Click on on the Block labeled "C:" (One with a blue line over it in the middle).  This will bring up a menu, select the EXTEND VOLUME option which will start a wizard. (if the Extend Volume option is grayed out then read the NOTE in Step 2 above)


4.  Once the wizard starts you can pretty much just accept the defaults until the wizard finishes.  Here is a walk thru of my wizard:




NOTE: Your partition size numbers will be different than mine base on how much you expanded your virtual hard drive in the first section of this how to.  Generally you just want to accept the defaults which will try to add all the additional space it can. 


5.  When you finish the wizard you now see that you only have two partitions, System Reserved and C:. Congratulation you are done and you can close COMPUTER MANAGEMENT.  Check your C: drive you should now have more room and can breath a little easier.

------------------------------------------------------------------------------------------------------------------

SECTION III
Removing a Windows Recovery Partition
ONLY DO THE STEPS IN THIS SECTION IF YOUR EXTEND PARTITION WAS GRAYED OUT IN SECTION II

If you encountered a 4th partition named Windows Recovery in Section II and it was between your C: and Unallocated partitions, you can not combine the two (C: and Unallocated) without removing the Windows Recovery Partition.  If the option to EXTEND VOLUME is grayed out on your C: partition, removing the Recovery Partition is the only way I know of to proceed. We will need to do this from an Admin DOS Command Prompt from within the virtual Windows 10.  Here's how:

1. From within the virtual Windows 10
 Right-click the Start Menu and select Command Prompt (Admin).

2. Type diskpart and press Enter.

3. Type list disk and press Enter.
 (A list of disks will be displayed.)

4. Type select disk # and press Enter.
 (Replace # with the number of the disk containing the recovery partition) 

5. Type list partition and press Enter.
 (A list of partitions will be displayed.) 

6. Type select partition # and press Enter.
 (Replace # with the number of the recovery partition

7. Type delete partition override and press Enter.

After the confirmation message, you can close the DOS Command Prompt and go back to Section II and finish those steps.

Friday, January 10, 2020

Create Desktop Shortcut Ubuntu 19.10

I'm running Ubuntu 19.10 in a Virtualbox and wanted to create desktop shortcuts to programs so that I can quickly launching them (my machine is still running 16.04 since I skipped 18.04 because of Gnome Desktop).

It shouldn't be this much of a pain to create a desktop shortcut but the Gnome Desktop people think the desktop should be nothing more than a Theme Machine.  The Gnome Desktop looks and acts so much like an Apple Ipad I see Steve Jobs ghost every time I look at it.   Alright enough whining from me it's what we got so let's try to make it work for us our way.

First we need to install Gnome Tweaks.  In Terminal (Command Line) type the following:

sudo apt-get install gnome-tweaks

Once it installs, run it. Now navigate to the EXTENSIONS section and turn on the DESKTOP ICONS option.


That's all you need for Desktop Shortcuts but there are other niceties that Gnome Tweaks offers and it's worth looking over later.

To make our desktop shortcut we need to locate the "launcher" file for our chosen program. These "launcher" files are stored in a couple of locations on Ubuntu systems and they have the extension ".desktop" The ".desktop" files are located in the following two directories:

/usr/share/applications/
/home/YOURUSERNAME/.local/share/applications/

*** replace YOURUSERNAME with your logon name (user name)
*** most ".desktop" files are stored in the first location

To get to the ".desktop" files just launch the FILES program and navigate to one of the two folders where the .desktop files are stored.  (NOTE:  to get to the "/usr/share/applications" you will have to first click on the OTHER LOCATIONS option in the left hand column in FILES)


After Clicking on the OTHER LOCATIONS options you click on the COMPUTER option in the left top section of the FILES program.  After that just navigate to the "/usr/share/applications" folder and find the ".desktop" file for the program you want to create a desktop shortcut for.



Below is where ".desktop' files are stored in your home directory.
They are in a hidden folder so you have to check 
the "Show Hidden" option in FILES

Once you've found the ".desktop" file for your desired program you simple Right Click on it and select COPY.  Then navigate to the DESKTOP directory (left side panel in your FILES program) and PASTE your ".desktop" file into the DESKTOP folder.

That will make the ".desktop" file appear on your desktop but the icon will be wrong and it will not function yet. Below you can see that I copied and pasted the ".desktop" file for the program Darktable.  Notice that the "shortcut" looks like a text file and you can see ".desktop" extension still.


To finish make this a usable desktop shortcut you will need to Right Click on the ".desktop" file on your desktop and select properties. Now click on the PERMISSIONS tab and check the "Allow executing file as program" option.  Just closing Properties saves your change (click on the X in the upper right corner).



Okay now the last step.  Once again Right Click on your ".desktop" file on your desktop and you should have an option that says "Allow Launching"  just Left Click on it and it will then be ready and the icon should change to what your use to seeing associated with your program.


You can now double click on your new desktop shortcut and it should start your program.


Wouldn't it be a lot easier to just allow a right click on your desktop and browse to your desired application?  Or even have an GUI app installed by default that did most of the heavy lifting for you?  Well there's not that I know of and it gets harder from here.


METHOD 2


MAKE YOUR OWN ".DESKTOP" FILE

What if you've installed AppImages and need make a desktop shortcut for them or  if there is no "launcher" file on your system for your progam?  or maybe you've written your own Bash Script  or Python program and want a quick desktop shortcut to it.  Well you will have to make your own ".desktop" file.

I'm going to go through this quickly so that you can just get it done.  I encourage you to read more about ".desktop" files and all their options here.

First open a text editor, create a new blank document, and copy & paste the below information into it:


[Desktop Entry]
Version=2.6
Name[en_US]=Darktable
GenericName[en_US]=Graphic Editor
Comment[en_US]=This is an AppImage file link of Darktable
Exec=/home/YOURUSERNAME/AppImages/Darktable2.8.AppImage
Path=/home/YOURUSERNAME/AppImages/
Icon=/home/YOURUSERNAME/Pictures/Icons/darktable.png
Terminal=false
Type=Application
Categories=Application



Now you need to change what you copied & pasted to fit your needs.  Here is what each line means and what you should change:

[Desktop Entry]
All .desktop files start with this

Version=2.6
This is the version of your program and you really don't have to have this line or it doesn't have to be correct but you should try to get it right

Name[en_US]=Darktable
This is the name that will appear under your new desktop shortcut

GenericName[en_US]=Graphic Editor
This is a general type of application i.e. webbrowser, text editor, graphic editor etc.

Comment[en_US]=This is an AppImage file link of Darktable
Whatever you want to help you know about this shortcut

Exec=/home/YOURUSERNAME/AppImages/Darktable2.8.AppImage
This is the path to and your programs startup command.  My program's startup command is "Darktable2.8.AppImage" and that program is located in "/home/YOURUSERNAME/AppImages/" directory.  This program happends to be in my home directory in the folder AppImages.  If your's is similar you would change YOURUSERNAME to your logon or user name.

Path=/home/YOURUSERNAME/AppImages/
This is path to your program and where your program will startup

Icon=/home/YOURUSERNAME/Pictures/Icons/darktable.png
This is the path to and file name of the graphic you want to use as an icon for your program.  I have a folder in my "Pictures" folder called "Icons" where I keep all my icon graphics. Change this to fit your needs.

Terminal=false
Is this a Terminal program or command.  i.e. if this was a bash script you would set this to "true".

Type=Application
This specification defines 3 types of desktop entries: Application, Link or Directory.

Categories=Application
Categories in which the entry should be shown in a menu.

There are more options you can add and for a better explanation you really should follow this link and read more about it.

Okay, once you've changed the ".desktop" file to fit your needs save it to the DESKTOP directory with the extension ".desktop".  Make sure you have you icon graphic saved in the proper place that was referenced in the ".desktop" file you just saved.

The ".desktop" file should have appeared on your desktop after you saved the ".desktop" file to the DESKTOP directory but it will look like a text file and will not function yet.


You will now need to Right Click on the ".desktop" file on your desktop and select properties. Now click on the PERMISSIONS tab and check the "Allow executing file as program" option.  Just closing Properties saves your change (click on the X in the upper right corner).



Okay last step.  Once again Right Click on your ".desktop" file on your desktop and you should have an option that says "Allow Launching"  just Left Click on it and it will then be ready and the icon should change to what your use to seeing associated with your program.



You can now double click on your new desktop shortcut and it should start your program.


***NOTES:  When editing make sure you mind your Capital Letters in file and path names.  I tried the "~" shortcut for my home directory but it did not work for me.  Watch the "/" and make sure you have them in the right places.  When you copy .desktop file from one of the two directories they tend to have a lot more options set in their .desktop files.  You can make .desktop files that reference Bash scripts just make sure to change the Terminal=false to Terminal=true and in the Exec= part this works for me "Exec=/PathToBashScript/bash BashScriptName.sh" .  The same will work for Python too.

***ICON'S Locations.  The images used as the icons are either referenced directly with their entire path listed in the .desktop file (ICON=/path/image) or are stored in a couple of system directories. One is  "/usr/share/pixmaps" and the second is "/usr/share/icons" (most live here).  If you just see a name without a path listed in the .desktop file (i.e. Icon=imagefile) then it will be stored based off the variable $prefix which can be /usr, /usr/local or ~/.local or in one of the two directories listed above.

Sunday, January 05, 2020

USB Logitech Unified Mouse/Keyboard Quit Working

I had a Logitech Unified USB wireless mouse/keyboard combo that worked plug & play on Ubuntu 16.04.  While cleaning the PC I broke the Unified USB dongle (don't ask).  A new Unified dongle was $15 alone or you could get a new M510 Mouse and dongle for $20.  I figured, why not get the mouse too.  Once I plugged in the Logitech Unified Dongle, the mouse worked great, but there are no hardware buttons for pairing my old keyboard (k360 model).  A quick search online and I found the pairing software for Mac, Windows, and Chrome but not Linux. 

I had a plan I thought might work, I have a virtual windows 10 running on the Ubuntu 16.04 box so I downloaded the pairing software for windows and installed it on my virtual box win 10.  I then associated a USB port with the virtual win 10 and ran the pairing software on the virtual.  I plugged in the Unified Dongle when instructed and amazingly it worked and the k360 keyboard paired with the new Unified Dongle.  I then accidentally hit the RESET switch on the computer and it shut down while the virtual was still running.  Upon reboot I was getting no response from the mouse or keyboard.  In addition no USB keyboard or mouse would work (no input devices at all).  I could get into bios and the keyboards and mice worked fine, but once Ubuntu booted I could not type my password or move the mouse cursor.

How I fixed it;  

1.  After several resets I found the f12 key would bring up the GRUB menu in which I selected the ADVANCED option.


2.  This will bring up a 2nd menu.  I picked the 2nd option down the (upstart) one.


3.  This will drop you to a command line (Terminal) screen.  It will ask for your User Name and Pass Word.  Once you supply those you will be able to type commands.

4.  I reinstalled the xserver-xorg-input software from this command line with the following three commands;

sudo apt-get update
sudo apt-get install --reinstall xserver-xorg-input-all
sudo reboot

That was it.  After doing this everything worked just fine and the keyboard was still paired with the new Unified Dongle.


NOTE:  After doing this the hard way I've read that there is Linux software that does the pairing and more.  I did not use this software so you may want to research it before trying it but to install it you simple open a Terminal Window (command prompt) and type the following three commands;

sudo apt-get update   
sudo apt-get install solaar 
sudo reboot

After the reboot you will see a new icon on the top right of your screen near the date and time.


It's the bluish * looking one.

Here is an article about Solaar.  Good luck.

Saturday, January 04, 2020

Adjust Mouse Sensitivity

The Mouse Sensitivity option is not showing up in Ubuntu 16.04 and using the Terminal Command "xset mouse num num" command has to be done at every log on.  I'm using a Logitech wireless mouse and keyboard.  I've read that if you have a wired mouse the option does show.


There is another way to set the mouse sensitivity with a GUI program, xserver xorg input synaptics. To install it run the following command in a Terminal window.

sudo apt-get install xserver-xorg-input-synaptics

Once the program installs you can find it by searching your programs for KEYBOARD AND MOUSE.  Running it bring up the following with the needed options.



This will allow you to adjust your sensitivity and acceleration along with some keyboard functions.