MacBook Ubuntu Overheating

I dual boot Ubuntu 14.04 LTS on my work MacBook Pro (2015?). The SSD makes it a pretty quick dev machine but out of the box temperature control doesn’t seem to work. There are lots of outdated old forum posts about manually setting the fan speed. In 2018 all you need to do get fan control working is install macfanctld!

$ sudo apt install lm-sensors
$ sensors
Adapter: Virtual device
temp1: +35.3°C

Adapter: ISA adapter
Physical id 0: +73.0°C (high = +84.0°C, crit = +100.0°C)
Core 0: +73.0°C (high = +84.0°C, crit = +100.0°C)
Core 1: +69.0°C (high = +84.0°C, crit = +100.0°C)
Core 2: +71.0°C (high = +84.0°C, crit = +100.0°C)
Core 3: +68.0°C (high = +84.0°C, crit = +100.0°C)

Install fan control daemon:

sudo apt install macfanctld

Instantly the fans spin up and the temperature quickly drops down to normal:

$ sensors
Adapter: Virtual device
temp1: +33.9°C

Adapter: ISA adapter
Physical id 0: +54.0°C (high = +84.0°C, crit = +100.0°C)
Core 0: +54.0°C (high = +84.0°C, crit = +100.0°C)
Core 1: +50.0°C (high = +84.0°C, crit = +100.0°C)
Core 2: +50.0°C (high = +84.0°C, crit = +100.0°C)
Core 3: +50.0°C (high = +84.0°C, crit = +100.0°C)

Corrupt USB Flash Drive Data Recovery on Mac OS X Mavericks

An oldy but a goody…

  • Identify the device node
    Remove the drive from the computer then run
    $ ls /dev/rdisk*
    Insert the drive and re-run the command, for me a new device /dev/rdisk3 shows up
  • Checkout what might be wrong
    $ sudo dmesg | tail
    disk3s1: I/O error.
    0 [Level 3] [Facility] [ErrType IO] [ErrNo 5] [IOType Write] [PBlkNum 14988] [LBlkNum 0]
    0 [Level 3] [Facility] [DevNode /dev/disk3s1] [MountPt /Volumes/Lexar]
  • Make an image of the disk
    $ dd bs=64k if=/dev/rdisk3 of=./recovered.dmg conv=noerror,sync
    478816+0 records in
    478816+0 records out
    31379685376 bytes transferred in 1278.080407 secs (24552200 bytes/sec)
  • Try mount the created image in Finder (unlikely)
  • Install foremost for data carving
    $ brew install foremost
    ==> Downloading
    ######################################################################## 100.0%
    ==> make mac
    🍺 /usr/local/Cellar/foremost/1.5.7: 5 files, 84K, built in 29 seconds
  • Run foremost on the image
    $ foremost -i ./recovered.dmg -o ./recovered
  • Browse the glorious recovered data!

Bash – Loops using pipe and read

Perform some operation for every line in the output of a command, e.g. add .txt to every file in a directory:

ls /var/* | while read fname; do cp $fname $fname.txt; done

Instead of:

for fname in `ls /var/*`; do cp $fname $fname.txt; done

Neat trick I actually picked up in a job interview. Easier to read if the original command is long as it avoids the backticks, and bash is all about readability, right?? 🙂

Dead iMac Hard Drive Recovery

This is a tale of loss, love but in the end, happiness. My girlfriends 20″ iMac hard drive recently died, although the computer was still under warranty the hard drive could not be easily recovered by ‘MagnumMac’ and if it is replaced under warranty you don’t get to keep the old drive! The hard drive contained the last 3 years photos and Uni work. There was no choice but to pay for a replacement and keep the broken drive. (For anyone who’s iMac starts going slow for a couple of months, then started making a clicking sound, a ‘plonking’ sound and the inability to boot will follow.) These are the steps I used to recover the drive, only loosing about 20 files in 160GB. Note that this drive was VERY dead, it would still spin but would not mount, it had a hardware fault and would ‘plonk’ off if you tried to do so.

  • Put the drive into an external SATA enclosure and connect it to a computer with more free space than the entire drive capacity.
  • Hopefully the disk will mount, if not open /dev directory and try find it. For me it was rdisk3. Now create an image of the disk using dd, from the terminal type:

    dd bs=64k if=/dev/rdisk3 of=/recovered.dmg conv=noerror,sync

    The original post I found used a blocksize of 512, but this was going to take about 25 days to copy using USB, I used 64k which only took about 3 hours. You will end up with a .dmg file.

  • Get DiskWarrior , it REALLY WORKS so I would advise buying it if you have the money. To use DiskWarrior the .dmg must be mounted. As mine wouldn’t mount I had to attach it using the command:

    hdiutil mount -nomount -readwrite /recovered.dmg

  • From DiskWarrior use the “Rebuild” option on the image which will now be in the popup menu. It only takes a minute and will come up with a Report. From the report click “Preview” and it will mount your files as a drive on your desktop. BACKUP YOUR DATA and enjoy!

Websites which made this all possible: