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?/dispatcher.d/mytc:

#!/bin/sh

install_mytc () {
  NET_DEVICE=$1

  INCOMING=$2
  MAX_INCOMING=$3
  OUTGOING=$4
  MAX_OUTGOING=$5

  /sbin/tc qdisc del dev $NET_DEVICE root

  /sbin/tc qdisc add dev $NET_DEVICE root handle 1:0 hfsc default 1
  /sbin/tc class add dev $NET_DEVICE parent 1:0 classid 1:1 hfsc sc m2 $OUTGOING ul m2 $MAX_OUTGOING
  /sbin/tc qdisc add dev $NET_DEVICE parent 1:1 handle 2: fq_codel

  /sbin/modprobe ifb numifbs=1
  /sbin/ip link set dev ifb0 up
  /sbin/tc qdisc del dev ifb0 root
  /sbin/tc qdisc del dev $NET_DEVICE ingress
  /sbin/tc qdisc add dev $NET_DEVICE handle ffff: ingress
  /sbin/tc filter add dev $NET_DEVICE parent ffff: protocol ip u32 match u32 0 0 action mirred egress redirect dev ifb0

  /sbin/tc qdisc add dev ifb0 root handle 1:0 hfsc default 1
  /sbin/tc class add dev ifb0 parent 1:0 classid 1:1 hfsc sc m2 $INCOMING ul m2 $MAX_INCOMING
  /sbin/tc qdisc add dev ifb0 parent 1:1 handle 2: fq_codel
}

install_mytc enp0s3 40mbit 44mbit  4000kbit 4400kbit 
install_mytc wlp2s0 40mbit 44mbit  4000kbit 4400kbit 



# note: why not just use ingress policing as in http://blog.stevedoria.net/20050906/ingress-policing-with-linux-and-tc instead of using ifb to re-route incoming packets to hfsc?
#  dunno why, but on my 17 mbit downlink, speedtest.net could only give me a max of about 1 mbit when i did that, but when i do what i did above, with ingress->ifb->tbf, i could get up to approximately my full downlink speed, and throttle it to whatever i liked. 
# 
# note that using just tbf instead of hfsc and fq_codel seemed to work just fine. I am using hfsc and fq_codel because people who know more about this stuff than me seem to be excited about fq_codel being 'advanced', and because it may have made an ssh connection while uploading/downloading have a little less latency.
#
#
# 
#related links:
# http://serverfault.com/questions/350023/tc-ingress-policing-and-ifb-mirroring
# http://linux-ip.net/articles/Traffic-Control-HOWTO/classless-qdiscs.html
# http://lartc.org/howto/index.html
# http://lartc.org/howto/lartc.qdisc.classful.html
# https://gist.github.com/bradoaks/940616 
# https://wiki.archlinux.org/index.php/Advanced_traffic_control
# https://wiki.gentoo.org/wiki/Traffic_shaping
# http://blog.stevedoria.net/20050906/ingress-policing-with-linux-and-tc
# https://gist.github.com/bradoaks/940616
# http://wiki.linuxwall.info/doku.php/en:ressources:dossiers:networking:traffic_control
# https://community.ubnt.com/t5/EdgeMAX/If-you-re-looking-to-better-understand-what-fq-codel-HTB-and-BQL/td-p/953863
# https://www.ietf.org/proceedings/90/slides/slides-90-aqm-6.pdf
# http://www.bufferbloat.net/projects/cerowrt/wiki/Wondershaper_Must_Die
# http://www.spinics.net/lists/lartc/msg23058.html
# http://www.linuxfoundation.org/collaborate/workgroups/networking/ifb
# http://linux-tc-notes.sourceforge.net/tc/doc/police.txt
# http://linux-tc-notes.sourceforge.net/tc/doc/sch_hfsc.txt
# http://askubuntu.com/questions/20872/how-do-i-limit-internet-bandwidth

# note: in general, mytc only really works as intended 
# on bare metal; in a VirtualBox VM, it does seem to
# throttle, but sometimes throttles much more than it is
# supposed to


# to turn off:
#  /sbin/tc qdisc del dev $NET_DEVICE root
#  /sbin/tc qdisc del dev $NET_DEVICE ingress
#  /sbin/tc qdisc del dev ifb0 root
#  /sbin/tc qdisc del dev ifb0 ingress


to deactivate throttling:

NET_DEVICE=wlp2s0

  1. or NET_DEVICE=enp0s3 sudo /sbin/tc qdisc del dev $NET_DEVICE root sudo /sbin/tc qdisc del dev $NET_DEVICE ingress sudo /sbin/tc qdisc del dev ifb0 root sudo /sbin/tc qdisc del dev ifb0 ingress

to reactivate throttling: sudo /etc/NetworkManager?/dispatcher.d/mytc

sudo chmod u+x /etc/NetworkManager?/dispatcher.d/mytc

What to do if there is an i915 error

when there is an error in i915 (the Linux GPU driver used with the SP4), to see the details, do:

sudo cat /sys/kernel/debug/dri/0/i915_error_state

" You can check the parameters of the i915 module by using the following command as root :

for i in /sys/module/i915/parameters/*;do echo ${i}=`cat $i`;done

"

[9]

Minecraft

When i initially tried Minecraft in the VM, it crashed. The following fixed it:

Increase allocated RAM from 1GB to 2GB (only applicable to 64 bit users):
    In the Edit Profile menu in the Launcher, check the JVM Arguments box, and change the -Xmx1G argument to -Xmx2G

Change Video Settings in-game (Options -> Video Settings)

    Enable VSync
    Enable VBOs


(not sure which of these did the trick; the VBOs option only seemed to appear when i was fullscreen?)

Shared folder between the Linux guest and the Windows host

Devices->Shared Folders->Shared Folder Settings->Machine folders->Folder plus icon, create a new folder named 'winshare' and check automount, make permanent sudo mkdir /media/winshare

to mount (have to redo this each time after booting):

  sudo mount -t vboxsf winshare /media/winshare

Gedit style

d/l https://wiki.gnome.org/Projects/GtkSourceView/StyleSchemes?action=AttachFile&do=get&target=darkmacs.xml and mv to ~/.local/share/gtksourceview-3.0/styles/ :

cd ~/.local/share mkdir -p gtksourceview-3.0/styles cd gtksourceview-3.0/styles wget 'https://wiki.gnome.org/Projects/GtkSourceView/StyleSchemes?action=AttachFile&do=get&target=darkmacs.xml' -O darkemacs.xml set gedit to use it: edit->preferences->fonts and colors

Pointer speed

settings->mouse and touchpad-> turn pointer speed faster (but not all the way)

Turn off screensaver/lock

Settings->Brightness&Lock->Turn screen off when inactive for: Never Settings->Brightness&Lock->Lock: off Settings->Brightness&Lock->uncheck Require my password when waking from suspend

workaround a bug in Virtualbox relating to Chrome

"Launch Chrome with the --disable-gpu switch, and then get into preferences and un-check the "use hardware acceleration if available" checkbox."

The bug is: https://www.virtualbox.org/ticket/15417 . For me, what happens is that various Chrome apps either don't render correctly, or mess up the VM so that you can't see anything in the VM within Xwindows.

possibly a better workaround (but i haven't tried it) is: https://blog.rudeotter.com/virtualbox-bug-display-chrome-chromium/

---

Notes for later, when we get the touchscreen drivers

ginn or touchegg for touchpad/touchscreen gestures on desktops that dont support it like cinnamon:

https://www.reddit.com/r/SurfaceLinux/comments/3mxeh3/mint_better_touch_screen_support/

---

SP3: refresh the touchscreen when it stops working: https://www.reddit.com/r/SurfaceLinux/comments/3sw93t/need_some_help_with_touch_screen_problem/

---

rotation sensors and auto-rotate in gnome:

https://www.reddit.com/r/SurfaceLinux/comments/3sk5tp/autorotation_issues_plus_a_workaround/

---

fix wifi by turning off wifi power management:

https://www.reddit.com/r/SurfaceLinux/comments/3qcqha/ubuntu_on_surface_book/

---

use 'redshift' on GNU/Linux to do something similar to what 'flux' does on Windows

---

some old kernels:

https://www.reddit.com/r/SurfaceLinux/comments/3qccha/current_status_of_sp4_on_linux_tested_with_mint/

tigerite's ubuntu-based kernel, from https://www.reddit.com/r/SurfaceLinux/comments/49kfct/best_linux_distro_option_for_surface_3_nonpro/:

add-apt-repository ppa:tigerite/kernel && apt-get update && apt-get install linux-surface

sudo add-apt-repository ppa:tigerite/kernel sudo apt-get update && sudo apt-get install linux-surface apt-get upgrade

various kernels for various surfaces:

https://www.reddit.com/r/SurfaceLinux/comments/3qcqha/ubuntu_on_surface_book/ https://www.reddit.com/r/SurfaceLinux/comments/30hg2w/sp3_kernel_40rc4_debs_with_patches_for_camera/

old outdated tigerite ubuntu kernel thread: https://www.reddit.com/r/SurfaceLinux/comments/3ufn49/ubuntu_on_surfacebook_touchscreen_pen_input/

chakra linux kernel/install by csslayer: https://www.reddit.com/r/SurfaceLinux/comments/3xhmu7/just_installed_chakra_linux_on_surface_pro_4_i7/

fedora : https://www.reddit.com/r/SurfaceLinux/comments/3w3xuq/fedora_23_w_plasma_5_on_surface_book_installation/

https://www.reddit.com/r/SurfaceLinux/comments/3qz8bo/kernels_for_surface_pro_34book/cwqhpcw

some patches:

some kernel patches for ubuntu for the SP3 for touchpad, special buttons, touchpad gestures, lid: http://askubuntu.com/questions/620726/ubuntu-on-surface-pro-3-or-linux-at-all

https://www.reddit.com/r/SurfaceLinux/comments/46o3mh/fix_udev_power_adapter_event_by_patching_acpi/

https://www.reddit.com/r/SurfaceLinux/comments/3z27ka/is_it_safe_to_install_kernel_updates_on_ubuntu/

to make grub detect NVMe:

https://www.reddit.com/r/SurfaceLinux/comments/46o1jf/some_more_information_for_grub_and_sp4/

https://www.reddit.com/r/SurfaceLinux/comments/40wgyo/type_cover_pro_4_on_nixos/

"The only "gotcha" I hit was that it would fail to boot (after install) unless I included the nvme module in my mkinitcpio.conf (I guess the driver needs to be loaded earlier than it was being loaded otherwise)."

automatic suspend: https://www.reddit.com/r/SurfaceLinux/comments/3zytfw/status_of_arch_linux_on_sp4/

autorotate: https://github.com/tiggerite/mint-17.3-for-surface-pro-3/blob/master/utils/autorotate

an old status report:

status from https://www.reddit.com/r/SurfaceLinux/comments/49ek0j/debian_and_surface_book/d0t9iz4:

"the cameras, hardware buttons, suspend, reconnecting keyboard, doesn't work ideally in addition to touchscreen issues. Sound and mic work and wifi (usually) works."

"You lose the touchscreen, most pen functions, the cameras, and good power conservation in sleep states (meaning sleep on Linux uses almost as much power as leaving the surface "on" but with the screen turned off).

And that's with the patched kernel! (without which the type cover and hardware buttons do not work). Basically it's not at all usable as a tablet, but (with a type cover and a patched kernel) it works perfectly well as a light-weight camera-less laptop. "

"

Working:

1) Type cover with limited multitouch 2) Graphics accel 3) Wifi (mostly works;it will flake out once in a while and require a reboot) 4) Audio 5) Manual backlight control in Gnome

Not working:

1) Camera 2) Touchscreen 3) Pen 4) Sleep 5) Hardware buttons 6) Secure boot (the instructions on the Arch wiki result in the linux bootloader being bypassed every time secure boot is enabled, but it boots fine with Secure boot off) " (the sleep problem in Arch was apparently solved in this thread: https://www.reddit.com/r/SurfaceLinux/comments/3zytfw/status_of_arch_linux_on_sp4/ )

https://www.reddit.com/r/SurfaceLinux/comments/3ssadf/what_is_needed_for_touchscreenpenhardware_button/

intel is working on an opensource 'precise touch' driver (for the SP4 touchscreen):

https://www.reddit.com/r/SurfaceLinux/comments/3z6g9g/installing_debian_on_the_microsoft_surface_pro_4/czxwh8o

(in case that doesnt work, the parent thread talks about an effort to reverse engineer it)

old article on HiDPI?:

http://www.pcworld.com/article/2911509/how-to-make-linuxs-desktop-look-good-on-high-resolution-displays.html

must turn on pressure sensitivity on xournal [10]

palm reject script: https://github.com/freundTech/surface-tools/tree/master/palmreject

some EFI stuff:

https://www.reddit.com/r/SurfaceLinux/comments/43an26/repair_grub_on_surface_pro_4/

some sort of firmware update:

https://01.org/zh/linuxgraphics/downloads/skylake-dmc-1.23?langredirect=1 mentioned in https://www.reddit.com/r/SurfaceLinux/comments/3qz8bo/kernels_for_surface_pro_34book/cwr4f30

on getting the type cover 4 working in the bootloader:

https://www.reddit.com/r/SurfaceLinux/comments/3rb2l5/has_anyone_successfully_installed_ubuntu_1510_on/cwpntj3

" If you choose to encrypt your hard drive here (and you should!), make sure you add hid_multitouch to /etc/initramfs-tools/modules and run sudo update-initramfs -u after you install a custom kernel that supports the new Type Cover. That way you can enter your LUKS password on the go!

    You will also need to modify /etc/default/grub and disable the fancy graphical splash screen: GRUB_CMDLINE_LINUX_DEFAULT="quiet nosplash". You'll have to do this from the recovery menu for the first boot (which is non-graphical and therefore lets you type)."

note: even without the above, there seems to be an OSK in GRUB. This is odd b/c as of this writing, there is no touchscreen driver for GNU/Linux. The GRUB OSK seems to be some sort of special UEFI firmware thing: https://forums.lenovo.com/t5/ThinkPad-X-Series-Tablet-and/Lenovo-Helix-On-Screen-Keyboard-with-Bitlocker/td-p/1613352

repair grub and also get secureboot working (sticky on surfacelinux reddit) (using gummiboot, i think):

https://www.reddit.com/r/SurfaceLinux/comments/43an26/repair_grub_on_surface_pro_4/

repairing grub when it was working then randomly broke: https://www.reddit.com/r/SurfaceLinux/comments/3x2ces/problems_installing_grub_on_surface_book/

todos

when on the bare metal, i7z shows a much lower percentage of time in C6 at idle compared to my old laptop (with a U560 CPU, on which i was running xubuntu). why is this, is it bad, and if so can it be fixed?

as of 5/2017, notes on the trouble with the wifi driver:

https://www.reddit.com/r/SurfaceLinux/comments/6am03n/surface_book_anyone_got_wifi_working_consistently/ https://www.reddit.com/r/SurfaceLinux/comments/6a0dx3/surface_pro_3_and_linux_after_15yrs/

https://www.reddit.com/r/SurfaceLinux/comments/5klbig/sp4_bug_reports_where_were_at/

[–]jfarthing84 1 point 4 months ago

I'll chime in about the wifi issue; it's definitely a thing: https://bugzilla.kernel.org/show_bug.cgi?id=188351.

    permalinkembedsavereportgive goldreply

[–]EnliteNDFarmer?[S] 1 point 4 months ago

Thanks, I added it in!

    permalinkembedsaveparentreportgive goldreply...

After hibernation, wifi do not work but you can run this script that will put it working: /bin/bash

ip link set wlp2s0 down

modprobe -r mwifiex_pcie

modprobe mwifiex_pcie

service network-manager restart

https://www.reddit.com/r/SurfaceLinux/comments/6am03n/surface_book_anyone_got_wifi_working_consistently/

[–]mrchilly0 2 points 11 days ago

If I remember correctly, the Manjaro kernel has the wifi patched. You need to find a Debian kernel patched for your surface.

    permalinkembedsavereportgive goldreply

[–]Jasonmoofang 1 point 4 days ago

There are a number of patched kernels that have this fixed, they are around on this sub - I'm using SuperKernelTouch?+

Not sure if you have any options if you wanna avoid patched kernels.

    permalinkembedsavereportgive goldreply

https://www.reddit.com/r/SurfaceLinux/comments/6a0dx3/surface_pro_3_and_linux_after_15yrs/

Wifi was make or break for me, and after kernel 4.4, it crashes. Sometimes it will work for a short time then lock up, sometimes it would slow to a crawl. mwifiex_pcie module is the culprit, and every bug report I've read fixes one aspect, but more things seem to break. There are patched kernels available up to 4.9.5, and clicking on the original git page forks, I was able to find kernel upgrades.

 4.10 didn't fix the wifi issues, and after a few crashes, I found cass0's copr repo for the sp3. Much like the aur for arch, copr was a great help for software and for finding a functioning kernel. Everything played nice, and after installing the sp3 kernel, fedora functioned well. (https://copr.fedorainfracloud.org/coprs/cass0/surface-pro-3-kernel/) AS of 4/25/17, he had 4.11 built and in the repo.

Vanilla kernels after 4.4 screw with the wifi and make it necessary to patch your kernel, or find a pre-patched kernel. https://wiki.archlinux.org/index.php/Microsoft_Surface_Pro_3 is one of the better sources for setting things up when you start.

[–]sgitkene 2 points 14 days ago

I have the wifi working fine. IIrc, there have been firmware patches for the broadcom chip that powers wifi and bluetooth. Not sure anymore, but there was also a uefi patch.

the aur surfacepro3 kernel is definitely a blessing, but it's no longer maintained.

    permalinkembedsavereportgive goldreply

https://www.reddit.com/r/SurfaceLinux/comments/69atec/surface_book_wifi_dies_randomly/

I've had linux on the surface book since January this year and the wifi dropping off randomly was rare and I could reboot quickly so it was still usable.

However, now I have some serious work I need to get done in Linux which involves downloading large files. If the wifi drops now in the middle of this, I lose a lot of time.

I'm really afraid to make any changes to it now though but was wondering if anyone else has found a workaround to this yet.

Edit: Running Ubuntu 16.04

[–]243MHz 3 points 19 days ago*

For me, I installed TLP and edited /etc/default/tlp to disable the WiFI? power savings mode and added the Ethernet Controller's PCI address to RUNTIME_PM_BLACKLIST. You can find the PCI address with sudo lspci

grep Ethernet it will be the numbers in the first column. For me it was 03:00.0.

My setup is different though, I'm running 17.04 with kernel 4.11. I recommend seeing if the TLP trick works with 16.04 before changing anything else. If you really need to make sure your transfers get done, you can just disable all the TLP power management stuff from the get go just to make sure. Then once you're done, you can slowly tweak settings to see what works best.

It may not be the greatest or most accurate solution, but I found it works for me. Good luck!

Edit: Forgot to say I also disabled bluetooth with sudo systemctl stop bluetooth and sudo systemctl disable bluetooth I'm not sure what impact it has on it, but I was trying to achieve a stable system, and I don't use bluetooth.

Edit Edit: If you want to look at some documentation for TLP configuration, check out http://linrunner.de/en/tlp/docs/tlp-configuration.html

https://www.reddit.com/r/SurfaceLinux/comments/694qq5/linux_on_surfacebook_kernel_bug_with_mwifiex/

Linux on Surfacebook - Kernel Bug with mwifiex (self.SurfaceLinux?)

submitted 20 days ago by ubuntu_on_surfacebk

I'm running 17.04 but can't get the wifi to work for more than a minute without causing the whole system to go into an invalid state after a kernel bug involving mwifiex_pcie. Generally the bug doesn't occur until I start downloading a large file or opening a youtube video. I also got the same issue on 16.04.

I'm running the 4.10.0 kernel. I also tried running an Antergos live usb with the 4.10.13-1 kernel and got the same issue.

Also, I tried installing 4.11rc8 on ubuntu but I can't get it to boot so I went back to the 4.10 kernel

Has anyone seen this error and managed to fix it somehow? I'm confused as to how anyone has managed to get linux running on a surfacebook as it seems this issue ought to be affecting all surfacebooks.

[–]npjohnson1 1 point 20 days ago

Use the proprietary Marvell firmware. I don't have a link, but it's on the subreddit somewhere.

    permalinkembedsavereportgive goldreply

[–]binarytamer 1 point 19 days ago

Maybe this is the right startingpoint: [11]

I had the same with my SP4. Hard locks with soundloops and not even logmessages. But i'm using arch. Since I build an installed this kernel: [12] but branch linux-49 i have no more freezes

    permalinkembedsavereportgive goldreply

[–]mrchilly0 1 point 19 days ago

There are patched kernels just for the surfacebook. The mwifiex issue is a continuing problem, and patching the kernels seems to be the only fix. The "latest and greatest" kernel isn't necessarily the right kernel to be using. The 4.4 kernel didn't seem to have any mwifiex issues, but from that point forward there were problems. If you use arch linux, check aur for a kernel and patches.

    permalinkembedsavereportgive goldreply

[–]binarytamer 1 point 19 days ago

You're right, i tried [13] which gave me freezes and [14] has no ipts patch applied. So i was looking for a kernel with ipts and no freezes

    permalinkembedsaveparentreportgive goldreply

[–]Torcher92 1 point 19 days ago

Yeah the mwifiex kernel module seems to be a general crapshoot for authenticated networks but it's certainly been getting better over time. I've been testing the release version of 4.11 on the Surface Book and it seems to have become generally stable with the occasional disconnect requiring a reboot to regain connectivity but at least not crashing the kernel. The only solution I've found for that is to disable power management which seems to give 99.99% connection stability but even without that it seems to be stable 95% of the time. I'll be pushing 4.11 to the master branch of the kernel mentioned below probably tonight but for the most part the following kernel will become deprecated once Arch Linux pushes 4.11 on their own as there are no unique patches required for stable output. At least until I can figure out and have the time to port touch all the way up to 4.11.

    permalinkembedsavereportgive goldreply

4.11rc6 kernel working well on SP3 (self.SurfaceLinux?)

submitted 1 month ago by CaffinatedOne?

I had to get my SP3 swapped at the MS store yesterday for a hardware issue, so I reinstalled the new one with Fedora 25 and pointed it at the rawhide kernel repo to check progress upstream on 4.11 (4.11.0-0.rc6.git3.2.fc27.x86_64 specifically). It's been surprisingly solid for a "test" kernel.

Multitouch on the SP4 type cover, touchscreen, and the wifi all seem to be working well. In fact, the wifi has been surprisingly solid. I've been running speedtest to see if I can get it to hiccup and haven't had any issues so far (and the speed is really good).

There are still a few things that don't work for me (auto-rotation and suspend notably), but they didn't work before, so that's nothing new.

Anyway, I'm impressed with how 4.11 is shaping up.

[–]nacho_grande 1 point 1 month ago

Using 4.10.9 right now and I'm surprised how much works out of the box now! I have similar specs (SP3 + SP4 TC) and I've confirmed that touchscreen, sp4 tc, camera, and wifi are really solid.

Working on trying to get budgie installed and still running into EFI issues but things are hopeful!

    permalinkembedsavereportgive goldreply

[–]underasail 2 points 29 days ago

May I ask how you got the touchscreen working on the SP4?

    permalinkembedsaveparentreportgive goldreply

[–]nacho_grande 1 point 29 days ago

I have the surface pro 3 with a sp4 type cover keyboard.

---

touchscreen driver

https://github.com/ipts-linux-org/ipts-linux-new/wiki

1

Help! Fedora 25 on SP4 (self.SurfaceLinux?)

submitted 2 months ago by w1nstone

Hi Guys, Looking for help getting fedora working decently on SP4. ... So i managed to get to a better state, by enabling the rawhide kernel (4.11) which now the touch cover works, but now the wifi is flakey, the touchscreen does not work and if i leave it idle so the screen goes blank i have to power it off and back on again.. Can anyone give me an easy ish guide to getting it working on f25?

...

I've hacked my way around installing different kernels etc but have yet to find one where the wifi works reliably, which is a bit of a deal-breaker for me.

...

The only way for me to use Fedora is to disable the wifi and use a USB > Ethernet dongle. Does anyone have any other suggestions? Someone with a little more linux experience? ...

[–]cass00 1 point 2 months ago

Have you tried this kernel?

https://www.reddit.com/r/SurfaceLinux/comments/55v8fq/fedora_copr_repo_for_sp3/

[–]cass00 2 points 2 months ago

Look here. You have to do the same thing with the rawhide repo or any other repo that has newer kernel versions. https://www.reddit.com/r/SurfaceLinux/comments/55v8fq/fedora_copr_repo_for_sp3/d8mcdfx/ permalinkembedsaveparentreportgive goldreply

[–]cass00 1 point 2 months ago

Look here. Increase the amount of parallel installs. Also make sure you use the right kernel in grub later. http://forums.fedoraforum.org/showthread.php?t=309411 permalinkembedsaveparentreportgive goldreply

...

    give goldreply

[–]w1nstone[S] 1 point 2 months ago

Ok thanks i am now on your kernel, wifi so far seems stable and touchpad and mouse work fine, the touchscreen is not working however, should it? thanks again for all the help

    permalinkembedsaveparentreportgive goldreply

[–]cass00 1 point 2 months ago

Hmm, just realized you're not thatsmyhorse. SP4 touchscreen support is not included. This kernel is intended for the SP3. Wifi might be more stable though.

    permalinkembedsaveparentreportgive goldreply

[–]w1nstone[S] 1 point 2 months ago

Haha, well i have to say i have been using it since and other than the touchscreen everything is working fine so far! do you know of a SP4 touchscreen kernel or patch that enables it? thanks again!

    permalinkembedsaveparentreportgive goldreply

[–]w1nstone[S] 1 point 2 months ago

just for additional information, the other problem is if you leave it so the screen goes off - it wont come back on, so it needs to be hard powered off :/

    permalinkembedsaveparentreportgive goldreply

[–]w1nstone[S] 1 point 2 months ago

Hey cass00! me again, dont suppose you could update this to the 4.9 kernel and add intel IPTS support? xD https://github.com/ipts-linux-org/ipts-linux-new/wiki Its just touchscreen and the sleep/dead issue left and otherwise my SP4 is working fine, i am looking at other options for the sleep thing unless anyone has any suggestions? thanks for all the help so far!

    permalinkembedsaveparentreportgive goldreply

[–]cass00 1 point 2 months ago

It's not really that simple, plus I don't own a SP4, plus had some wifi problems with 4.8 kernel so staying 4.7 for now. However there are other kernels for the sp4 floating around here you might want to give a try

    permalinkembedsaveparentreportgive goldreply

---

https://www.reddit.com/r/SurfaceLinux/comments/629eso/surface_book_ubuntu_1704_411rc3_wifi_troubles/

---

sudo ln -s /usr/bin/nodejs /usr/bin/node

(see https://github.com/nodejs/node-v0.x-archive/issues/3911 )

---

sudo systemctl disable sshd

---

Links:

---

sudo vi /etc/NetworkManager?/conf.d/default-wifi-powersave-on.conf

[connection]

  1. wifi.powersave = 3 wifi.powersave = 2 # bayle: changed this for marvell bug

(note: changed that back for a newer kernel, let's see if it works now)

sudo vi /etc/default/tlp

  1. WiFi? power saving mode: on=enable, off=disable; not supported by all adapters. WIFI_PWR_ON_AC=off
  2. WIFI_PWR_ON_BAT=on WIFI_PWR_ON_BAT=off # bayle; for marvell bug on surface
  3. Exclude PCI(e) device adresses the following list from Runtime PM
  4. (separate with spaces). Use lspci to get the adresses (1st column).
  5. RUNTIME_PM_BLACKLIST="bb:dd.f 11:22.3 44:55.6" RUNTIME_PM_BLACKLIST="02:00.0" # bayle changed this for marvell bug

---

sudo vi /etc/modprobe.d/bluetooth-blacklist.conf

blacklist rfcomm blacklist btintel blacklist btrtl blacklist btbcm blacklist btusb

  1. following https://www.reddit.com/r/SurfaceLinux/comments/629eso/surface_book_ubuntu_1704_411rc3_wifi_troubles/dfud2xo/

---

note: if you have to upgrade the kernel to an as-yet-unreleased ubuntu version:

---

change default search engine to Google(?)

---

chmod -R go-rwx ~

---

note: in 16.10, Xorg.0.log is in /home/USERNAME/.local/share/xorg/Xorg.0.log

---

redshift doesn't work with wayland but in addition you must tell GeoClue? to allow it:

sudo vi /etc/geoclue/geoclue.conf

[redshift] allowed=true system=false users=

---

http://www.omgubuntu.co.uk/2017/07/adjust-color-temperature-gnome-night-light

"

    Open dconf-editor (install it if you don’t have it)
    Navigate to org/gnome/settings-daemon/plugins/color/night-light-temperature.
    Enter a custom value

Here are some temperatures values to use as a guide:

    1000 — Lowest value (super warm/red)
    4000 — Default night light on temperature
    5500 — Balanced night light temperature
    6500 — Default night light off temperature
    10000 — Highest value (super cool/blue)

"

i use 3000

---

sudo aptitude install gnome-tweak-tool

gnome-tweak-tool

appearance: global dark theme: on animations: off

power: suspend when laptop lid is closed: off

top bar: battery percentage: on clock shows date: on

workspaces: static workspaces: on

  1. of workspaces: 9

---

https://github.com/windsorschmidt/disable-workspace-switcher-popup

---

note: the command

  gnome-shell-extension-prefs

might be useful someday

---

Use 'dconf-editor'. Select preference org.gnome.shell.extensions.dash-to-dock.pressure-threshold. Set the 'Use default value' slider to OFF. Enter a custom value in the 'custom value' box. The default value is 100 and it seems like values around 500 make it a little less sensitive.

---

do NOT do 'settings->power->turn off wifi to save power->off', this doesn't mean 'turn it off sometimes when power needs to be saved', it means 'go into Airplane Mode right now'!

---

to make the scrollbars bigger in Firefox:

vi ~/.config/gtk-3.0/gtk.css

.scrollbar.vertical slider, scrollbar.vertical slider { min-width: 15px; }

---

sudo aptitude install gnome-tweak-tool /usr/bin/gnome-tweaks appearance->animations off workspaces-># of workspaces static, # of workspaces 9

---

install

https://extensions.gnome.org/extension/758/no-workspace-switcher-popup/

(or mb

https://extensions.gnome.org/extension/959/disable-workspace-switcher-popup/

)

---

dconf-editor org -> gnome -> desktop ->wm ->keybindings edit the switch-to-workspace commands for workspaces 1 through 9. Add values like ['<Primary>F5']

ref. https://askubuntu.com/questions/332264/13-04-more-than-four-workspace-shortcuts-in-gnome-flashback-no-effects

---

ubuntu control panel->privacy->set all to whatever setting gives max privacy, EXCEPT don't 'purge trash and temporary files' (i assume this would delete in-use things out of /tmp ?!?)

---

power->power saving section of page->blank screen: never

---

notifications->notifications popups->off notifications->lockscreen notifcations->off

---