How to access your Ubuntu partition if Windows BitLocker has overwritten your GRUB boot loader

If you dual boot a Linux install alongside Windows 10, you may run into an issue where the Windows 10 BitLocker (full disk encryption) panics and refuses to boot your computer. (For example, if you make a change to the BIOS setting, and BitLocker thinks the hard drive has been moved to a different computer.)

The downside to this is that when BitLocker Panics, it may do so before loading the GRUB 2 bootloader, instead popping up a screen asking for your bitlocker “key”. [You DID save that key file in a safe place, right?]

However, even if you do not have access to your BitLocker key, it is usually possible to access (boot into) your Ubuntu partition (If you have a modern UFEI computer) . There are two possible ways to do this. The first is directly from the BitLocker key recovery screen. You can pick to “skip” this drive, and pick an alternate boot option, and one of the options will likely be your Linux/Ubuntu partition (because the UFEI system still knows about the Ubuntu boot system, even if the Windows Bit Locker has over written the Grub master boot record.

Alternatively, on my laptop at least, you could also interrupt the normal boot sequence and pick the “f12 – pick boot device” menu and the Ubuntu/Linux partition was one of the options (along with booting from a USB drive, etc…)

Once you have Ubuntu booted up, a simple:

sudo grub-install

in a terminal should get the GRUB MBR back where it belongs.

Geeqie image viewer showing only white squares in Ubuntu 21.04

Ubuntu 21.04 uses Wayland (vs X11) and packages a version of the geeqie image viewer that has a bug where this results in displaying white squares instead of images.

https://github.com/BestImageViewer/geeqie/issues/539

The workaround until Ubuntu updates their geeqie package is to go to Edit->Preferences in GeeQie and in the “Image” area enable the option “Use GPU acceleration via the Clutter library (requires restart)”. Once you close and re-start Geeqie, it works! (Assuming your graphics card supports GPU acceleration).

Enabling a maximum battery charge amount (charge threshold) on Lenovo X1 in Ubuntu

Most of the time when using my laptop I am plugged into it’s AC charger. But, I don’t want my lithium-ion battery charged to 100% all of the time, as that is unhealthy for the battery and will lead to it prematurely losing capacity.

My Lenovo X1 Carbon allows you to set a value less than 100 in the:
/sys/class/power_supply/BAT0/charge_control_end_threshold
field and will stop charging your battery if it goes above that amount.

So you can issue a command like the following to prevent your laptop from charging your battery above 80%:

echo "80" | sudo tee /sys/class/power_supply/BAT0/charge_control_end_threshold

(and if you wanted to get fancy, you could tell it to not start charging the battery until it fell below 70% with a command like the following)

echo "70" | sudo tee /sys/class/power_supply/BAT0/charge_control_start_threshold

Then, you would have to unplug the laptop to discharge the battery below 80, and it would just stay there.  If you were planning on taking your laptop somewhere without a power cord, you would want to reset this to 100 and fully charge it before you left.

On the X1 carbon with Ubuntu 21.04, I got some “/sys/class/power_supply/BAT0/charge_control_end_threshold: Invalid argument” type errors when trying to set the end amount to a value lower than the current start amount (or the start amount to a value higher than the current end amount). So if you are messing with one, you should probably set the other appropriately before-hand. For example, I use the following commands, in this specific order to limit to 80 (start charging below 70):

echo "70" | sudo tee /sys/class/power_supply/BAT0/charge_control_start_threshold
echo "80" | sudo tee /sys/class/power_supply/BAT0/charge_control_end_threshold

 

And then to reset to 100 (start charging below 99 or less) I use the commands in this order:

echo "100" | sudo tee /sys/class/power_supply/BAT0/charge_control_end_threshold
echo "99" | sudo tee /sys/class/power_supply/BAT0/charge_control_start_threshold

 

Using this ordering prevents the Invalid argument errors for me.

The above commands reset the default values, and will not survive a reboot. So if you want them to always be active, you can set up a system service which will fire every time your computer reboots by creating a file in /etc/systemd/system/  called charge-threshold.service that looks like the following:

[Unit]
Description=Set the battery charge threshold
After=multi-user.target
StartLimitBurst=0

[Service]
Type=oneshot
Restart=on-failure
ExecStart=/bin/bash -c 'echo 70 | tee /sys/class/power_supply/BAT0/charge_control_start_threshold; echo 80 | tee /sys/class/power_supply/BAT0/charge_control_end_threshold'

[Install]
WantedBy=multi-user.target

Then enable the service with the following:

X1:/etc/systemd/system$ sudo systemctl enable charge-threshold.service
X1:/etc/systemd/system$ sudo systemctl start charge-threshold.service

Making bc use scale=8 (or any other configuration) every time you start it.

If you use bc (a command line calculator) frequently, you probably want floating point division by default. You can type “scale=8” every time you open it, or you can set up some environment arguments to have that be your default every time you open it.

Create a .bc file in your home directory that includes:

scale=8

Edit a file that is executed every time you log in (such as .bashrc) to include the line:

export BC_ENV_ARGS=~/.bc

 

 

How to extract depth images from Pixel 4 / google camera Android phone Portrait images

I have a Pixel 4 android phone which can take “Portrait” images that use a depth map to “blur” the background, focusing on the foreground.

I also have a Looking Glass Factory Portrait holographic display which can display holographic images.

Currently, the HoloPlayStudio software (version 0.3.5 beta) that comes with it only natively supports iPhone portrait photos, but will import RGB+D photos, so I need to extract the depth image (and the original image without the blurred background)

I want to extract a depth map from my android photos so that I can (manually) create RGB+D photos (which have a regular jpeg image next to the corresponding depth map).

This website makes it easy to see/download the different layers embedded in the Pixel 4A “Portrait” mode jpeg image: https://www.photopea.com/

Download the original image and the depth map, glue them together with the depth map on the right and you have an RGB-D image suitable for HoloPlayStudio.

You can also extract the original and Depth Map images using the exiftool.

The command that I found worked was suggested by Phil here:
https://exiftool.org/forum/index.php?topic=11701.0

It extracts the 2nd trailer image, which is the depth image:

exiftool input.jpg -trailer -b | exiftool - -trailer -b > dept.jpg

Incidentally, the FIRST trailer image is the non-blurred original image…

exiftool input.jpg -trailer -b > original_image.jpg

So if you extract the trailer from the original image, it will be the depth map, and you won’t have to chain exiftool together on the command line as above…

exiftool original_image.jpg -trailer -b > depth.jpg

Completely unrelated to extracting depth images, but possibly needed to create holograms from a linear slide movie is the following ffmpeg command that will extract 3 seconds of a video starting at the 2 second mark into PNG image frames:

ffmpeg -ss 00:02 -i <input> -t 00:03 filename%05d.png

Giving away public Wifi with DD-WRT and VPN

Cliff Notes for setting up a public (unencrypted) wifi hotspot to give free internet to guests with minimal risk to “your” network.

Sometimes it’s nice to give people free wifi, especially if you have more bandwidth than you normally use. However, you don’t want random people being able to access your network (or their random network activity to be traced TO your network….)  This is my set of notes for how to set up a 2nd wifi router (which must support the DD-WRT firmware) to act as a free wifi hotspot to untrusted guests.
Continue reading

BEME Erod remote control repair (crystal oscillator replacement)

Electronics inside a remote control

I dropped the remote control for my E-Rod electrically operated drapes, and it stopped controlling the receiver/drape unit. I had another remote that still worked, so I knew the problem was with the remote, and not the drape motor unit. The IR transmitters were still flashing a signal, and on the oscilloscope the signal looked reasonable, but the carrier frequency was at 62.7 kHz.

I eventually traced the problem to the yellow square package, a crystal oscillator, and bought a 10-pack of them for $5 online (with a month wait time….). Replacing the oscillator restored the carrier frequency to 38 kHz and restored proper operation of the remote.

 

Wifi Printing to HP Envy 4500 printer chops off top of page

If you are printing from Ubuntu Linux to an HP Envy 4500 printer and try to print a document with a very small top border, you may find that the printer chops off the very top quarter inch of the page.

The fix I found was to change the paper size from “US Letter (11 x 8.5)” to US Letter Borderless (11.14 x 8.72)” in the print drivers.

I have read several places online where other users with Mac’s and Windows machines have the same issue when printing over wifi, so I feel the issue is with the printer itself (and it’s wifi to printing bridge) as opposed to the Linux drivers.

30 second delays in internet on AT&T U-verse 5268AC FXN modem

My wife and I were running into inexplicable “delays” in our AT&T internet service over WiFi. The speed of the internet would be fine when it worked (speedtests showed good lag/upload/download, etc…) but sometimes the entire internet would “pause” and not respond for 20-30 seconds at a time. Usually not enough time for a connection to time out, but websites would be stuck loading for a long time, or Google Web Apps wold have a “loading….” message for half a minute before recovering (or failing to recover, making us try again with an edit to a document or calendar item…).

After much gnashing of teeth, network profiling, and dark vodoo, we traced the problem down to our devices auto-switching between the 2.4 Ghz and 5 Ghz wifi networks from the router [a Pace DSL modem Model 5268AC FXN ].  The problems happened most frequently when we had about 50% wifi signal strength to the 5G radio, and apparently our devices would see the stronger signal strength on the 2.4 router and switch over to it, then decide to switch back, and so forth.

The root cause of the problem is that the AT&T Uverse DSL gateway / wifi router has both networks with the same SSID (Name) and password, so our devices felt that they were “the same” network, just on different frequencies, and would switch between them frequently.  I have no idea why this would cause a delay of TCP/IP traffic, as a change in the physical/data link layer shouldn’t affect the Network/Transport layers (at least, not for 30 seconds).  Perhaps when using a different brand/model of Wifi Router devices can auto-switch between 2.4 and 5g seamlessly. ( Or perhaps not, our previous cable modem from Spectrum / BrightHouse named the two networks differently (with a 2 and 5 suffix) so that once you connected to a particular network frequency, you stuck with it, but at least we didn’t see this type of issue. )

In any case, the solution was simple. For testing purposes, we fixed the BSSID (mac address of the router) in our client devices to the 2.4 Ghz network, so it would not switch to the 5 Ghz radio. This fixed the problem.  Renaming the 5 Ghz network name to something different from the 2.4 Ghz network on the router would also have the same effect for all devices (for example, using myNetwork2.4 and myNetwork5 as the names).

Installing an Encrypted Partition with LVM dual boot on Ubuntu 16.04

The Ubuntu 16.04 installer has the option to install full disk encryption using LVM if you are erasing everything on the hard drive. However, if you want to dual boot (use some of the hard drive for Windows, and the rest for Linux) the automated installer won’t allow you to automagically use full disk encryption.

You can still make it work, but have to do a lot of manual work using a terminal from the Live CD environment.  Here is a log of what I had to do to get it working for me.

Continue reading