Andrés J. Díaz

ajdiaz

  • 08:50:25 pm on June 20, 2009 | # | 0

    Really the sysfs and /proc filesystems are worlds of magic and fantasy. Each day I discover a new trick using this filesystems. So, I decided to post a short summary of my favorites ones. Enjoy and feel free to add your tricks in comments, maybe we can a /proc and /sys knownledge database in a post :)

    1. Scanning for LUNs in attached FC
    echo "- - -" > /sys/class/scsi_host/hostX/scan

    2. CPU hotplug
    echp 0 > /sys/devices/system/cpu/cpuX/online

    Obviously when run echo 1, put the CPU online again

    3. Enable dmesg timestamp
    echo Y > /sys/modules/prinkt/parameters/time

    4. Restore a removed file when is still in use
    cat /proc/pid/fd/descriptor number > /tmp/myfile_restored

    5. Get the IO operations for a process:
    cat /proc/pid/io
    The syscr and the syscw are the accumulated read and write IO operations that process do where running.

    6. Increase size of IO scheduler queue:
    echo 10000 > /sys/block/device/queue/nr_request

    7. Get the current IO scheduler enabed to a specific device:
    cat /sys/block/device/queue/scheduler

    8. Get the threads of pdflush process which are running:
    cat /proc/sys/vm/nr_pdflush_threads

    9. Set the percentage threshold for memory to start to flushd data to disk:
    echo XX > /proc/sys/vm/dirty_background_ratio

    10. Set the sleep time for pdflush checking (in centisecs):
    echo XXX > /proc/sys/vm/dirty_writeback_centisecs

    11. Set the time to live for a data in buffer, when raises, data will commit to disk (in centisecs):
    echo XXX > /proc/sys/vm/dirty_expire_centisecs

     

Leave a Comment