notes-computer-msSurfacePro4-msSurfacePro4Install

Configuring Windows

Plug in Surface, turn on

Go through install screens -- do NOT do express install, instead go in and turn OFF every option except for SafeFilter?.

Click Windows Start button in lower left corner, Settings, Updates, Check for updates.

Click Windows Start button in lower left corner, search for Powershell, right click, run as administrator, in Powershell do:

  Set-ItemProperty -Path "HKLM:\Software\Microsoft\WindowsUpdate\UX\Settings" -Name "UxOption" -Type DWord -Value 1

which turns off auto-restart for updates, according to https://gist.github.com/alirobe/7f3b34ad89a159e6daa1

Some trouble I had with Check for updates

First time i did this there was an error. The error message was cryptic but gave a hexadecimal (ie starting with "0x") error code. Searched the internet for this error code and found it was because the clock is wrong. The clock was indeed wrong. Went to Settings->Time and Language->Additional time, date, and regional settings->Set the time and date->internet time->Change settings->Update Now, and indeed time synchronization failed and the time stayed on the wrong time.

While I was looking up what to do about this on another computer, my Surface crashed -- it froze and the system failed to respond to either touch or pen. I think maybe i could get a "Slide to shut down your PC" screen to come up, but since touch didn't work i couldn't 'slide' (but maybe that screen didn't come up, and maybe i am confusing this memory with a different time it crashed). I rebooted it by holding down on the power button for a long time until it shut down, then pressing the power button to boot it.

This time the time worked for some reason, and then it was able to Check for updates. The first Check for updates took a long time (maybe a little less than 10 minutes?). Then it said it was downloading the updates. That took a long time, and then it said it was preparing the updates for installation. If you clicked on the link to get more information (I think the link may have been called 'Details'?) it listed the various updates that it was downloading or preparing (although on this screen it seemed to say 'installing' instead of 'preparing to install'). Some of the updates said 'Error' with no further information. At some point either it crashed and i rebooted it or it rebooted itself or it asked permission to reboot.

...

alternative description of the last few paragraphs:

after this reboot it rebooted itself one or more times before it got back to the desktop. This took awhile (i forgot how long; maybe 15 minutes or so?), and there wasn't really any sort of progress indicator. Then i looked at Updates again and more updates were downloading. At some point the computer crashed a second time; this time the screen was black but if i moved the cursor it would move, but it would only show the spinning in-progress cursor, and would not become un-black. Again i rebooted it; i don't remember if i held down the power button for a medium amount of time causing the 'slide to reboot' screen to come up again and then used that, or if i had to hold down the power button for a long amount of time. Eventually the next set of updates had downloaded and prepared to install, and now the computer asked me for permission to reboot and install it. I said yes, so it rebooted again. This time it booted into a progress indicator screen that said that it was upgrading windows and gave an estimated progress percentage. This took longer than the other updates-installing-via-reboot, maybe >30 minutes although i don't remember.

After all this the Updates said the system was up-to-date; however looking at Details, one update still showed Error. I tried 'Check for updates' and tried shutting down the computer and then booting it to no avail. Then i tried restarting the computer (using "Settings->Power->Restart" rather than "Settings->Power->Shut down") and that worked.

In the couple of days since, i've had no more Windows crashes, so maybe all the updates really did fix most everything. Still, it's shocking that the original system was so buggy, on a flagship high-end device that is supposed to be Microsoft's answer to Apple. It's not like i was doing anything weird; i literally had just got the computer and immediately started installing updates, i hadn't installed or used anything else, so why was it crashing? The main supposed benefit of one company controlling both the hardware and the software is that they can make everything work well together and test the heck out of their software running on their own hardware, so why didn't Microsoft do that before launching the Surface Pro 4? In any case, as long as it doesn't crash anymore, it's fine for me, but i feel bad for the people who bought the computer sooner, before the latest patches came out (apparently one of the big updates i downloaded was dated ~March 9).


Repartition

after the updates were installed, i tried to repartition before doing much else, because i worried that if i installed or did much other stuff some files might somehow be created in the middle of the drive, making it harder to shrink my windows partition. I'm not sure if this was really a danger, but i was being careful.

If not already disabled, disable 'Fast startup' (fastboot) in Power Options -> Choose what the power buttons do ->Change settings that are currently unavailable->Shutdown settings->Turn on fast startup (fast startup can cause problems with dual booting [1] [2]).

Start->Search for 'recovery' and select 'Create a recovery drive'. I put this on a USB drive. I needed 8 GB.

bitlocker was already off

get a root terminal by doing start->search for "cmd", right click on the result and select Run as Administrator, then in it do: powercfg.exe /hibernate off exit

note: if there isn't enough space in the following step you can try this too: start->settings->system->about->system info (last link on page)->advanced system settings->advanced->performance->advanced->virtual memory (Change...)->do not automatically manage; then select "No paging file". Reboot.

get the 'disk management' control panel by start->search for "partition" or for "disk management" select your primary partition by clicking on it, Action->All tasks->Shrink Volume for me, the "total size before shrink in MB" is 487077. 'size of available shrink space' is 453214, which is more than i need. i want to give about 25% of the HDD to Windows and 75% to Linux, and i want to take out 16G of swap before that, so the amount of 'shrink' i want is ceil((487077 - 214)*.75) + 214 = 369404 (leaving 117673 MB for the Windows partition). So i enter 369404 into the "Enter the amount of space to shrink in MB' box, and then press Shrink. It takes two seconds then says that i now have 114.92GB for Windows and 360.75GB of unallocated space (i leave the other two partitions, EFI and Recovery, alone). Then i decided to give 4GiB? (4096 MB) more to GNU/Linux so i shrunk Windows a little more.

re-enable the paging file via the control panel, reboot. get a root terminal and re-enable hibernation via 'powercfg.exe /hibernate on'. (note: elsewhere i read that hibernate can screw with Linux booting, so maybe don't reenable it?

Restart windows (apparently you have to do this after shrinking the Windows partition, before installing Ubuntu). i rebooted twice just to be safe.

After all of this my primary Windows partition, C:, shows 75.5GB free out of 114 (about 2/3s free).

(why 16GB swap? https://github.com/jimdigriz/debian-mssp4 suggests about 150% physical memory for swap. For 16 GB this almost agrees with https://help.ubuntu.com/community/SwapFaq (which suggests 20 GB))

if you have an external UHD monitor, it works at 30hz, just not at 60hz.

xrandr --output DP2-2 --mode 3840x2160 --rate 30.00


Issues

Sometimes upon awakening from sleep, the external screen is blank. The solution is to disconnect the cable connecting the surface to the hub, wait a few seconds until an image appears on the internal screen, and then reconnect the cable. But, this means that external drives connected via the Surface Dock will be disconnected uncleanly without unmounting them in the OS.

Using 'detect' in the Display control panel worked for me just now (once), i'll try that again next time and see if it always works.

Sometimes when trying to unlock Windows 10, it says "The device has been locked for security reasons". This only means that the PIN sign-in (and maybe the camera) won't work; you can still use the password. Annoying.

Other 'review'ish/statusy notes

How long is battery life? If i load a bunch of tabs in the web browser with a lot of junk (not sure what caused it, but i had youtube playing videos and also had presumably ads and stuff), the estimated battery life drops to ~1.75 hrs. If you do nothing, though, it goes up to ~9 hrs.

I haven't used i too many times all the way through the battery, but it seems like battery life for typical use for me is a little over 4 hours. Which i consider to be very short.

note that there is an invisible subset of the typecover trackpad that is right-click rather than left-click; see https://www.microsoft.com/surface/en-us/support/hardware-and-drivers/touchpad-a-builtin-mouse?os=windows-10

in the Ubuntu guest, the touchscreen and typecover work perfectly. The pen doesn't work too well though; clicking with it just makes a little circle appear where it's clicked. When the guest is (capturing what? the keyboard? the mouse?) the pen button acts like SUPER_L (the left Windows button). Two-fingered scroll on the typecover trackpad works. Scroll does not work on the touchscreen (it is interpreted as a click-and-drag).

It also looks like Virtualbox can pass in the webcam, though i havent tested that yet.

for short durations i can apparently sleep or hibernate from the Windows host without ill effects on the Linux guest in the VM, but for long durations sometimes the VM gets messed up (it freezes up; even if you pause the VM before putting the host to sleep and then unpause it after waking up). I don't know what the difference is. So i guess the conclusion is that you can't safely sleep with the VM on.

i tried xournal; you can't draw in it via the trackpad or the pen, but you can with the touchscreen.

So, this setup appears to fulfills the goal of enabling me to use the SP4 for Linux as a tablet (noting that the pen doesnt appear to work in Linux). As a bonus, this setup would allow you to concurrently run OneNote? (which i haven't tried yet, but some of my friends like it).

how big is too big for an external monitor?

thoughts on large monitors: how big is too big?

two questions:

resolution:

It depends on how far you sit from your computer and how big your screen is.

It stands to reason that the smaller the screen, the less benefit you will get from higher resolution, because, sitting at some fixed viewing distance, the effective size of each pixel is already very small on a small screen. At some point they would be so small that further increases in resolution wouldn't be perceptible by the human visual system; most likely there will be diminishing returns as you get close to this limit. Similarly, the farther away you sit, the less important higher resolution is.

I have a large keyboard tray in between me an my desk (todo measure), and my monitor is located about 9 inches (todo measure this) back from the edge of the desk (todo measure sum distance). There are ergonomic benefits to a keyboard tray so i don't think this is a crazy setup, altough there may be no good reason not to move the monitor closer to the edge of the desk than i currently have it.

I feel that 4k (by which i mean 3840x2160) is slightly higher than the optimal resolution. The next popular step below 4k is QHD (by which i mean 2560x1440). I would recommend QHD over 4k for a computer monitor. 4k is not terrible though, or at least it probably won't be terrible when the software and hardware ecosystem catches up to it and becomes able to process it quickly.

This is interesting, because it means that, in my opinion, the industry has finally 'maxed out' the resolution of computer monitors. Imo, further increases in resolution beyond 4k would actually be worse, not better.

physical size:

Again, it depends on how far you sit from your computer.

Size is important because i found that with my older monitor, a 24" that i ran at 1920x1200, either i zoomed in on stuff so much that a PDF of a single page wouldn't fit on the monitor, or i was constantly leaning forward in my chair to see better, which is ergonomically bad. So, i would recommend a size larger than 24". My current monitor is 32" and i find that to be a good size.

If the monitor is too big, then you have to move your head, as opposed to just your eyes, to see all of it. This is supposed to be bad for/tiring for you. It also may take more time or concentration than just moving your eyes, although i'm not sure about that.

general problems with the VM setup

" cat /sys/kernel/debug/dri/0/i915_frequency_info ... > Current CD clock frequency: 450000 kHz

Yep, that's too low for you 4k@60 mode. We'd need to bump to 540 MHz at least. Unfortunately we don't support dynamic cdclk change on SKL yet. There are some patches in flight somewhere to get it done, but last time I looked it still needed more work. " -- [3]

---

Backup, partially

to backup some of the contents of your EFI partition before starting:

search for 'cmd', right click on it, Run as administrator, "mountvol P: /S" (You can change P: to any unused drive letter; that's arbitrary.) now the EFI partition is mounted but is invisible to the File Explorer. But you can copy from it like this: search for 'task manager', run it, 'more details', File->Run new task->Browse..., navigate to This PC->P:, select the folder EFI, copy it, navigate to somewhere you want to store the backup, paste it. Note that file 'BCD' seems to be in use and can't be copied. Dunno if that makes this backup useless.

i don't know how to unmount volumes in Windows so i restarted after this (Start->Power->Restart)

(from http://superuser.com/questions/965751/how-to-access-efi-partition-on-windows-10 )


Install Ubuntu from Windows

note: this procedure requires a USB hub, a USB keyboard, and a USB mouse, because the Ubuntu installer won't recognize the surface touchscreen, pen, or typecover

get http://releases.ubuntu.com/16.04/ubuntu-16.04-beta2-desktop-amd64.iso from http://releases.ubuntu.com/16.04/

download rufus 2.8 from https://rufus.akeo.ie/ (as of this writing, virustotal thinks it's probably OK)

set Rufus to do not check for updates.

select your USB device

set partition scheme to GPT, set file system to FAT32. Next to 'create a bootable disk using' (which should be checked), leave it on 'iso image' and next to that should be a little CD icon, click it and select the ubuntu-16.04-beta2-desktop-amd64.iso that you downloaded. Now click Start. There may or may not be a dialog box saying that Rufus needs to download a new Syslinux version, if so click Yes. A dialog box warns that all data on the target device will be destroyed, click OK.

Now reboot. If it doesn't work, hold down volume up on reboot; verify that USB drive is set to boot first; disable secureboot.

note: i booted into the ubuntu installer and then didn't install and then rebooted and it went right to windows, rather than going into the ubuntu installer again! i rebooted again and same thing! next time i rebooted into UEFI with volume-up, and didnt change anything, just exited, and this time it booted into the ubuntu installer again.

select install ubuntu from menu english do connect to wifi right now do download updates, do install 3rd party software 'install ubuntu alongside windows boot manager'

NOTE:

"Never run sudo grub-install. This will wipe out GRUB and leave the system in an unbootable state. Simply installing the kernel is enough to do the trick." https://www.reddit.com/r/SurfaceLinux/comments/3rb2l5/has_anyone_successfully_installed_ubuntu_1510_on/

if you usually boot into Windows and then run Ubuntu in Virtualbox, then after the kernel updates, you will boot into GNU/Linux (on the bare metal) next time you reboot (not Windows); i think this is because the kernel update runs 'update-grub', and update-grub can't see the Windows partition from within Virtualbox, so it doesn't include it in the Grub menu. The solution is just to run 'sudo update-grub' after you boot into the bare metal GNU/Linux.

said another way:

often when Ubuntu updates, when i next reboot (in the bare metal), the windows boot option is gone! booting into ubuntu and doing 'sudo update-grub' fixes it though -- and when booting into the VM the windows option was gone, as it should be. Not sure what is happening here, and it's a little scary but at least it's easily fixed.

i guessing that what may be happening is when an update runs in the VM, it is running 'update-grub' in the background, which then looks at the UEFI configuration of the machine and sees the VM, so it doesn't see Windows, and so it updates the grub menu (the REAL one, on the bare metal) accordingly. So re-running update-grub from the bare menu lets it work.

i've heard that you should NOT use boot-repair, as it may hose windows booting [4]. Nor should you use EasyBCD? [5].

Links:

Ubuntu setup

sudo vi /etc/default/grub

(note: if you don't know vi then use another text editor instead)

change the first stanza to:

GRUB_DEFAULT=2
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=2
#GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="i915_bpo.enable_rc6=0"
#GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i915.i915_enable_rc6=0"
GRUB_CMDLINE_LINUX=""

sudo update-grub

sudo vi /etc/modprobe.d/myblacklist.conf

blacklist i915_bpo

sudo adduser yourusername video sudo adduser yourusername tty

add the 'noatime' option to each drive in /etc/fstab

Virtualbox setup

Download and install virtualbox (i got 5.0.16). Install all subfeatures and do give permission to install the USB thing. Download and install virtualbox extension pack.

Note that, although it isn't GPL licensed, according to virtualbox.org you are allowed to use (at least this version of) the virtualbox extension pack for free even if you are using VirtualBox? for commercial activity, as long as your VirtualBox? installation is just being used by you and a few other people:

"Personal use is when you install the product on one or more PCs yourself and you make use of it (or even your friend, sister and grandmother). It doesn't matter whether you just use it for fun or run your multi-million euro business with it. Also, if you install it on your work PC at some large company, this is still personal use. However, if you are an administrator and want to deploy it to the 500 desktops in your company, this would no longer qualify as personal use. Well, you could ask each of your 500 employees to install VirtualBox? but don't you think we deserve some money in this case? " -- https://www.virtualbox.org/wiki/Licensing_FAQ (question #6)

More info: https://www.virtualbox.org/wiki/VirtualBox_PUEL

run virtualbox as administrator (right click on it and choose run as administrator). Machine->New (or just New). Expert mode. Name gnu_linux. Type Linux, version Ubuntu (64-bit). Memory size 10240. Do not add a virtual hard disk. Create.

search for cmd. Right click on it, run it as administrator. cd C:\Program Files\Oracle\VirtualBox?

list your partitions with: VBoxManage? internalcommands listpartitions -rawdisk
.\PhysicalDrive?0

If your drive is setup like mine, Ubuntu will be on number 5, and swap will be on number 6. You can hopefully distinguish your partitions by their size. The following commands assume that partition numbers 5 and 6 are the ones to use. DON'T GET THIS WRONG, in particular, it could be catastrophic if you accidentally put the number for your Windows partition in here.

This is called 'raw hard disk access' For more info on this stuff, see:

Note: NEVER allow the guest (Linux) to have mount a disk via raw hard disk if the host (Windows) might have that partition mounted at the same time. For example, NEVER MOUNT THE WINDOWS PARTITION FROM WITHIN LINUX, and don't setup the windows partition for raw hard disk access.

VBoxManage? internalcommands createrawvmdk -filename "C:\Users\<user_name>\VirtualBox? VMs\gnu_linux\main_partition.vmdk" -rawdisk
.\PhysicalDrive?0 -partitions 5,6 where <user name> is replaced by your user name

There should be a pause and then the message "RAW host disk access VMDK file C:\Users\<user_name>\VirtualBox? VMs\gnu_linux\main_partition.vmdk created successfully."

Type 'exit' in the commandline window.

This will have created two files, main_partition.vmdk and main_partition-pt.vmdk.

Back to virtualbox. Settings. Storage. Click Controller: SATA. Click the 'add disk' icon (add new storage attachment). Add hard disk. Choose existing disk. Choose the file C:\Users\<user_name>\VirtualBox? VMs\gnu_linux\main_partition.vmdk . Click on the newly added 'main_partition.vmdk' and select the 'solid-state drive' option.

General->Shared Clipboard->Bidirectional ->Drag'n'Drop->Bidirectional System->Motherboard->Pointing device->USB multi-touch tablet. ->Chipset ICH9. ->Processor->2 CPUs (https://www.virtualbox.org/manual/ch03.html says to not set this more than your number of real cores, not the number of hyperthreads). Enable PAE. ->Display->Screen->Video memory->128 MB (the max). ->Networking->attached to: change to 'bridged adapter' ->USB->USB 3.0

Remember that you'll always have to run VirtualBox? as administrator with this setup.

NOTE: with this setup, if you ever save the VM state and then boot into bare metal GNU/Linux, and then run the VM with the saved state, you will corrupt your GNU/Linux partition!!! See [7]. Therefore, i recommend either never saving or pausing the VM state (which can be hard; sometimes VirtualBox? autosaves if eg the computer shuts down while VirtualBox? is running, as happened in the previous hyperlink), or only ever running VirtualBox? from a script that autodeletes any saved state before booting the VM (this is what i do), to avoid accidentally rebooting into GNU/Linux (which can easily happen, especially because each time Ubuntu auto-updates the kernel while running in the VM, the next time the machine reboots it will boot into GNU/Linux) and then later accidentally running the VM before you delete the saved state.

settings->usb->add usb filter with a '+' icon (the one that adds a usb filter with fields set to one specific device), add all external usb drives.

doesn't help much but probably a good idea:

cd "C:\Program Files\Oracle\VirtualBox?"

.\VBoxManage? modifyvm "gnu_linux" --vram 256

note: VBoxManage? will not accept values higher than 256 (which is in units of megabytes). if you edit the .vbox VM specification file manually with Wordpad and try to change the VRAM size to something larger than 256 MB, the VM won't boot, with the error message: "VRamSize? is too small, 0x0, max 0x100000 (VERR_INVALID_PARAMETER)." I wonder why? To compare, the Surface Pro 4 GPU has 32 GIGABYTES of graphics memory, or 128x the Virtualbox maximum.

to confirm that graphics acceleration is working inside the virtualbox:

/usr/lib/nux/unity_support_test -p

another useful program:

glxinfo

in virtualbox, file->preferences->input->virtual machine tab->host key combination: change to either 'menu' button (which is on the typecover 4 and which is on my current external keyboard), or rightALT-application.

in fullscreen mode, there is a 'mini toolbar' at middle of the bottom of the screen; just move your mouse down there to make it pop up with some menus. It is quite convenient. In Windowed mode, this is an extra menu at the top of the window.

to attempt to stop Windows from auto-restarting to apply updates (not sure if this is a good idea, i don't think i did it right on my system, not sure if anything is broken):

Administrative Tools->Task Scheduler->select (in left panel) Task Scheduler Library->Microsoft->Windows->UpdateOrchestrator?; in middle panel, tab 'triggers', make sure there are no triggers, if there are, go into 'properties' using the right panel and delete them. on right panel, make sure it is disabled; if not, click 'disable'.

Now, using the filesystem, look at the Properties of the file C:\Windows\System32\Tasks\Microsoft\Windows\UpdateOrchestrator?\Reboot . Security->Advanced->Change Owner from SYSTEM to Administrators. Close the Advanced and Properties dialogs, and reopen the Properties dialog and re-click Advanced. Click Disable Inheritance; Convert Inherited Permissions into Explicit Permissions, then in the Permission Entries, remove: YSTEM->Full Control (This folder and subfolders), SYSTEM->Special (Files only), CREATOR OWNER->Full Control (subfolders and files only); leaving only Read access for Authenticated Users, LOCAL SERVICE, NETWORK SERVICE and/or Read & Execute for Users and Everyone.

[8] step 2

Links:

Get VirtualBox to boot into GNU/Linux

So we already have a dual-boot system that can boot into either Windows or GNU/Linux, and we already have VirtualBox? mostly setup; VirtualBox? is using the real GNU/Linux partition, not an image file. Now we have to get VirtualBox? to actually boot into GNU/Linux.

cd /tmp
mkdir -p bootable_iso/boot/grub; cp /usr/lib/grub/x86_64-efi/* bootable_iso/boot/grub; cp /boot/grub/grub.cfg bootable_iso/boot/grub
sudo vi bootable_iso/boot/grub/grub.cfg
   # and remove or comment out the stanza relating to Windows Boot Manager (there won't be one if you are doing this from within the VM already, eg if you are upgrading the kernel later on)
sudo apt install xorriso
grub-mkrescue -v -o boot_ubuntu_vm.iso bootable_iso

Move the newly created boot_ubuntu_vm.iso file to the Windows partition (i do this by having Dropbox on both Linux and Windows). Boot into Windows (if you were doing the previous on bare metal instead of from within an already running VM).

attach boot_ubuntu_vm.iso to the VM using Storage->click on Controller IDE, then click add storage attachment (the "disk +" icon, then choose Add Optical Disc) (at the top of the list under Controller: IDE). Then check the Live CD/DVD box.

boot the VM. for me, it didnt work. Shut it down. Boot it again. This time it worked (i dunno if perhaps i was pressing some buttons).

If you get "Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)" during boot and then get dropped into maintenance mode, it's because one of the mount points specified in your fstab is missing. in fstab, mark any drives that aren't always present (eg external USB drives), but that you put in fstab, with the 'nofail' option. (do you do this on the 'main' fstab or is there an fstab on the boot_ubuntu_vm.iso? i forgot)

this is also the way to upgrade the kernel running in the VM (because ordinary Ubuntu updates can't modify boot_ubuntu_vm.iso)

note: i do 'sudo vi /etc/default/grub' and change GRUB_DEFAULT to 0 and 'sudo update-grub' before doing this so that the boot ISO will have the Ubuntu menu item as the default (not sure if the 'sudo update-grub' is actually necessary there). But then afterwards i have to boot back into bare metal Ubuntu (and do 'sudo vi /etc/default/grub' and change GRUB_DEFAULT back to 2 (Windows)) and run 'sudo update-grub' again in order for Windows to appear again in the bare metal bootloader (so that i can boot into Windows).

note: to have both the guest additions ISO and the boot ISO mounted at once, mount the guest additions ISO via going into the Devices menu, Optical Drives, IDE Primary Slave, and adding the .iso file from the directory C:\Program files\Oracle\VirtualBox? (after installing Guest Extension Pack onto VirtualBox?). (previously i had said, "VirtualBox?, Settings->Storage, using 'add optical disc' and adding the .iso file from the directory C:\Program files\Oracle\VirtualBox? (after installing Guest Extension Pack onto VirtualBox?)", but i don't think that works anymore). This is better than using the 'Devices' VirtualBox? menu from the running VirtualBox? VM window (Devices->Insert Guest Additions CD Image...) because using Insert Guest Additions CD Image will remove the boot ISO from the virtual CD drive, which would mean that the next time you try to boot the VM, it won't boot and you'll have to do back into Settings->Storage and put the boot ISO back into the virtual CD drive.

now to install the guest additions:

sudo apt-get install dkms
cd /media/YOUR_USERNAME/VBOXADDITIONS_5.0.20_106931

(where YOUR_USERNAME is replaced by your username, and VBOXADDITIONS_5.0.20_106931 is replaced by whatever the current versioned guest additions name is)

sudo sh ./VBoxLinuxAdditions.run
Power->restart (in the GNU/Linux guest, not in the Windows host)

Writing a Powershell script in Windows to boot VirtualBox after erasing any saved state

To allow us to write PowerShell? scripts,

search for 'powershell', run as admin, do

Set-ExecutionPolicy? RemoteSigned?

this makes it so that "Locally-created scripts will run. Scripts that were created on another machine will not run unless they are signed by a trusted publisher."

put this in a file at C:\Users\YOUR_USER_NAME\bin\run_gnu_linux.ps1:

# request administrator access
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }

cd "C:\Program Files\Oracle\VirtualBox"

.\VBoxManage discardstate gnu_linux

# when there is no saved state to be discarded (the usual case), the previous command will cause an error; this is normal"

.\VBoxManage startvm gnu_linux

# uncomment the following line if you want the script to wait for a keypress before terminating
#$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

to run run_gnu_linux.ps1 at startup, type windows-R to get the 'run' box, type shell:startup to go to the folder C:\Users\YOURUSERNAME\AppData?\Roaming\Microsoft\Windows\Start Menu\Programs\Startup, right-click, New->Shortcut, select the path 'powershell.exe C:\Users\YOURUSERNAME\bin\run_gnu_linux.ps1', Next, name it whatever (i named it 'run_gnu_linux').

to pin run_gnu_linux.ps1 to the taskbar, pin the shortcut that you just created to the taskbar, not the file run_gnu_linux.ps1.

(tangential note: some other startup tasks run too; you can see these in Task Manager, 'startup' tab)

Using VirtualBox

if you want to make it fullscreen:

the "host key" is the RIGHT control key. If you use that, it gets intercepted by VirtualBox? rather than passed to the guest, even when VirtualBox? has otherwise 'captured' the keyboard. Click on the guest window then press host-f (rightcntl-f) to get into fullscreen mode. Now shut down the VM by selecting the Shutdown menu option inside Ubunutu and confirming. If the VM was shutdown in fullscreen mode, it will remember to immediately go fullscreen again the next time it is started.

i like to use it in windowed mode, though. I run Firefox outside of the VM (on the host).

Pin virtualbox to the taskbar at the beginning. Now when in Windows, running Virtualbox, you can press Windows-1 to switch to the virtualbox window. And, assuming that the right Windows key is still the Host key in virtualbox, you can press Windows and then Windows-2 to switch to the second application in the taskbar (which for me in pinned firefox, ie firefox on the windows side).

Virtualbox issues

External USB drives

virtualbox has a lot of trouble 'capturing' USB drives from a Windows host if Windows has already tried to use the drive.

Leave the USB hub to which the drives are plugged in off until Linux is booting on the VM.

also if you shut down the VM sometimes Windows gets the drive.

restarting the VM doesn't seem to help. the only workaround i have found is to restart the entire Windows host. Even then, even if i start the VM immediately upon startup, often some of my external drives are not captured by the VM, so i end up rebooting the Windows host a few times until i get lucky.

Firefox blacklists virtualbox's graphics drivers

You can confirm this because in Firefox, URL 'about:support' 'Graphics' subsection says "Blocked for your graphics card because of unresolved driver issues." in various places.

For background, see:

You can force-enable the blocked functionality but for me, it screwed stuff up (Layers Acceleration caused menus to not render):

Sound doesn't work

Some people mentioned a workaround where you play a youtube video with sound on the Windows host while Virtualbox is booting and then while playing a sound in Virtualbox, but that didn't work for me.

In the VirtualBox? log i get an error "DSound: Starting playback failed with E_ACCESSDENIED".

iptraf doesn't work

on wlp2s0, which is my network interface under VirtualBox?. But nethogs does work:

sudo nethogs wlp2s0

or if your network interface is enp0s3:

sudo nethogs enp0s3

(in the past) sporadic failure to autologin

sometimes when booting ubuntu as a guest in the VM it (lightdm) doesn't autologin, even though this always works on bare metal. But sometimes it does work. Recently this problem has stopped occurring. I don't know why.

---

Windows App setup

to enable Windows Hello: Settings->Accounts->Sign in options, set a PIN (note: if you forget your PIN you'll still be able to use your old password), then enable Windows Hello

unpin Microsoft Edge from taskbar. unpin Microsoft Store.

Start->search for speech recognition->pin to taskbar

pin firefox to first pinned item in taskbar. Pin text editor (Notepad or Emacs) to second. Move pinned file explorer and pinned speech recognition to last.

search for 'mouse'->mouse and touchpad settings->additional mouse options->pointer options, use the slider to speed up the pointer

pin calculator to taskbar

Windows update->advanced options->change "Automatic (recommended)" to "notify to schedule restart"

windows update -> advanced options -> choose how updates are delivered -> make sure 'updates from more than one place' is turned off (it was already off for me)

turn on speech recognition; search for Speech and select Speech Recognition, turn on from there. Later, train the speech recognition to your voice; search for Speech and select Speech Recognition->Train your computer to better understand you. According to http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/windows-7-speech-recognition-training-needs-more/d308f134-f310-4e38-ab62-0031844a7b20 it doesn't matter whether or not you say punctuation during the training.

Settings->System->Battery saver, turn on if below 80%

Settings->System->Power and sleep->Additional power settings->Create a power plan->Never put the computer to sleep when plugged in, minimize brightness on battery, brightness on 50% when plugged in, turn off the screen after 15 minutes

install dropbox from dropbox.com

Colemak

download colemak from colemak.com. extract it, double click on setup.exe. To switch to it, click on the 'ENG US' in the taskbar, then select Colemak.

to make Colemak the default keyboard layout, not just a non-default optional one: after adding Colemak, pull up the keyboard layout selection menu from the task bar icon, Language Preferences->English->Options, select US QWERTY and Remove, then re-add it

OSK (on-screen keyboard)

Pin the OSK to the taskbar.

Firefox

download and install firefox

Firefox->Tools->Options->When Firefox starts: Show my windows and tabs from last time

log into Firefox to enable sync

install firefox extensions: uBlock origin, resurrect pages

install flux from justgetflux.com. Set your location. Change transition speed from 'fast' to 'slow'. Turn down brightness a little with alt-pagedown (alt-pageup makes brighter). Enable safe mode. If alt-pagedown makes it whiteish instead of yellowish, may have to enable "expand color range" and reboot (although currently i can't find that menu item) https://forum.justgetflux.com/topic/2194/dimming-brightness-appears-to-make-my-screen-cooler

install the Pinterest browser button

sudo ln -sf /usr/bin/firefox /etc/alternatives/x-www-browser
sudo ln -sf /usr/bin/firefox /etc/alternatives/gnome-www-browser

Moving stuff from my old GNU/Linux computer to this one

scp the old computer's filesystem into a folder called 'oldcomputer' in your user home directory on the new computer. Then:

cd
sudo mv /etc/postfix /etc/postfix.orig
sudo mv oldcomputer/etc/postfix /etc/postfix
sudo cp /etc/aliases /etc/aliases.orig
sudo mv oldcomputer/etc/aliases /etc/aliases

cd ~/Mail; ln -s bsgmail/INBOX/ local

sudo /etc/init.d/postfix reload

sudo mv oldcomputer/etc/mailname /etc/

crontab -e, and add line:
<pre>
*/3 * * * * offlineimap -o -u quiet
</pre>

Copy the contents of the old home folder from oldcomputer into the new home folder.


Linux app setup

Vi

  1. .exrc is for vi; this turns off the ridiculous substitution of arrow keys with letters while in insert mode vi ~/.exrc

set nocompatible

Install stuff

sudo apt dist-upgrade
sudo apt install screen aptitude xkbset desktopnova libgetopt-declare-perl texlive-full mercurial git subversion cvs bzr ack-grep qiv ssh atop gnupg urlview acpidump xournal gimp vlc-nox  gstreamer0.10-plugins-bad  gv ssh preload iotop tmux screen vim mairix pwgen xpdf powertop ntp exiv2 htop vlc smartmontools whois python-scrapy youtube-dl ffmpeg libav-tools mouseemu offlineimap wmctrl mutt-patched postfix xdotool dkms perl-doc wmctrl xdotool offlineimap wmctrl mutt-patched postfix pymacs python-mode emacs smartmontools iptraf xorriso compizconfig-settings-manager mesa-utils

some stuff that i use but that many people won't need:

sudo apt install ipython python-scipy octave python-matplotlib python-setuptools python-mode graphviz python-virtualenv python-decorator git ack-grep atop gnupg iptraf tightvncserver python-pip python python-dev gcc g++ libatlas-dev gfortran liblapack-dev python-pandas cython python-requests python-sklearn python-numpy gcc python2.7 gnupg python-imaging cython python-rpy2 python-prettytable python-statsmodels pymacs python-mode perl-doc 

To install Pharo Smalltalk:

sudo apt-add-repository -y ppa:pharo/stable
sudo apt-get update
sudo apt-get install pharo-vm-desktop pharo-launcher

To install WikiGateway (you probably don't need this):

sudo aptitude install python-setuptools python-feedparser python-mechanize python-egenix-mxdatetime # required by wikigateway
cd prog/wikigateway/libraries/pythonModule/
sudo python setup.py install

Compiz

sudo apt-get install compizconfig-settings-manager
ccsm&

unity-control-center->appearance->behavior->enable workspaces

display:scaling to 200%

effects->turn everything off

desktop->ubuntu unity plugin->general->enable low graphics mode ->menus->set all fade-* durations to 0 (they were in the hundreds)

settings->appearance->behavior->menus visibility->always

gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ hsize 3
gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ vsize 3

unity-control-center->keyboard->shortcuts->assign cntl-Fx to 'Switch to workspace x' for x = 1..9

sudo apt install unity-tweak-tool

general->texture quality->fast ->window animations: off ->desktop magnification: off launcher->launcher->autohide->on ->turn up reveal sensitivity ->search->background blur->off

ccsm&

utility->workarounds-> check 'Force full screen redraws (buffer swap) on repaint'

desktop wall->viewport switch preview->uncheck 'show viewport switch preview' desktop wall->viewport switch preview->uncheck 'show live viewport previews' desktop wall->viewport switching->set 'wall sliding duration' to 0

documentation: https://help.ubuntu.com/16.04/ubuntu-help/shell-windows.html

general->OpenGL?->uncheck 'sync to vblank'

(my compiz CPU usage was sometimes very high (40-80%!) and this may have reduced it, to about 20%-30% now; or maybe it didn't do anything, i'm not too sure. from http://askubuntu.com/questions/562640/high-cpu-with-compiz-and-ubuntu-14 )

also i had already had done:

general->OpenGL?->texture filter: 'fast'

w3m in mailcap

sudo apt install w3m

in /etc/mailcap, add:

text/html; w3m -I %{charset} -T text/html; copiousoutput; nametemplate=%s.html

right after the first text/html line

to unmount usb drives

i put the following into an sh script:

#!/bin/sh
sudo sync
find /media -xdev | xargs -n1 sudo umount 
sudo sync

i run this script before disconnecting the Surface from the external hard drives, to make sure everything is written to disk before i disconnect the disks.

HiDPI in xterm

add to .Xresources to make xterm use the 'xft' library (truetype fonts) with the default xft monospace font: xterm*faceName: mono and then add to .Xresources to scale up fonts: Xft.dpi: 120 then do this to activate the new .Xresources: xrdb -merge ~/.Xresources then create an xterm to test: xterm&

Shared virtualbox clipboard and xterm

virtualbox shared clipboard, bidirectional mode, only takes from the "CLIPBOARD" buffer in a Linux guest (the one that you use cntl-C, cntl-V with), not the "PRIMARY" buffer (the one that you use text selection and mouse middle key with) (although when you cntl-C on a Windows host, it copies it into both CLIPBOARD and PRIMARY).

So, to make xterm select to both buffers: xterm*VT100.translations: #override <Btn1Up>: select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0)

Ubuntu OSK

At first i ran the Virtualbox Ubuntu VM in Fullscreen mode and used the Ubuntu OSK, but now i always run the VM in Windowed mode, and i use the Windows 10 OSK when i need an OSK. If you are going to do the same, you can skip this subsection. But if you would like instructions on how to activate and configure the Ubuntu OSK, read on.

unity-control-center universal access->typing->turn "on screen keyboard" to "on"

The upper right hand key in the on screen keyboard (OSB) is an 'x' that will deactivate the OSK. To re-activate it, click the keyboard icon (four squares) in the Unity taskbar.

When logging in, you can activate the OSK via a little universal access icon (person in a circle) that appears in the taskbar at that time. The OSK is annoyingly small when logging in (making it more difficult than it should be to type your password) but gets bigger later.

configure the osk via the button with 3 lines, then the tools button. window->transparency> 20 for window, 50 for background, set to 50 after 4 seconds of inactivity general->start hidden

note that you can move the OSK by dragging the key with the four arrows.

Touch scrolling in Firefox

to make touch scrolling work in firefox, install extension 'grab and drag' (still doesn't work great for me).

my_startupwindows

install my move_window_to_viewport script and my my_startupwindows script

gnome-session-properties &

and create an item to run my_startupwindows at startup

Mouseemu to middle-click with touch cover

sudo vi /etc/default/mouseemu

add the line:

  MID_CLICK="-middle 0 88"         # F12 with no modifier

and save and exit (':wq')

sudo kill -HUP `cat /var/run/mouseemu.pid`

(if that last line doesn't do anything you may need to reboot)

now you can press F12 in lieu of mouse middle-click. This is handy when using the type cover, which doesn't appear to provide a way to middle click.

Traffic Shaping

traffic shaping

as root, create /etc/NetworkManager?