pigfoot’s weblog

We should forget about small efficiencies — Donald Knuth

Archive for the ‘Unix’ Category

Tune your ext2/3 filesystem

Tune your ext2/3 filesystem, from Gentoo Weekly Newsletter (October 17th, 2005)

ext2/3 are the main filesystems for a large amount of users but what a lot of people don’t know is that you can get almost Reiser4 speed out of it without any of the instability they’d associated with Reiser4. One of the great features of ext2/3 is the ability to tune it by adjusting various parameters. The one we are going to modify here is dir_index which essentially uses hashed b-trees to speed up lookups in large directories.

Let’s take some precautions, first of all by finding out if some of those parameter are already enabled, by running
# tune2fs -l /dev/hdXX

(replacing XX with your drive and partition your ext2/3 filesystem resides in). If you don’t see dir_index in the list then we can enable it, and just in case you do see dir_index in ‘Filesystem features’ then you have either enabled it already or it was automatically enabled for you.

You are going to need a Gentoo LiveCD because changing parameters on mounted filesystems can cause problems, so in the interest of safety we are booting off the CD. At the start phase the Gentoo install system is booted into what’s called a “ramdisk” which is where the files needed are put into RAM to be used. mke2fs, tune2fs and other parts of the e2fsprogs package will be present at this stage.

Now let’s turn on the feature with
# tune2fs -O dir_index /dev/hdXX

Now run e2fsck with the -D option to have the directories optimized:
# e2fsck -D /dev/hdXX

Do that on any ext2 or ext3 partition and then reboot. You should notice the difference straight away.

Popularity: 10% [?]

  • 0 Comments
  • Filed under: IT, Linux, Unix
  • OpenBSD: Improved Memory Allocation, Beta Testing 3.8, from KernelTrap.

    OpenBSD creator Theo de Raadt described a number of modifications to how OpenBSD allocates memory:

    • mmap system call return a random memory address, as well ensuring “that two objects are not mapped next to each other; in effect, this creates unallocated memory which we call a ‘guard page’”
    • malloc function was updated to use mmap to obtain memory
    • free function was updated to immediately return memory to the kernel and un-allocate it from the calling process

    Theo points out that these changes have a couple of significant impacts. He explains that for over a decade efforts have been made to find and fix buffer overflows, and more recently bugs have been found in which software is reading before the start of a buffer, or beyond the end of the buffer. With these recent memory allocation changes, such an attempt will cause the application to coredump with a SIGSEGV signal.

    Additionally, now that memory is unmapped as soon as it is freed, any attempt to access freed memory will also cause the application to coredump with a SIGSEGV signal.

    Popularity: 15% [?]

  • 0 Comments
  • Filed under: IT, OpenBSD, Unix
  • How not to load-balance connections with accept(), from Phil Harman’s blog.

    這裡還有一些利用 LD preload 的技巧.

    Popularity: 12% [?]

  • 0 Comments
  • Filed under: IT, Sun, Unix
  • Linux: Removing Older GCC Support, from kerneltrap.

    大意是說以後用 GCC 3.2 以前的版本不能再 compile Linux kernel 了. 剛剛找了一下, RHEL 2.1, Debian 3.0 (woody), SuSE 8.0, Gentoo 1.2, Slackware 8.1 都是小於 3.2 的. 不過 Redhat 8.x, 9.x 和 Fedora Core 所有版本都是有 support 的.

    Popularity: 10% [?]

  • 0 Comments
  • Filed under: IT, Linux, Unix
  • GDB to MDB Migration

    GDB to MDB Migration Part One, Part Two. from Eric Schrock’s Weblog.

    Solaris 的 corefiles 改良成可以包含 process 所有資訊 (library text 和 type information), 而 MDB (and KMDB) 被設計用來作 post-mortem analysis 和 live kernel analysis[1][2].

    Coredump debugging 可能是上班以後必備的技巧之一吧 :p

    [1] libumem & libutil in Solaris, from zmx.
    [2] libuutil and designing for debuggability, from me.

    Popularity: 15% [?]

  • 0 Comments
  • Filed under: IT, Sun, Unix
  • LG3D on dual head display

    Photographs of Dual Head Display Environment on Solaris 10 x86 with nVidia driver and LG3D on TwinView Part2, from Yasuhiro Fujitsuki’s weblog.

    Solaris 10 上用 nVidia 的新 driver 的 screenshot, 有雙螢幕以及 Looking Glass.

    如果不知道甚麼是 Looking Glass 的話, 可以參考 screenshot 或是 Demo.

    Popularity: 13% [?]

  • 0 Comments
  • Filed under: IT, Sun, Unix
  • The Future Of Devfs

    The Future Of Devfs, from KernelTrap.

    devfs 已經是欲除之而後快, 取代的是 Greg KH 從 2001 年寫的 udev.

    Popularity: 11% [?]

  • 0 Comments
  • Filed under: IT, Linux, Unix