Saturday, June 3, 2017

How To Update VirtualBox

Environment: Debian 8 (64-bit) host, Windows 7 (64-bit) guest

  1. $ sudo apt-get update
  2. $ sudo apt-get upgrade
  3. $ vboxmanage list extpacks
  4. if the version is older than on virtualbox.org, download the new one
  5. $ sudo vboxmanage extpack install --replace <extension_pack_filename>
  6. $ vboxmanage storageattach <vbox_guest_uuid> --storagectl "IDE" --port 0 --device 0 --type dvddrive --medium /usr/share/virtualbox/VBoxGuestAdditions.iso
  7. install VBoxGuestAdditions from Windows 7 (64-bit) guest
  8. $ vboxmanage storageattach <vbox_guest_uuid> --storagectl "IDE" --port 0 --device 0 --type dvddrive --medium emptydrive

Environment: Debian 8 (64-bit) host, Debian 9 (64-bit) guest


in host:
  1. $ sudo apt-get update
  2. $ sudo apt-get upgrade
  3. $ vboxmanage list extpacks
  4. if the version is older than on virtualbox.org, download the new one
  5. $ sudo vboxmanage extpack install --replace <extension_pack_filename>
  6. $ vboxmanage storageattach <vbox_guest_uuid> --storagectl "IDE" --port 0 --device 0 --type dvddrive --medium /usr/share/virtualbox/VBoxGuestAdditions.iso

in guest:
  1. $ sudo apt-get install build-essential module-assistant
  2. $ sudo m-a prepare
  3. $ sudo mount -o exec /dev/cdrom /media/cdrom
  4. $ sudo /media/cdrom/VBoxLinuxAdditions.run
  5. $ sudo umount /media/cdrom

in host:
  1. $ vboxmanage storageattach <vbox_guest_uuid> --storagectl "IDE" --port 0 --device 0 --type dvddrive --medium emptydrive

Sunday, April 30, 2017

Pasting from X selection with keyboard

My mouse's middle button has a problem after I have been using it for a few years. It doesn't easily work when I click it to paste anymore. I have to try clicking the button a few times each time and that is very sad, and it even hurts my hand already. It's time to paste with keyboard instead.

I learn from Google Search that "shift+ins" works. I have tried that with Ubuntu 14.04 (Unity) and Debian (lxde). It works, but not for all cases. Now, I am using a workaround below instead:

xsel | xclip -selection c

It passes the text I select to clipboard and then I can use ctrl+v to paste instead. The bad thing is that it trashes whatever is stored in the clipboard (ctrl+c). But it is reliable. Feel free to map it with other tools at your convenience.

Thursday, March 30, 2017

Windows PowerShell

Running Remote Command with Windows PowerShell inside WORKGROUP

on each machine:
  • run powershell as admin 
  • Enable-PSRemoting
  • Set-Item wsman:\localhost\client\trustedhosts *
  • Restart-Service WinRM 
frequently used commands:
  • Get-Service winrm
  • Stop-Computer -Force
  • Enter-PSSession -ComputerName <ip_addr> -Credential <username>
  • Exit-PSSession
  • Invoke-Command -ComputerName <ip_addr> Stop-Computer -Force
  • Set-ExecutionPolicy remotesigned : To run unsigned PowerShell script

Sunday, February 19, 2017

An Example of How To Auto Update System Time in Auto Resumed Guest OS after host OS boots up in KVM

Environments
  • Host OS: Debian 8
  • Guest OS: Debian 8
Currently, when we suspend a guest OS for N minutes and resume it, the system time in the guest OS is N minutes in the past.

I configure my KVM system such that when the host OS shuts down or reboots,  all the running guest OSes are suspended.  And they are automatically resumed after the host OS boots up.  (Here is the link which shows you how to do that.  Read the section, "Automatic guest management on host shutdown/startup".)

Assuming the host OS and the guest OS are always accessible from the local network, I decide to use SSH and /etc/rc.local to automate the updating of system time of the guest OS after it is automatically resumed.

Here are the steps it takes to do it:
  1. Create a special unix user on the guest OS and, probably, name it, kvmupdatetimeman
  2. Grant sudo permission to user kvmupdatetimeman by adding the line below in the vi editor which shows up when you issue the command `sudo VISUAL=vi visudo`:

  3. Assuming a unix user on the host OS you want to use for this purpose is debian, set up SSH public key authentication for user debian on the host OS so that it can SSH to the guest OS under user kvmupdatetimeman without having to enter a password.  Make sure you SSH from the host OS to the guest OS at least once so that you already have accepted the SSH host key of the guest OS or else our automated script will have problem as we won't handle the accepting of the SSH host key from our script.
  4. On the host OS, add this line to the file /etc/rc.local which is executed every time after the machine boots up.

  5. Add the code below into the file updatesystimeinguest and don't forget to chmod +x it.  Assuming the 2 IP addresses in the code are your guest OSes' IP addresses in your local network:

Now, every time you boot up your host OS after shutting down or rebooting, your auto suspended guest OSes which are automatically resumed will have correct system time automatically.

Related links