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.

08/05/2008

Playing embedded movies in LaTeX PDF

Things have changed since I first posted this (find a summary here): the Okular version shipped with KDE 4.2/SuSE Factory plays embedded movies (haven't checked projector output yet, but for that, the graphics driver is responsible anyhow). There seems to be some unreliability in showing poster images, still, and phonon refused audio playback, but the basic functionality is there. For Lilypond users: point-and-click annotations also work by now. KDE users, consider the following post to be slightly historic ;-).

01/05/2008

Who needs an X server anyway?

Worst case scenario: your X server keeps crashing, no other computer available and you need to do some emergency googling, backup, downloading, system analysis etc.
Here is a collection of console system analysis tools:
  • First, a beauty of a fossil: the lynx browser, available from the main SuSE repository. Link navigation with arrow keys, the "g" key is useful for URL typing. Google search is a bit cumbersome, but feasible. Flash and Javascript sites (e.g. the ATI driver download site) are more or less unusable.

  • wget download utility: wget <file URL>

  • YaST has a comfortable command-line interface, simply type yast

  • burn backups: wodim, see the examples right at the end of man wodim

  • some decent vi manual

  • Start Samba filesharing server with smbd -D; start ssh server with sshd

  • Unison and rsync work from console, too.

  • Check free disk space: df -h

Less spectacular: You want to work on a remote machine via ssh and a VNC connection works too slow for you.
  • Midnight Commander (mc) is a classic console file manager with ftp capabilities.

  • The fish:// protocol allows you remote ssh access in Konqueror - e.g. fish://avocadohead@myserver.com/home/avocadohead/

fglrx 8.476: Play movies at your own risk!

It is well known that the ATI fglrx driver produces flickering video in combination with compiz/AIGLX. One solution is to switch to kwin while playing DivX files, DVDs etc.; in this case fusion-icon is your friend ;-)
Nevertheless, with the latest driver (fglrx 8.476 aka AMD Catalyst 8.4) I was in for something special: trying to watch a movie with kaffeine on any window manager crashed my X session instantly. I ruefully reverted to fglrx 8.455.
Morale: Always keep a backup of the last remotely stable driver installer.