Skip to 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 Utility.app, 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 Terminal.app, 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/Firefox.app/Contents/MacOS/firefox -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 macosforge.org, 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
    579
    
    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 us.archive.ubuntu.com 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 us.archive.ubuntu.com
    [...]
    11  ae-94-94.ebr4.SanJose1.Level3.net (4.69.134.253)
    [...]
    17  ae-82-82.ebr2.Washington1.Level3.net (4.69.134.153)
    18  ae-44-44.ebr2.Frankfurt1.Level3.net (4.69.137.61)
    [...]
    25  ae-42-42.ebr2.London2.Level3.net (4.69.141.194)
    26  ae-26-56.car2.London2.Level3.net (4.68.117.176)
    27  gi1-0-1.oxygen.canonical.com (195.50.121.2)
    28  drescher.canonical.com (91.189.88.40)
    
    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 us.archive.ubuntu.com 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)