Skip to main content

e2fsck & expect

Sometimes fsck won't run non-interactively, because the filesystem is too damaged to choose sane repair defaults. So the first question will be "Abort?" and if we're brave enough, we'd answer with "no" but all the following zillion questions I'd like to answer with "yes", as in "yes do whatever it takes to repair the filesystem, I have my backups around anyway". When doing this, the wonderful tool expect comes to mind. But since I have a severely damaged filesystem only once a year (hah!), I always forget how to use it. Here's an example:

#!/usr/bin/expect -f
set timeout -1
spawn /sbin/e2fsck -v $argv
expect {
        "Clear? "             { send "y" ; exp_continue }
        "Abort? "             { send "n" ; exp_continue }
        "Recreate? "          { send "y" ; exp_continue }
        "Fix? "               { send "y" ; exp_continue }
        "Ignore error? "      { send "y" ; exp_continue }
        "Force rewrite? "     { send "y" ; exp_continue }
        "Root inode not allocated.  Allocate?"   { send "y" ; exp_continue }
        "/lost+found not found.  Create?"        { send "y" ; exp_continue }

TestFailed at TrueCrypt::EncryptionTest::TestXts:831

I should've seen it coming: apparently, TrueCrypt is not working under Snow Leopard, at least not under 64 bit:

$ system_profiler SPSoftwareDataType | grep 64-bit
      64-bit Kernel and Extensions: Yes
$ TrueCrypt --text --test
Error: TestFailed at TrueCrypt::EncryptionTest::TestXts:831
There's a way to create (encrypted) volumes with Disk, but I fail to see how we can use a whole blockdevice as a backing store...

Update: Truecrypt 6.3 is out and even works on 64bit MacOS 10.6 now. However, MacFUSE does not but there's a workaround to fix this.

How to create a shortcut to launch a specific firefox profile on a Mac?

Oh, I'm glad somebody else has already done this and explained how to create an application shortcut for a script. Not only is it tedious to start a different Firefox profile via, but cut'n'paste between the rest of the world wasn't working then. A proper Application Bundle did the trick:

  • Open Script Editor
  • do shell script "/Applications/ -P tmp >/dev/null &"
  • Save as an Application Bundle

  • Now you can drag this thing around and place it e.g. on your Dock.

    ZFS FTW!

    While the upgrade to 10.6 failed miserably, I used the rest of this Sunday to install 10.6 from scratch and now we have:

    $ uname -rv
    10.0.0 Darwin Kernel Version 10.0.0:
    Fri Jul 31 22:47:34 PDT 2009; root:xnu-1456.1.25~1/RELEASE_I386
    I was curious about the ZFS port from, since Apple removed ZFS from the Desktop versions of OSX and lo and behold it's still working:
    # zpool create tank0 /mnt/tmp/file-*
    # time cp -a /opt /Volumes/tank0
    real	0m16.847s
    user	0m0.776s
    sys	0m8.703s
    # zpool list
    NAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT
    tank0                   286M    124M    162M    43%  ONLINE     -
    Well, ~7MB/s is not really fast, but it's working and that's great news for everyone in need of a real filesystem. (I mean, just a few hours ago a journaled, case-sensitive HFS Plus volume wouldn't let me turn on FileVault, this is just ridiculous!)

    In other news, what the heck is this?
    # file /bin/ls
    /bin/ls: Mach-O universal binary with 2 architectures
    /bin/ls (for architecture x86_64):      Mach-O 64-bit executable x86_64
    /bin/ls (for architecture i386):        Mach-O executable i386
    # file /*bin/* /usr/*bin/* | grep -c ppc
    I thought Apple threw those overboard with Snow Leopard?

    Update I: the ZFS MacOS Forge project has been discontinued and Apple seems to kick out ZFS altogether, apparently due to licensing issues.

    Update II: Another post has a few more details/speculations on this issue and someone set up a new mac-zfs git tree - yay!

    Why is located in London, UK?

    While trying to update a few packages, (not only) I noticed that it's very slow to download from this mirror, although it's said to be geographically located near me:

    $ traceroute
    11 (
    17 (
    18 (
    25 (
    26 (
    27 (
    28 (
    So, I guess I have to pick another mirror then.

    Update: A nice fellow on #ubuntu-mirrors was kind enough to answer this one for me: apparently no single US mirror would like to act as because of the high (network) load involved, hence Canonical is providing this "mirror", although it's not really a mirror but their London HQ.

    cc: seems to be a cross-compiler

    Since FreeBSD still ships with csh as its default shell, I tried to compile ksh93 on FreeBSD 8.0-RC1 and this happened:

    # cd /usr/ports/shells/ksh93
    # make install
    ===>  Building for ksh93-20090505
    package: update /usr/ports/shells/ksh93/work/bin/execrate
    package: cc: seems to be a cross-compiler
    package: set HOSTTYPE to something other than the native freebsd8.amd64
    *** Error code 1
    This seems to happen every now and then, but I had to go to another bugtracker to find the solution: apparently, "make install" compiles a small test-program and tries to execute it in /tmp. However, /tmp is mounted noexec and so the test-program fails to execute and in turn the build fails as well. The solution was to mount /tmp with the exec flag:
    $ grep /tmp /etc/fstab 
    tmpfs   /tmp   tmpfs   rw,nosuid,exec,mode=1777,size=134217728 0 0
    Unfortunately, FreeBSD's tmpfs won't allow a remount - we have to umount and the mount again:
    $ mount -u -o exec /tmp 
    mount: tmpfs : Operation not supported
    $ umount /tmp
    $ mount -o exec /tmp
    $ mount | grep /tmp
    tmpfs on /tmp (tmpfs, local, nosuid)

    Snow Leopard, Redmond style

    I know, 10.6 has been out for ages (hah!), but only now I found some time to try this. Unfortunately, with no luck:

    Mac OS X cannot be installed on Macintosh HD, because this disk
    cannot be used to start up your computer.
    Huh? I just started from this very "Macintosh HD"! Turns out, others had this problem too and there are a few good and silly articles on the net, but all hints failed so far. Attempting to resize the startup disk's partition via DiskUtility brought up another error message:
    MediaKit reports no such partition
    Of course, by then I remembered I had rEFIt installed which might confuse DiskUtility et al. - but even after removing it (and a few reboots later), both errors stuck. Although I have a GUID partition table, I tried to update the MBR of my startup disk but I doubt it did anything at all:
    $ sudo fdisk -u /dev/rdisk0
    fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory
    So here we are, the seventh incarnation of OS X but the error messages still suck and are not usable at all :-\

    We're sorry, Alan Turing

    Apparently the British Prime Minister had to apologize for how Alan Turing was treated for being gay. While it's good to hear they don't approve now, the statement feels a bit blurry in the end:

    For those of us born after 1945 [...] it is hard to imagine that our continent
    was once the theatre of mankind’s darkest hour. It is difficult to believe [...]
    people could become so consumed by hate - by anti-Semitism, by homophobia,
    by xenophobia and other murderous prejudices
    Dude, Turing has been convicted in 1952 in the UK, and treated in the same homophobic ways the Nazis did before 1945 in Germany! And same-sex marriage is still not possible in the UK - how's that not homophobic, hm? Instead they create things like "civil partnerships" - equality, but not really, u know. Did anyone say butt buddies? Fuck you, guys! Gah, this makes me angry and depressed at the same time. Grrr.