Quickie: Keeping my OSX downloads folder clean

Tuesday, May 4th, 2010

My Downloads folder consistently gets large and cluttered. I considered an app like Hazel but it seemed like overkill.

I added the following alias to my .bashrc file:

alias clean_downloads="find ~/Downloads -mtime +30 -maxdepth 1 -print -exec rmtrash '{}' ';'"

which depends on the free tool ‘rmtrash‘ being installed — a command line way to elegantly move files to the OSX-standard trash can.

The nice thing is when I think ‘that looks messy’, I just run clean_downloads, and get a nice list of all the things that it just “trashed” — so, worst case, I can go and fish it out right then and there. Actually a bit nicer than things magically getting trashed while I’m not looking.

Getting around tmpfs ‘noexec’ problems

Tuesday, March 16th, 2010

In general, running your /tmp (or /var/tmp) without the execute bit set is a good idea. And sometimes, you don’t have a choice — for example, when running in a hosting environment running Virtuozzo.

You’re liable to see a mount that looks like this:

$ mount | grep noexec
/dev/simfs on /tmp type simfs (rw,noexec)
/dev/simfs on /var/tmp type simfs (rw,noexec)
devpts on /dev/pts type devpts (rw,nosuid,noexec)

However, sometimes that’s a problem, for example if you run the fantastic checkinstall tool to package software. You might see an error message like this:

/usr/bin/installwatch: /var/tmp/tmp.SuogJyYftZ/installscript.sh: /bin/sh: bad interpreter: Permission denied

The noexec permission has gotten us. How to work around it?
Here’s a quick, easy to roll back method:

# make a new temporary directory for this use
mkdir ~/tmptmp
# use mount --bind to overlay this on our 'real' /var/tmp for now
$ sudo mount --bind ~/tmptmp /var/tmp
# do your work
$ sudo checkinstall make install
# restore the natural order to the universe
$ sudo umount /var/tmp

You could also (potentially) remount /tmp without that option temporarily, but that isn’t always possible. (See ‘virtuozzo’ above.)

Adding iSCSI exports to OpenSolaris for remote Time Machine

Monday, March 15th, 2010

There are 3 ways to Time Machine over the network (that I know of)

  1. Use a Time Capsule
  2. Run Snow Leopard Server, which allows you to set remote drives as Time Machine volumes
  3. Mount the iSCSI share via an “initiator”, and use it like it was a normal hard drive.

I’m not sure I’d want to use the iSCSI option with a laptop, so I use a hybrid of the second and third options.

I’m running Snow Leopard Server on a Mac Mini with limited disk space. I’ve got a large server running OpenSolaris about which I blogged previously.

Here are the brief steps you need to take to get it working.

On the Snow Leopard Server, install the ISCSI initiator from GlobalSan.

On your OpenSolaris server, make sure you’ve installed the support packages needed.

pkg install SUNWiscsi SUNWiscsitgt

Now, from one of your available disk pools, create the virtual hard drives for your servers to mount, (making sure you make them about 1.5x larger than the disks you’re trying to back up, so you can get historical information from them.

zfs create -o shareiscsi=on -s -V 160GB mypool/laptop_tm
zfs create -o shareiscsi=on -s -V 140GB mypool/server_tm

To find out what the “target ID’s” are, run this:

iscsitadm list target

shows the target names to paste into the initiator.

You can follow the instruction at this blog on sun.com which has screenshots of the rest of the process.

At this point the drives are just like regular disks, from the perspective of your Mac (desktop or server) — and can be formatted and used for Time Machine. Very convenient and the data that you’re backing up will be in the safe, safe hands of ZFS in the event of a disk failure.