Segfault > IT > Notes > General
  • Use irxevent to send button presses and irexec for starting programs for lirc.
  • Check http://www.romanofski.de/docs/lirc for instructions for lirc and xmms (Lirc howto) or http://www.g-loaded.eu/2006/01/10/how-to-configure-and-use-lirc/ for a more general lirc howto.
  • A good explanation for X and key events is here: http://gunnarwrobel.de/wiki/Linux-and-the-keyboard.html
  • It looks like "Mysaifu JVM " is a free java virtual machine for pocketPC.
  • If, while emerging, the error message "ACCESS VIOLATION" pops up, write as follows:
    FEATURES="-sandbox" emerge
    Or, if emerge db or emerge sandbox fails, use as well FEATURES="-sandbox" emerge sandbox and then try again emerging db.
    Or, if a package is masked by the ~x86 keyword, add eg. "app-laptop/fnfx" (without version number) to the file /etc/portage/package.keywords. E.g.: media-tv/mythtv ~x86
    Or, if you want to install a specific version of a software which is masked write the version and add an equal sign in front of the string. E.g.: =media-tv/ivtv-0.8.2
  • To update the system "emerge --update --deep world" and or "emerge --update --deep --newuse world" is you modified the USE flags.
  • Local portage database can be searched faster using eix.
  • Have a look at the following notes if booting Gentoo on a Sun Blade 100 does not work:

At the "ok" prompt (press "Stop + a" if your workstation doesn't want to stop on its own at the "ok"-prompt) I gave the command "boot cdrom" to run the bootloader of the CD, and afterwards "gentoo" (the default kernel of 2008.0), which resulted in the screen getting blank during the boot process.
I solved this by invoking BEFORE saying "boot cdrom" the command "setenv output-device screen:r1024x768x60" COMBINED afterwards with "reset-all" (only the first time after executing the previous command - that setting is then somehow saved in the PROM of the PC) and "gentoo video=atyfb:off" OR "video=atyfb:1024x768@60".

At this point the screen at least was showing me when the workstation was getting stuck, which varied between when reaching during the boot process the point of "Loading firmware" or "Letting udev process events" or "hda" during the boot process.

I did a lot of attempts and the one that finally worked was "gentoo video=atyfb:1024x768@60 nodma ide=nodma"
In my case it's the parameter "ide=nodma" which makes the difference, but depending on your distribution the "nodma" option might make the difference, so you can use them both at least for the first time just to see if things work.

After the successful boot I partitioned (partitions looked somehow funny - e.g. "hdc1p1" instead of the usual "hdc1") and formatted both HDD to see if things were really working - no problems here.

  • Set the speed of the mouse pointer:
    xset m 1/2 5
  • Problems with installing Mythtv and making it update the mysql database: 
    • To see if you have problems because of UTF8, run mythbackend in a terminal. If you get an error about the primary key being too long try:
      $mysql -u root
      DROP DATABASE mythconverg;
      CREATE DATABASE mythconverg CHARACTER SET latin1;
      exit;
    • If mythbackend says it was already started and as well already stopped write "/etc/init.d/mythbackend zap".
  • To automatically load modules on boot modify the file /etc/modules.autoload.d/kernel-2.6
  • Keyboard remap:
    • The bindings of enlightenment are under "/usr/share/e16/config/bindings.cfg"
    • xev is a small program that shows the key codes of the keys pressed
    • xmodmap maps one key with another. Example:
      xmodmap -e "keycode 77 = Down"
      Such mappings can be saved in the root directory in a file called eg. .Xmodmap which contains informations eg. in the following format:
      keycode 77 = Down
      This can be loaded automatically at X-startup, e.g. with a script containing xmodmap $HOME/.Xmodmap.
      Afterwards it is possible to set in the file .xbindkeysrc instructions like...
      "eesh desk arrange"
      Down
      "$MYSCRIPTS/menu/alsa_increase_volume"
      XF86AudioRaiseVolume
      ...and automatically set xbindkeys upon X-startup to have those scripts & applications run whenever you press the key.
  • How to user multimedia keys: A description of how to map keys to programs or events.
  • To write / flush the data from memory to the harddisk use the "sync" command (has no options).
  • If a system fails during boot (Error "Could not create directory...) and it is on a jfs partition it is because a deeper filesystem check with "jfs_check -f /dev/hdaX" has to be performed on the not mounted partition.
  • eesh can be used in order to change enlightenment parameters and as well the desktop.
  • To update the system:
    emerge --update --deep [--newuse] world
  • To see what's the estimated end of emerging the current package type:
    genlop -c
  • To see what's currently being emerged type:
    tail /var/log/emerge.log
  • To see the CPU usage of a process using the command PS, digit:
    ps -o cpu -p [pid of the process]
    "cpu" could be as well uppercase.
  • To do a grep NOT for the word specified (opposite behaviour), use "grep -v".
  • You tell X to use enlightenment by editing the file rc.conf
  • Kernel modules that have to be loaded are saved in the file "/etc/modules.autoload.d/kernel-2.6". Run "modules-update" after modifiying the list.
  • Global variables can be defined (in Gentoo) in the file /etc/env.d/99local (create it if you never defined global vars before). !!!Run env-update afterwards!!!
  • In order to send keyboard events, use xvkbd. For example, type the following in order to send a backspace char event to Firefox:
    xvkbd -window 0x1c00040 -text "\b"
    • Use eesh in order to get the window id:
      eesh wl | grep -i firefox
    • If you have to use special keys, you have to use the utility xev (should be included in X - it is not in gentoo), grab the keysym (example the right arrow is 0xff53),...
    • ... then search the code 0xff53 in the file...
      /usr/include/X11/keysymdef.h
    • ..., find the key definition you're interested in (like in this case XK_Right), remove the XK_ and use the remaining string like this:
      xvkbd -window 0x1c00040 -text "\[Right]"
    • Another example is if you have two X servers running. By sending a combination of ctrl+alt+F7 or F8 you switch servers:
      xvkbd -display :0 -text "\C\A\[F7]"
  • In order to set the dynamic CPU clock, type:
    echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  • After re-compiling the kernel or changing version, re-emerge nvidia-drivers, ieee80211 and ipw2200.
  • To create and MD5 SSH1 digest file do
    ebuild xf86-video-ivtvdev-0.10.6.ebuild digest
  • Use johntheripper to guess passwords (e.g. /etc/shadow)
    The config file is located in /etc/john/
  • Use "lsof" to list the open files.
    "lsof -u " lists for each user the files that are open.
    "lsof " lists for a specific file who has it open.
    "lsof -c " lists the files opened by a specific program.
  • Read this article on Gentoo for important informations on memory management in Linux (e.g. why you see only 880MB RAM for your system even if you have more installed).
  • The program "free" shows the available memory.
  • Use usbview to see which USB devices are connected to what.
  • If during an emerge of kdelibs I get "ERROR: kde-base/kdelibs-3.5.5-r6 failed.", and I just switched compiler version, follow the guide under http://www.gentoo.org/doc/en/gcc-upgrading.xml
  • You can delete the whole content of the directory /usr/portage/distfiles/ if it's using too much space. Emerge will afterwards automatically download anything that is missing during an emerge.
  • Run the command time to see how much cpu time (real time and sys/user time of the CPU) was used by the execution of the command.
  • To send signals to a dcop-enabled applicatin:
    • enter first...
      dcop [applicationname]
    • ...to get the list of the parts of the application that are able to get signals, and afterwards...
      dcop [applicationname] [partname]
    • ...to see which signals can be sent. The ones with [void] at the beginning don't return any value.
    • Therefore, to start playing a song in Amarok, type the command...
      dcop amarok player play
  • A good virtual keyboard for X, so that a real keyboard is not needed and character input can be done on-screen, is XVkbd. 
  • To set the layout of the keyboard use xrdb (before starting xvkbd). Eg.:
    cd /usr/share/X11/app-defaults/
    xvkbd XVkbd-swissgerman
  • Mount an iso image like this:
    mount -o loop,ro -t iso9660 imagename.iso /mnt/cdrom
  • DMG images can be burned using cdrecord: cdrecord dev=/dev/cdrom mac_image_file.dmg
  • How to mount DMG image files (MAC): 
    • Check with the file command what kind of image the file is:
      file mac_image_file.dmg
      mac_image_file.dmg: Macintosh HFS Extended version 4 data last mounted...
    • It can be mounted with:
      mount -o loop,ro -t hfsplus mac_image_file.dmg /mnt/yourmountpoint
  • In order to be able to access RAM beyond 880MB, activate in the Kernel setup "Processor Type and Features => High Memory Support". See this article about Linux memory management.
  • To see details about the motherboard, use "dmidecode".
  • Use blkid in order to get the UUID of the drives.
  • In order to assemble a software raid using the UUIDs of the drives, find out the UUID with (if e.g. the partitions that compose the raid are sdf1 and sdg1)...
    mdadm --examine --scan /dev/sd[fg]1
    ...and afterwards assemble it with the command (if md1 is the target)...
    mdadm --assemble /dev/md1 --uuid=56301900:9d834972:42b1cab9:ee964b44
  • If a failure happens in a sw-raid after you replace the HDD it's enough to run e.g. ...
    mdadm /dev/md1 --add /dev/sdf1
    ...to add the new HDD to the raid and start the recovery/sync/rebuild.
  • To stop having all RAID arrays auto-assembled during boot edit /etc/mdadm.conf and add "AUTO -all".
  • The Canon i865 works well with CUPSD if configured as a "bjc600" (remember to emerge CUPS with the ppds flag).
    Send remote processes to sleep with kill -STOP PID or kill -19 PID and resume them with kill -CONT PID or kill -18 PID.
  • If in a RAID array two HDDs or more fail / get an unhealthy status at the same time, there is the possibility that something might have gone wrong with the drivers of the controller. Try to restart the array with all the HDDs (e.g. a RAID 5 with 4 HDDs)...
    mdadm --assemble --force /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
    ...and check in "cat /proc/mdstat" if both the HDDs are still marked as "failed". If not, try to re-add the faulty HDD with...
    mdadm --manage /dev/md0 --add /dev/sdd1
    ...or whichever HDD failed and see if the RAID rebuilds correctly and still works afterwards.
  • The top 100 Amiga games (for UAE emulator): http://www.lemonamiga.com/games/votes_list.php
  • If when booting using an ide-CD or -DVD you get an error saying...
    No bootable medium found. Waiting for new devices...
    Could not find CD to boot, something else needed!
    ...give to the kernel the option all-generic-ide. More informations here.
  • If you're using e.g. an external HDD-case which contains multiple HDDs and this is connected by USB and you can only see one of them, make sure that the kernel has "SCSI_MULTI_LUN" activated (under "Device Drivers -> SCSI device support -> Probe all LUNs on each SCSI device").
  • Use cp -Rxvad to copy EVERYTHING from one HDD to another - e.g. when you want to copy everything from one partition to another.
  • Use "ccd2iso" to convert a CloneCD image (.img) to a normal iso image.
  • Run update-pciids so that lspci can show up-to-date descriptions of your pci devices. There are as well other update-* commands - e.g. for the ca-certificates, usb devices, etc... .
  • Use "powertop" to see how to improve notebook in battery mode.
  • To split up a file into smaller pieces:
    rar a -v2048k outfile file
  • To have a look at the hardware (e.g. RAM speed, CPU type, Chipset, etc...) use lshw or dmidecode.
  • Use k9copy to make backups of DVDs.
  • Use iotop to see which process generates the most disk activity.
  • To avoid a filesystem check during boot just write an empty file called fastboot in the root directory
    touch /fastboot
  • Clones of Windiff in Linux are e.g. Easydiff or xxdiff.
  • Location of Kernel modules is e.g. in /lib/modules/2.6.28-gentoo and they have the ending .ko.
  • Use gpg -c to encrypt a file. Just gpg to decrypt it.
  • If, after taking out some HDDs from a SW-raid, the system says...
    /dev/sdX is apparently in use by the system; will not make a filesystem here!
    ...when creating or mounting an ext filesystem (e.g. mkfs.ext3 /dev/sdX), and you're sure that the disk is not mounted (df -h) nor in use by the raid (cat /proc/mdadm), the format fails because the superblock of the raid is still present at the end of the HDD. The solution is to overwrite the HDD with 0s (dd if=/dev/zero of=/dev/sdX bs=64k). BE CAREFUL - YOU WILL LOSE ALL THE DATA ON THE HDD!!!.
  • mdadm commands lookup: 
    • Create a raid:
      mdadm --create --verbose /dev/md2 --level=1 --raid-devices=2 /dev/sdc1 /dev/sdd1
    • Grow a raid (HDDs replaced by some bigger ones and raid already re-synced):
      mdadm --grow /dev/md2 --size=max
    • See here about shrinking and growing raids.
    • Startup a raid:
      mdadm --assemble /dev/md0 --uuid=503cbba1:7bed6e2f:b543e69e:13f1698e
      Or:
      mdadm --assemble /dev/md0 /dev/sdc1 /dev/sdd1
    • Stop a raid:
      mdadm --stop /dev/md0
    • Delete a raid:
      mdadm --manage /dev/md0 --fail /dev/sdc1
      mdadm --manage /dev/md0 --remove /dev/sdc1
      mdadm --zero-superblock /dev/sdc1
  • iozone command line...
    • iozone -a -z -i 0 -i 1 -i 2 -i 5 -b exceloutput.xls -e -g 16777216
      ...will generate an excel file, use biggest file of 16GB for testing purposes, run an fsync for each file, perform automatic testing sizing, test as well small record sizes with very big files, perfom tests write/rewrite, read/re-read, random-read/write, stride-read.
    • Alternatively...
      iozone -a -z -i 0 -i 1 -i 2 -i 5 -b exceloutput.xls -e -s 16G
      ...to run the tests on just a single 16GB file.
    • Or:
      iozone -a -i 0 -i 1 -i 2 -i 5 -i 8 -b exceloutput.xls -e -g 8G
      ...to run additionally a random mix of "reads/writes" and run all test sizes, with a maximum file size of 8G.
  • To use an HP printer in Linux, install "hplip" and use it in combination with cups. Make sure to use the latest version (unmask for emerge). 
  • The location in the network where to find the CUPS-server is defined in "/etc/cups/client.conf". Add a like like e.g. "ServerName :"
  • Use "keytouch" to easily assign commands to special notebook buttons or similar.
  • Use "autounmask" to automatically unmask a series of masked packages.
  • Hard-masked packages can be unmasked in Gentoo by commenting the line in "/usr/portage/profiles/package.mask".
  • To avoid loading automatically modules ("autoload") when the system boots, add the module name that you don't want to be loaded in /etc/modprobe.d/blacklist.conf. The entry will be e.g. "blacklist ".
  • Send stats about your Gentoo installation (smolt): http://www.linuxquestions.org/questions/gentoo-87/gentoo-machine-setup-statistics-public-beta-test-launched-756303/
  • If you modify an ".emerge"-file in Gentoo you will have to modify as well the hash values inside the Manifest file. To do that use "ebuild manifest" which will generate a new "Manifest"-file for all files in that directory.
  • Use "ntp"/"ntpd" (/etc/init.d/ntp-client start) and then "hwclock" (hwclock --systohc) to set the system clock/date and set the hardware clock with that value.
  • Mount raw local devices to loop devices (loopback) with "losetup":
    • Mount: losetup /dev/loopX /myfile.img
    • Check if anything is mounted: losetup /dev/loopX
  • To fix bad blocks on a reiserFS partition:
    • debugreiserfs | grep -i 'blocksize'
    • badblocks -n -b -o mybadblocksfile
    • reiserfsck --rebuild-tree --badblocks mybadblocksfile
    • You will probably have to add some blocks to "mybadblocksfile" - depending on what "reiserfsck" says.
  • Rootkit tests:
    chkrootkit
    rkhunter
  • To trace running processes use:
    trace -p
  • If I get an error message like "rm: cannot remove : Operation not permitted" when trying to remove a file even when being root, use "chattr -i ".
  • To make perl apps run again after an update of perl:
    perl-cleaner --reallyall
  • Debian ARM architecture using QEMU
    • Use "rcconf" to edit the init level.
    • Instructions to build Debian from scratch http://blog.troyastle.com
      • Go to your mirror, navigate to the directory "debian/dists/lenny/main/installer-armel/current/images/versatile/netboot/" and download the "vmlinuz" and the "initrd.gz" files + set up your KVM VM with the options "-kernel ~/arm/vmlinuz-versatile", "-initrd ~/arm/initrd.gz" and "-append "root=/dev/ram"", plus once the installation is done copy from the local installation the vmlinuz and initrd files out of the VM + put them into your KVM directory and finally change the append option to your usual HDD e.g. "-append "root=/dev/sda1"". 
    • Downloadable image of Debian ARM http://people.debian.org/~aurel32/qemu/arm/
    • Very first steps + Xorg management & multiple screens: http://forums.debian.net/viewtopic.php?t=12256
    • Use "tightvncserver" to get X output as I wasn't able to make QEMU's emulated VGA work with ARM. You'll need as well the packages of "e16", "xorg" and "gnome" (to get the graphical pkg manager etc).
    • Network configuration in Debian is in "/etc/network/interfaces". For DHCP It is configured as follows:
      auto lo
      iface lo inet loopback
      auto eth0
      iface eth0 inet dhcp
    • To start/stop the network use "/etc/init.d/networking start/stop". Eventually just stop "/etc/init.d/network-manager" (and take it out of the init with rcconf) if it screws up with the network config. 
  • If trying to mount a LVM partition - dirty way for absolute beginners or disinterested people like me:
    • Start LVM with "/etc/init.d/lvm start".
    • Issue "fdisk -l" to see which partition is tagged as "Linux LVM".
    • Run "pvs -a" to make lvm somehow recognize the partition.
    • Now, running just "pvs", should show you the LVM partition that was recognized.
    • Running "lvdisplay /dev/" should now list all LV names.
    • Running "vgchange -a y " will prevent the error message saying something like "special device does not exist" when running the next command.
    • Run "mount -v /mnt/" to mount the volume. 
  • In Gentoo, the list of explicitly installed/emerged packages is in "/var/lib/portage/world".
  • Use "taskset" to set the CPU affinity for a process.
    E.g. "taskset -p 0x00000002 5222" to set the process with the PID 5222 to run only on the second CPU (core).
  • Serial communication using a serial/nullmodem cable:
    • Make sure that the module of the USB2serial converter are loaded (e.g. pl2303).
    • Use a terminal emulator to connect (e.g. minicom gtkterm picocom)
  • To check if PSR (Panel Self Refresh) is enabled:
    cat /sys/kernel/debug/dri/0/i915_edp_psr_status
  • To monitor in Linux changes to a directory (you'll need "inotify" active in your kernel) (in this specific example I monitor "modify" events that happen when something is written to a file and output the directory and file name):
    inotifywait -rm --format %w%f -e modify MYDIRECTORY/
  • To format an ext4 partition forcing the immediate format of the whole space without postponing a part of the task use:
    mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 [partition]
  • If "dmesg" does not show the full list of events that happened during the boot (the beginning does not start with "0.000") then modify the kernel option LOG_BUF_SHIFT and set a higher value (something like e.g. "18")
  • Re-emerge every installed package:
    emerge --emptytree world
  • Sparse files (related to "hole punching"):
    - dd creates a sparse file by default.
    - Identify fragmentation by using "filefrag ".
    - Convert sparse (potentially fragmented) files to non-sparse by copying them using "cp --sparse=never ...".
  • .