25/06/2008

FlexLM Licence Manager Tricks (IDL version)

This is more of a very special entry for myself in order to store information - but maybe for some of you out there information of this might be useful.

The FlexLM Lincense manager is used e.g. by idl to distribute floating licenses. It uses two TCP/IP ports for communication, the first normally being 1700, the second one is chosen randomly in the standard installation. To fix the second port (which might be useful in order to configure the firewall of the server running it ;-) ) add the following to the specific license.dat file you received:
DAEMON idl_lmgrd /usr/local/itt/idl70/bin *PORT=31700
Another important step is to run the FlexLM license manager as a non-privileged user - which you can achieve by the following procedure:

  1. create a non-privileged user flexlm with own group and own user id - password set to * in order to avoid direct login and give it the standard shell /bin/sh

  2. locate the license files and manager executables and change their access rights to readable for the flexlm user (and group).

  3. locate the startup script (in my case on a SuSE 10.2 machine it is stored in /etc/init.d/sys5_idl_lmgrd)
    and modify the line where the daemon is started to:
    su flexlm -c "{original command line in startup file}"
  4. in the startup script add the line
    umask 022
    directly after
    #!/bin/sh

09/06/2008

Dumping a disk image to a remote share

Situation: You have a samba share on a networked PC (if not, set up a samba server) a broken system partition you want to back up before screwing with it, a Linux rescue CD and no available movable hard disks. Configure your network with ifconfig/ifup or the correspondig utilities on the rescue disk. Mount your Samba share with
# sudo mount -t cifs -o username=<yourusername>,password=<yourpassword> //ip.of.network.pc/<nameofshare> /<some mount folder>
Knoppix e.g. has an empty mount folder at /media/test.
Now the image can be dumped with
# dd_rhelp /dev/<sdxx> /<some mount folder>/<some image>

So far in theory: practically, I couldn't find ddrescue on my Knoppix 5.1 live CD (no idea why, maybe I was just tired), so I just plugged the drive into good old Archimedes again and dumped the drive locally before it got completely unreadable. However, dd onto a samba share worked up to the first I/O error, as expected, so dd_rhelp ought to work on the same lines. Booting the Knoppix 5.3 DVD afterwards produced a perfectly reasonable /sbin/ddrescue.

08/06/2008

Deleting more files tham rm can handle

I had to delete something between 20000 and 100000 bitmaps at work, which exceeded the 128k buffer for rm arguments.
Solution and extended discussion found here:
$ find . -name '*.bmp' | xargs rm
$ find . -name '*.bmp' -print0 | xargs -0 rm in case the file name contains spaces.

28/05/2008

Convert PDF to inkscape SVG

I tried to find a vector graphics program on Linux capable of importing pdf, like Corel does on Windows. No luck: Karbon works to a certain extent, Corel on wine seems to be tricky. Scribus can import postscript created by ps2pdf, but might shift lines in the image. There is, however, a workaround to convert PDF to inkscape SVG.
Note: This is once again a historic post, as inkscape has PDF import capabilities since version 0.46 via poppler. It's not in the official SuSE 10.3 repos, but easily available via software.opensuse.org. Works better than the workarounds. On second thought: if you are missing the importing text as curves option, you might want to use this version of pdf2svg (it's also on Ubuntu universe). Works great, even for multi-page documents.

27/05/2008

Miktex package manager on Linux

Yes, the MikTeX Package Manager does still exist for Linux, they are just in the process of porting major parts of MikTeX and don't ship the miktex-tools package any more.
Download the sources from the MikTeX page. Untar and just follow the directions in the README.unx file. For some obscure reason, lynx must be installed, also (less obscure) curl-devel.
# cmake -G "Unix Makefiles" -DMIKTEX_INSTALLROOT=/usr/share/texmf (or whereever your texmf tree is)
# make
# make install
# ldconfig
Add the installation path to the root PATH (just for convenience):
# export PATH=$PATH:/usr/local/bin
Or link mpm in /sbin:
# cd /sbin
# ln -s /usr/local/bin/mpm
For mpm usage, check man mpm or Christian Schenk's blog entry. Don't forget to run
# texhash
after making changes to get texlive to find the changed packages.

NB: mpm doesn't compile with gcc 4.3.1 (e.g. openSuSE 11) but can be patched successfully.

13/05/2008

Yet another crashed FAT hard drive

Last week my portable brain extension crashed (2.5'' 80GB FAT32 USB drive): Windows didn't recognise it at all (no surprises here), Linux mounted it, but stalled at loading the directory table.
Definitely a case for Dr. daWuzzzz's Crashed Disk First Aid Kit: one Linux desktop with a free ATA plug (unplug a CD drive if necessary), one ATA 2.5''/3.5'' adapter (like this one), one bloody big backup drive (not FAT32 because of file size limit).
Try mounting
Most portable drives can be easily extracted from their cases with a screwdriver. Connect the IDE and power plugs via the adapter to your drive. Remember to keep everything grounded! Boot up.
If you are not sure about the proper device node try
# ls -l /dev/disk/by-id
ata-SAMSUNG_MP0804H_S042J10LB08407 -> ../../sdc
ata-SAMSUNG_MP0804H_S042J10LB08407-part1 -> ../../sdc1
ata-SAMSUNG_MP0804H_S042J10LB08407-part5 -> ../../sdc5

So, the first logical partition is /dev/sdc5.
# mkdir <mountdirectory> e.g./media/backup
# mount /dev/sdc5 <mountdirectory>
If the filesystem is intact, it should be autodetected. Otherwise, try mount -t. In my case, I had now access to the whole directory structure.
Back up what's left
Dump a disk image on your backup drive (quick check free disk space with df -k).
As dd (see daWuzzzz's post) will stop copying at the first error it encounters, dd_rescue is your friend (search for "ddrescue" in YaST btw). Even more friendly is dd_rhelp (included in ddrescue, tip from the O'Reilly SysAdmin blog), which looks for healthy block sections and tries to read the damaged ones at the end of the run. It also logs the dd_rescue output, listing damaged blocks.
# dd_rhelp /dev/sdc5 /<backupdrive>/<imagename>.iso
Using the -B (hard block size, see the shell output of simple ddrescue for explanation) and -b (soft block size) options with dd_rhelp is supposed to speed this up a bit. -b makes use of the available hard disk cache, with newer drives its commonly 8M maximum (better check yours).
It still took my computer ca. 20 hours to back up my drive, so be patient. As the dump simply copies 0's and 1's, the image size is the drive size, regardless of free space.
Create a mountpoint (e.g. # mkdir /media/backup
and mount your image (read-only).
# mount -t vfat <yourimage> /media/Backup -o ro,loop
In cases of mild drive damage one can also try direct copying (even in Konqueror). However, the copy command tends to hang up, and you have to reboot (or umount -l?) quite a lot. In case of serious damage, try testdisk.
Check and repair the file system
Warning: from here you'd better have the dumped image available, possible data loss!
Unmount first. fsck ist the standard Linux disk check utility, for DOS file systems like FAT dosfsck applies (symlinked by fsck.vfat, for more file systems see end of man fsck).
# dosfsck -ar /dev/hdc5
Repairs your file system automatically, asks when in doubt. No optional arguments: check without repairing.
In my case dosfsck put out the message: "There are differences between boot sector and its backup." and listed the differences, e.g. "(offset:original/backup) 71:20/00, 72:20/00...". Writing backup to original and vice versa didn't help. All problems below offset 1BE (=446 hex, executable boot code, see here), so dumping zeros on top of it shouldn't hurt (don't intend to boot from this drive).
# dd if=/dev/null of=/dev/hda bs=446 count=1
In the next fsck run, I copied this MBR to the backup. Still I/O errors, so I decided to live with a few lost files (at least I knew which), re-formatted the drive and copied everything back from the mounted image. Dumping the image back is also possible (cf. daWuzzzz) but I wanted get rid of the corrupted files. Copying is also faster in this case.
Disk health
Format and reuse the drive or buy a new one? smartctl might give you a hint there (cf. daWuzzzz)
My drive (which is definitely f***d up) always passed the health test, so one had better rely on smartctl -a
The same procedure should of course also work with a crashed system partition and any Linux live CD containing ddrescue (e.g. Knoppix).
A great site for data restoration is also CGSecurity. Their TestDisk app reads out data even when the file system is corrupted.

12/05/2008

How to get the latest NTFS-3g

Due to a charming display of eccentric version numbering, you might be stuck with a year-old NTFS-3g version and not even be aware of it.
The developers are in the habit of tagging their versions by month and day of the release date, so 1.913 was released on 07/09/13, 1.1120 on 07/11/20 and 1.2506 (sic!) on 05/06/08. Some nice kind of mini-Y2K here, I wonder what they will surprise us with in October. Don't get me wrong: I love ntfs-3g, couldn't live without it on my dual-boot systems. Kudos to the developers!

Installing the latest:
Add one of the following software repositories in YaST (use "specify URL"):
http://ftp.gwdg.de/pub/linux/misc/suser-jengelh/SUSE-10.3/ http://download.opensuse.org/repositories/home:/benkai:/ntfs/openSUSE_Factory/
Both ship the 1.2506 release and according to ntfs.org that one is heavily recommended, the main repo still has 1.913. Note: I am not altogether comfortable about using a factory repo on a day-to-day system, and for whatever reasons, YaST reported conflicts for the 1.2506 version from the benkai repo, the jengelh repo works fine.

Duplicate entries in Amarok collection

This might be just a residual effect of an (resolved) amarok bug (see KDE bug #87986). I had duplicate album entries for AFAIK every mp3 file on my NTFS data partition. Less annoying, but equally weird: playlists in the playlist browser were listed in triplicate. Deleting playlist files and rescanning the collection (even getting Amarok to scan a completely different folder) had no effect.
What worked was to quit Amarok, remove the following files from ~/.kde/share/apps/amarok - collection.db, collection_scan.files, collection_scan.log (can't hurt ;-)) and playlistbrowser_save.xml - restart and rescan collection. After that, rescanning, changing folders, adding new files and changing tags worked OK.
Another bit of weirdness: apparently I can't create playlists on the NTFS partition (Amarok complains "You can only select local files"), but overwriting existing ones works. Edit: That's actually a (resolved) NTFS-3g problem, get the last stable release (no, not 1.913!!!). Thanks to Sven from roKymotion for pointing that out.