Time Machine backup to NTFS without installing anything

Here’s a way to use an NTFS drive for Time Machine backups, even though it is used for other purposes too.

Find out the NTFS drive volume’s UUID:

1
diskutil info /Volumes/DRIVENAME | grep UUID

Put this in fstab: (Replace ENTED_UUID_HERE with the one you found from the previous command.)

1
sudo echo "UUID=ENTER_UUID_HERE none ntfs rw,auto,nobrowse" >> /etc/fstab

Eject, plug out and back in. MAKE SURE THE DRIVE WAS SAFELY REMOVED FROM WINDOWS, or it will not mount RW in Mac (See dmesg when plugging in).

Find your RW mounted volume

1
open /Volumes

Now we will create a Mac OS disk image on the NTFS volume.

  1. Open Disk Utility
  2. Click New Image
  3. Select a large enough size
  4. Format: Mac OS Extended (Journaled)
  5. Partitions: Single Partition - Apple Partition Map
  6. When done, mount this image

Now we will tell Time Machine to use this disk. It does not show up in the list of available drives, so we will use a command:

1
sudo tmutil setdestination /Volumes/MOUNTED-DISK-IMAGE

(Replace MOUNTED-DISK-IMAGE with the disk image you created, NOT the NTFS drive)

Now just test backing up and see that it works.

Resources:

I use this for backing up to my NAS via SMB/NFS

Mac OS X preferences and config tricks

So I bought a MacBook Pro and wanted to start using Mac OS X as my primary OS. I’m used to Windows/Linux so I have some preferences as to behaviour. There are some things that are kind of annoying, many of which can be fixed. Also there are some tricks that make me more productive.

Command line settings

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Disable trackpad acceleration:
defaults write .GlobalPreferences com.apple.trackpad.scaling -1
# If you have an external mouse, you have to disable its acceleration separately:
defaults write .GlobalPreferences com.apple.mouse.scaling -1
# Always show Finder path bar
defaults write com.apple.finder ShowPathbar -bool true
# Always show Finder status bar
defaults write com.apple.finder ShowStatusBar -bool true
# Show full path in Finder title:
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES; killall Finder
# Dock instant hide/show (disable Dock animation):
defaults write com.apple.dock autohide-time-modifier -float 0.00; killall Dock
# Disable character picker
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
# Speed up animation
defaults write NSGlobalDomain NSWindowResizeTime -float 0.03
# Don’t prompt for TimeMachine when plugging devices
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
# Disable two finger swipe back/forward in browser etc.
defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool FALSE
# Disable local time machine (I have an external backup)
sudo tmutil disablelocal
# Disable SpotLight (saves space and CPU)
sudo mdutil -a -i off

Finder tricks

Go to path:
Cmd + Shift + G

cd ..
Cmd +

cd / “Run” file
Cmd +

Print screen:
Cmd + Shift + 4 (press space to select window)

Keyboard re-mappings

I use the application Karabiner to remap keys.

I like to have the Ctrl-key all the way to the left like on most computers so i swap the Fn and Ctrl keys.

Because I am a developer I also like to use the standard F1-F12 keys without having to press the Fn-key. So when I press the Fn-key I get the Mac key functions instead.

In karabiner

Change Control_L Key (Left Control)
–> Check Control_L to Fn
Change Fn Key
–> Check Fn to Control_L

Change F1..F19 Keys & Funct …
–> Change Functional Key (Brightness, Volume, …)
—–> Functional Keys to F1..F12
——–> CHECK ALL
–> For PC keyboards
—–> Change fn-f1…f12 to brightness control, volume control, etc.
——–> Check fn-f1...f2: Brightness control, fn-f3: Mission control, …

In Mac system preferences -> keyboard -> Use F1,F2 as standard function keys

Other

Remove iTunes Helper from Login Items to prevent auto launch on iPhone connect

http://osxdaily.com/2013/03/01/9-simple-tricks-improve-finder-mac-os-x/
http://osxdaily.com/2011/07/28/turn-off-auto-correct-in-mac-os-x-lion/

References

https://gist.github.com/lexrus/081fa687d8b2475d3367
https://github.com/divio/osx-bootstrap/blob/master/core/defaults.sh

XBMC memory leak remedy

XBMC (now Kodi) has always had a tendency of leaking memory, so that it will eventually thrash and crash. My simple solution to this is to run xbmc inside a for loop instead of directly (just run the script from .xinitrc):

xbmc_angel.sh:

1
2
3
4
5
#!/bin/bash
while [ 1 ]; do
xbmc
nohup sleep 10
done

…And add the following to the local XBMC user’s crontab:

1
0 4 * * * killall xbmc.bin

This will kill XBMC every night at 4 o’clock. And give you a fresh XBMC every day!

How to download videos from Pepper Flash on linux

The new Pepper Flash plugin broke my old script for listing/downloading cached flash/flv videos.

Here is a new script. Uses sudo because the /proc/$PID/fd directory is root only.
This solution is based on silviot‘s solution here: http://superuser.com/questions/622606/how-do-i-save-the-buffered-flash-video-on-linux.

1
2
#!/bin/bash
for FLASHPID in $( pgrep -f chrom ) ; do (for FLASHFILE in $(sudo ls -l /proc/$FLASHPID/fd|egrep "(/tmp/Flash|Pepper Data)" | sed -r 's/^.* ([0-9]+) -> .*$/\1/'); do echo /proc/$FLASHPID/fd/$FLASHFILE; done ); done

Then you can just copy the file into home, like:

1
cp /proc/26493/fd/30 ~/

ReadyNAS RN102 constant activity remedy

My Netgear ReadyNAS RN102 keeps constantly writing to a file /var/readynasd
I don’t want to hold my breath waiting for Netgear to fix this so I took matters into my own hands and implemented a TMPFS fix for my NAS.
What it does is mount /var/readynasd as a tmpfs of 2MB, and copy files to here from /etc/readynas-db on every boot, and copy back every hour, and on shutdown.

Setup instructions

1
2
3
systemctl stop readynasd
mkdir /etc/readynasd-db
cp -a /var/readynasd /etc/readynasd-db/

Edit /lib/systemd/system/tmpdb.service:

1
2
3
4
5
6
7
8
9
10
11
12
[Unit]
Description=Mount RAMFS for SQLITE DB file
Before=readynasd.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c "mount -t tmpfs -o size=2m tmpfs /var/readynasd && cp -a /etc/readynasd-db/readynasd /var/"
#ExecStop=/bin/sh -c "cp -a /var/readynasd /etc/readynasd-db/" # TODO not working
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target

Edit /etc/cron.daily/tmpdb-sync

1
2
#!/bin/bash
cp -a /var/readynasd /etc/readynasd-db/

Now finish up:

1
2
3
chmod +x /etc/cron.daily/tmpdb-sync
systemctl enable tmpdb
reboot

ReadyNAS startup/boot script

I needed to add some startup command to run as root on my Netgear ReadyNAS (RN102). Turns out you don’t have any /etc/rc.local, so I added a new boot script /etc/init.d/local:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /bin/sh
### BEGIN INIT INFO
# Provides: local
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Local scripts
# Description: Local scripts
### END INIT INFO
PATH=/sbin:/bin
. /lib/init/vars.sh
do_start () {
hdparm -S 253 /dev/sdc
}
case "$1" in
start)
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
# No-op
;;
status)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
:

Just type whatever u need inside do_start. I needed to set a higher spindown timeout.

Then:

1
2
chmod +x /etc/init.d/local
update-rc.d local defaults

Tested on ReadyNASOS 6.1.6