Search

Thursday, February 27, 2020

OpenVMS System Disk Full?

DUA0 full? Audit log grows without limit, Operator logs keep eating away space as well.

Do this:

$ SET AUDIT/SERVER=NEW_LOG
$ REPLY/ENABLE/TEMP
$ REPLY/LOG
$ PURGE DUA0:[000000...]*.*

That's it. End of this post.

Monday, February 17, 2020

Install and Dual-Boot Linux on 17 inch MacBook Pro - Ubuntu MATE 18.04.3 LTS (Bionic) with Trackpad gestures, APFS File System support, MacBook Fan Speed Control and more


Supratim Sanyal's Blog: Ubuntu MATE Linux on 17" Apple MacBook Pro A1297 Late 2011 Intel Core i7 2.4 GHz 16 GB RAM 1 TB SSD
Ubuntu MATE on 17" Apple MacBook Pro A1297


In this post:
  • Recommended Additional Hardware Items
  • Booting Ubuntu MATE Linux on MacBook Pro from USB
  • Configuring Trackpad Gestures
    • White Screen on Rebooting after installing Linux
  • MacBook Pro Linux Fan Speed Control
  • Mount Mac OS X APFS File System on Linux for MacBook Pro
  • Notes on taking image backup and restoring dual-boot Mac OS X and Ubuntu storage:
    • Zeroing out free space for better disk image compression (smaller backup size)
      • Zero Out Free Space on MacOS X APFS and Unused Disk Partitions
      • Zero Out Free Space on Linux ext4 Disk Partitions
    • Taking Clonezilla Live Disk Image Backup
    • Restoring from Clonezilla Live Disk Image Backup
    • What to do if the EFI boot table is corrupted resulting in unbootable system

My old faithful MacBook Pro 17" model 8,3 (A1297) with Intel Core i7 4-core 2.4 GHz processor and recently-upgraded 16 GB RAM and 1 TB SSD storage continues to perform spectacularly with OS X High Sierra.

Supratim Sanyal's Late 2011 17" MacBook Pro - Late 2011 17" - MD311LL/A - MacBookPro8,3 - A1297 - 2564


However, long curious about Linux on MacBook Pro, I re-partitioned the SSD and installed Ubuntu MATE 18.04.4 LTS (Bionic Beaver) in a dual-boot configuration with rEFInd as boot-manager. The basic steps of installing Linux alongside Mac OS X are discussed with great detail in numerous posts in the world-wide web. Instead of repeating all of that, this post attempts to consolidate some notes and actual terminal sessions I captured during getting the Trackpad, backlit keyboard lights and fan speed control to work, and backup and restoration of the dual-boot disk image.

No information in this post is new or original; I followed the path laid by others who have lent significant time and effort to get all this working. My goal is to simply consolidate all the information I found useful in one place so that I do not have to go searching again if I have to ever re-do these.

While at it, I grabbed an OS X Catalina wallpaper for the Ubuntu MATE desktop, as you can see in the first screenshot at the top.

Recommended Additional Hardware Items


I used the following two items of hardware for the installation. Most people who want to install Linux everywhere are likely to already have these lying around.

1) You will need to connect to the internet when installing Linux on your MacBook Pro to fetch proprietary drivers and updates. The built-in MacBook Pro wifi adapter will not work without the proprietary drive that is available online. To get out of this catch-22 situation, either plug in a physical Ethernet network cable (yes, the A1297 has a gigabit RJ-45 Ethernet port and three USB 2.0 ports among its many ports and connectors, and a Superdrive dual-layer DVD writer too for that matter), or do what I did - get a cheap USB wifi adapter with Realtek chipset that Linux is very comfortable with. These are easily found for under $10 at Amazon.

2) You will need a USB mouse till you get trackpad gestures to work (instructions below). I used a cheap USB wireless / cordless mouse that was lying around.

All three USB ports taken: wifi adapter with Realtek chipset, USB dongle of chordless mouse and Linux boot USB stick
All three USB ports taken: mini USB wifi adapter with Realtek chipset, cordless USB mouse dongle and Linux boot USB stick


Booting Ubuntu MATE Linux on 17" MacBook Pro from USB


I partitioned the 1 TB SSD into three partitions:
  1. 250 GB for MacOS X APFS
  2. 250 GB for Linux ext4 (Ubuntu Mate 18.04)
  3. 500 GB Unused space formatted as exFAT file system

Here is what my SSD partitions look like.


Dual Boot MacBook Pro Disk Partitions - MacOS X and Linux


After you have partitioned the storage and installed rEFInd, boot from your newly etched Ubuntu MATE bootable USB stick and choose "Install Ubuntu MATE".  After a brief but sinister-looking period of white screen (be patient), the usual Linux bootup text will start scrolling by.

Then it will get stuck.

Power-cycle and start again, but this time use grub to edit the kernel parameters in the boot command line to add the three parameters:

noapic noacpi nomodeset



Press F10 to boot with the above Kernel boot parameters, and you will boot successfully right into the Ubuntu MATE installer. Happy installing!


Supratim Sanyal's Blog: Installing Ubuntu MATE Linux on 2011 17" MacBook Pro 1297 Late 2011 17" - MD311LL/A - MacBookPro8,3 - A1297 - 2564



Configuring Trackpad Gestures


Thanks to Thanh Tran's "Making the best of MacBook Air touchpad on Ubuntu: A guide to mtrack driver and make use of the multi-touch touchpad on Linux", I am able to use trackpad gestures to operate the MATE user interface. Tap-to-select, two-finger right-click and scroll, three-finger move/resize and all the basic gestures work with the mtrack software. Advanced gestures also work with additional xbindkeys and xdotool configurations, and the dispad tool helps with accidental taps on the trackpad while typing on the keyboard. Here is the full list of supported MacBook Pro trackpad gestures on Ubuntu Linux from Tran's post:
  • Left mouse click with one finger tap; right mouse with two fingers tap; middle mouse with three fingers tap
  • Scroll with two fingers (both horizontal & vertical)
  • Drag with three fingers
  • Swipe left and right with 4 fingers will simulate mouse button number 9 & 8. This means I can navigate back and forth in browsers and many applications
  • 4 finger swipe up: switch to next workspace
  • 4 finger swipe down: switch to previous workspace
  • While holding ctrl, 4 finger swipe up: Move active window to next workspace
  • While holding ctrl, 4 finger swipe down: Move active window to previous workspace
  • Pinch scaling down (move 2 fingers closer): trigger ctrl and - combination, which is zoom out in browsers and reduce font size in some apps
  • Pinch scaling up (move 2 fingers away): trigger ctrl and = combination, which is zoom in in browsers and enlarge font size in some apps

White Screen on Rebooting after installing Linux


You may get stuck at a white screen when you reboot the first time time after installing Linux. The reason seems to be Linux installation somehow confusing rEFInd boot loader.

The solution is to power the MacBook Pro off and back on again holding down the Option key as soon as the audible chime starts playing. This will allow you to boot from "Macintosh HD" into Mac OS X. You can then reinstall rEFInd. When you restart again, you should see the rEFInd boot devices screen. From this point onwards, every time you reboot you should be able to boot into Linux or Mac OS X using the rEFInd boot loader.

Mac OS X and Linux on MacBook Pro rEFInd boot loader operating system selection screen
Mac OS X and Linux on MacBook Pro rEFInd boot loader operating system selection screen


Here is the terminal session from installing mtrack, dispad, xbindkeys and xdotool.




MacBook Pro Linux Fan Speed Control


The Fanny notification center widget and menu bar application for Mac OS X tells me the fans of my MacBook Pro run mostly around the minimum speed of 2,000 RPM with the CPU and GPU temperatures hovering in the 50 - 60 degrees Celsius range after a couple of hours of use.

Fanny on Mac OS X reports Fan with and CPU and GPU temperatures at real-time

When booted into Ubuntu MATE Linux, it appears the fans run at their maximum speed all the time even when not really needed. A dynamic fan speed control based on thermal sensors like that built into OS X is needed.

The solution is to simply install the daemon called "macfanctld" using the package of the same name from the usual Ubuntu MATE 18.04 Bionic Beaver repositories. No further configuration is necessary after the installation.

$ sudo apt-get install macfanctld
$ systemctl status macfanctld

You can examine the log file at /var/log/macfanctl.log. If you wish you can of course tweak the default configuration file /etc/macfanctl.conf. Here is my (default) configuration file.

$ cat /etc/macfanctl.conf
# Config file for macfanctl daemon
#
# Note: 0 < temp_X_floor < temp_X_ceiling
#       0 < fan_min < 6200

fan_min: 2000

temp_avg_floor: 45
temp_avg_ceiling: 55

temp_TC0P_floor: 50
temp_TC0P_ceiling: 58

temp_TG0P_floor: 50
temp_TG0P_ceiling: 58

# Add sensors to be excluded here, separated by space, i.e.
# exclude: 1 7
# will disable reading of sensors temp1_input and temp7_input.

exclude:

# log_level values:
#   0: Startup / Exit logging only
#   1: Basic temp / fan logging
#   2: Log all sensors

log_level: 0


Here is what my /var/log/macfanctl.log:

$ cat /var/log/macfanctl.log
Using parameters:
        temp_avg_floor: 45
        temp_avg_ceiling: 55
        temp_TC0P_floor: 50
        temp_TC0P_ceiling: 58
        temp_TG0P_floor: 50
        temp_TG0P_ceiling: 58
        fan_min: 2000
        log_level: 0
Found applesmc at /sys/devices/platform/applesmc.768
Found 2 fans.
Found 29 sensors:
         1: TB0T - Battery TS_MAX Temp
         2: TB1T - Battery TS1 Temp
         3: TB2T - Battery TS2 Temp
         4: TC0C - ?
         5: TC0D - CPU 0 Die Temp
         6: TC0E - ?
         7: TC0F - ?
         8: TC0J - ?
         9: TC0P - CPU 0 Proximity Temp
        10: TC1C - ?
        11: TC2C - ?
        12: TC3C - ?
        13: TC4C - ?
        14: TCGC - ?
        15: TCSA - ?
        16: TCTD - ?
        17: TG0D - GPU Die - Digital
        18: TG0P - GPU 0 Proximity Temp
        19: THSP - ?
        20: TM0S - ?
        21: TMBS - ?
        22: TP0P - ?
        23: TPCD - ?
        24: TW0P - ?
        25: Th1H - ?
        26: Th2H - Right Fin Stack Proximity Temp
        27: Tm0P - Battery Charger Proximity Temp
        28: Ts0P - Palm Rest Temp
        29: Ts0S - ?

As you can see, Apple's designers put in an impressive number of temperature sensors for great thermal management. I particularly like the Palm Rest temperature sensor. assuming Palm Rest is empty aluminum surface on the two sides of the trackpad.


Mount MacOS X APFS File System Partition on Linux for MacBook Pro


Apple introduced their Apple File System (APFS) with macOS High Sierra, replacing the aging HPS+ file system. To access the APFS file system from Ubuntu Mate Linux, I followed Alistair Ross' instructions at How to mount macOS APFS disk volumes in Linux with minor modifications (e.g. bilding from source in a directory under my home directory instead of /tmp and using a mount-point right under root instead of /mnt since I keep /mnt free for other mounts.

Once it's done, I can see my OS X files under a "Users" directory under "root":

$ ls -l /macos-partition/
total 0
drw-r--r-- 1 root root  0 Feb 12 19:04 private-dir
drwxr-xr-x 1 root root 28 Feb  2 00:42 root


Here is the installation log.





Notes on taking image backup and restoring dual-boot Mac OS X and Ubuntu storage



I use Clonezilla for taking disk image backups of all of my systems at SANYALnet Labs.


Zeroing out free space for better disk image compression (smaller backup size)



It is necessary to zero out unused hard disk / SSD storage space to minimize Clonezilla image backup sizes. For my MacBook pro, I have three partitions that I have to zerofree.

MacBook Pro Dual-Boot Hard Disk SSD Partitioning


The first partition in blue is the MacOS X APFS partition. The second partition in pink is my Linux ext4 partition. The third partition in orange is an unused empty partition for future use which I formatted to exFAT for now.


Zero Out Free Space on MacOS X APFS and Unused Disk Partitions



MacOS X - Zero Free disk space


The Disk Utility command-line tool included with MacOS X is capable of wiping unused disk space by writing zeroes. To identify the partition names to run the tool on, simply do a:

$ ls -l /Volumes
total 256
lrwxr-xr-x  1 root    wheel       1 Feb 15 16:47 Macintosh HD -> /
drwxrwxrwx  1 localuser  staff  131072 Jan  1  1980 unused

This tells me I can use the Disk Utility to zerofree unused space on MacOS X APFS filesystem volume "Macintosh HD" as well as unused exFAT space volume "unused". In the "diskutil secureErase" commands below, the "freespace" parameter indicates we want to only overwrite free disk space without affecting existing files, and the level parameter "0" indicates we want to overwrite with just zeroes without performing more stringent multi-pattern secure disk wipe operations.

$ diskutil secureErase freespace 0 /Volumes/Macintosh\ HD
$ diskutil secureErase freespace 0 /Volumes/unused

Zero Out Free Space on Linux ext4 Partition


To zero out unused space on the Linux ext4 file system, boot into Linux and execute the usual simple shell script for zerofree. Everything in my Linux partition is under the file system's root directory ("/"), so this works fine.

#!/bin/bash
# ---
# zerofree.sh (Ubuntu MATE 18.04 on Apple MacBook Pro 17")
#
# Zeroes Out Unused Disk Space for subsequent image backup
# To execute: ./zerofree.sh
#
# Supratim Sanyal - supratim at riseup dot net
# See http://supratim-sanyal.blogspot.com/2016/12/zero-out-free-disk-space-on-virtual.html
# ---
cd /tmp/
cat /dev/zero > zero.delete-me
sync;sync;sync
#
rm -fv zero.delete-me 
sync;sync;sync
exit 0

Taking Clonezilla Live Disk Image Backup


I use a 2 TB external USB hard disk as Clonezilla disk image repository on which a 500 MB partition has bootable Clonezilla Live. The remaining 1.95 TB space is in a 2nd NTFS partition used to save the disk images after booting from Clonezilla Live from the first partition.

When preparing your Clonezilla USB boot disk, make sure you download the AMD64 version of Ubuntu-based Clonezilla Live. This is required to support the uEFI boot architecture used by modern Apple Macintoshes. If you are unfamiliar with Clonezilla, instructions for preparing a Clonezilla Live USB boot disk are available here.

As of this post, I am using the Disco release of Clonezilla Live AMD64 Alternate Ubuntu edition.

Insert the external Clonezilla USB boot disk, and power the MacBook Pro on. As soon as you hear the chime, hold down the Option (alt) key. Then use the MacBook Pro's boot device selection screen to boot from uEFI partition on the USB drive. Nothing will seem to happen for a little while but Clonezilla Live will eventually boot and start (patience!).

Follow the Clonezilla Live menu system to create a whole-disk image backup on the other bigger partition of the external USB disk. Since Clonezilla does not understand the APFS file system yet, it will take a raw backup of the entire partition. Clonezilla will, however, handle the ext4 and exFAT partitions correctly. Since we zeroed out unused space on all partitions, the backup size will pretty much be the smallest you can get (it is in the range of 64 GB total for my three partitions, but obviously it depends on how much data you actually have).

When backup is complete, use the Clonezilla Live prompt to power the computer off and remove USB storage devices. You can power the MacBook Pro back up at this point and boot into either Linux or MacOS X as you wish usung rEFInd boot manager.


Restoring from Clonezilla Live Disk Image Backup


This is where things get tricky if you are not careful.

On attempting a disk restore operation from the disk image using Beginner Mode settings, Clonezilla Live realized there is an ext4 partition, assumed a Linux system and left me with a unbootable computer. It turns out Clonezilla Live does funky things to the GPT (GUID Partition Table) like generating a initrd, write an MBR and, worst of all, change the GUID of my MacOS X partition to FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF.

Corrupted GPT after CloneZilla Live Disk Restore
Bad Corrupted GPT after CloneZilla Live Disk Restore in Beginner Mode with default options

Luckily, my MacBook Pro's symptoms were close enough to the issue discussed here for the solution to work.

To avoid such a situation, choose the Expert Mode of operation of Clonezilla Live when restoring the image backup, and make sure:

(A) the following checkbox is checked:

[*] Do not update syslinux-related files after restoring

(B) the following checkbox is not checked:

[ ] Write MBR (512 B) again after image is restored

CloneZilla Live advanced parameters for restoring mode
CloneZilla Live expert mode parameters for restore operation (Source: CloneZilla official documentation)

What to do if the EFI boot table is corrupted resulting in unbootable system


If, due to a faulty Clonezilla Live disk restore operation, the system becomes non-bootable, this post at stackexchange answered by klanomath and edited by David Anderson will rescue you. I am reproducing the information from there below, just in case the original post disappears. My MacOS X partition (disk0s2) is the same as that post, so no adjustment was needed there. But I did have to adjust the Start and Size numbers based on my 250 GB partitions which are different from the post. The steps below are to be performed with the MacBook Pro in Internet Recovery Mode activated by holding down Command (⌘), Option (alt) and R keys at the power-on chime.

The proper GUID of APFS partitions is 7C3457EF-0000-11AA-AA11-00306543ECAC.
To get your APFS partition back remove partition disk0s2 and restore it with the proper type: 
Open in the menubar > Utilities > Terminal
get some details: 
diskutil list #below I assume the disk identifier of the internal disk is disk0
gpt -r show disk0 
Unmount disk0: 
diskutil umountDisk disk0 
remove and restore the 2nd partition: 
gpt remove -i 2 disk0
diskutil umountDisk disk0
gpt add -i 2 -b 409640 -s 372637568 -t 7C3457EF-0000-11AA-AA11-00306543ECAC disk0
 
verify disk and partition: 
diskutil list
diskutil verifyDisk disk0
diskutil verifyVolume disk0s2 
Your Mac should be able to boot despite the MBR.

If you want (or have) to restore the pMBR because the MBR is stubborn/blocks the modification of the partition table do the following: 
get all disk details: 
diskutil list #below I assume the disk identifier of the internal disk is disk0
gpt -r show disk0 
replace the GUID partition table: 
diskutil umountDisk disk0
gpt destroy disk0
gpt create -f disk0 
re-add all previous partitions visible in the last gpt -r show disk0 output:
gpt add -i 1 -b 40 -s 409600 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B disk0
gpt add -i 2 -b 409640 -s 372637568 -t 7C3457EF-0000-11AA-AA11-00306543ECAC disk0
gpt add -i 3 -b 373047208 -s 262144 -t 426F6F74-0000-11AA-AA11-00306543ECAC disk0
gpt add -i 4 ...
gpt add -i 5 ... 
If you get a resource busy error after one of the steps, just unmount disk0 again with 
diskutil umountDisk /dev/disk0 
Finally verify disk and partitions: 
diskutil list
diskutil verifyDisk disk0
diskutil verifyVolume disk0s1
diskutil verifyVolume disk0s2
diskutil verifyVolume disk0s3
#disk0s4 & disk0s5 can't be verified with the default macOS tools because the latter is a Linux swap and the former a Linux partition, probably with ext4

Recommended Products from Amazon