Showing posts with label opensuse. Show all posts
Showing posts with label opensuse. Show all posts

Sunday, August 8, 2010

How to recover lost photos from a memory card (CF) - linux

This post describes a straightforward way to recover lost or deleted files from hard drives or memory cards using photorec in linux (SuSE 11.2). Photorec is one of many programs that can be used for this purpose and is available for Linux, Windows or Mac. PhotoRec ignores the filesystem and goes after the underlying data, so it'll work even if your media's filesystem is severely damaged or formatted. Experienced users should just install the program and use it.
This post describes the recovery of photos from a compact flash card.

A photo easily salvaged from the CF card

The Problem

Before the holidays I bought two 16 GB compact flash cards: one Adata (533x), which worked flawlessly; and one takeMS (120x), which failed.

The problematic compact flash card

After some photos with a Canon Rebel XTi (Canon 400D), the camera displayed something like "CF card error" and suggested replacing the card. I removed and re-inserted the card, and turned the Canon back on. The result was the apparent disappearance of all the photos (the message "NO IMAGES"). To avoid losing data the card was no longer used. I later tried to mount it on a PC but no files were found. The camera continued working fine with other cards.

The Preparation

  • Installing PhotoRec
    Use YaST -> software management to search for and install package "photorec".

  •  

  • Making a disk image (optional)
    To be on the (very) safe side, an image of the card was made. With photorec you can, in principle, bypass this step since it will never attempt to write to the drive or memory support from which lost data is recovered.
    Make a copy of the whole drive and not of a partition. Check that enough space is available to save the image file (in this case 16GB) and note that the operation can take quite a long time, depending on your drive and system (increase bs for speed, e.g. bs=64k or bs=1M). Using command dd:

    user@linux:~> sudo dd if=/dev/sdc of=takeMS_cf.img bs=512
    29818656+0 records in 29818656+0 records out 15267151872 bytes (15 GB) copied, 13988.5 s, 1.1 MB/s

    In linux once a drive has been partitioned, the partitions will be represented as numbers at the end of the drive names. To determine which device name your drive or card has you might be able to use mount. In my case the output of mount included the following line:
    /dev/sdc1 on /media/EOS_DIGITAL type vfat (rw,nosuid,nodev,uid=1000,utf8,shortname=mixed,flush)
    So the card's device name would be /dev/sdc.
    An alternative using SuSE linux is to check the hardware information in YaST->Hardware Information, check the "CF reader" in the Disk section.

The Recovery (step by step)

To recover the lost files just run photorec on the image or mounted drive.

user@linux:~> /usr/sbin/photorec /log takeMS_cf.img

PhotoRec leads you through a number of screens that are straightforward as shown below (see here another example).

Select the image file as media
(run the command as superuser if you did not create an image)

Select the partition table type (INTEL here)

Select here what will be searched.

In my case, searching both the single partition or the whole disk resulted in exactly the same files being recovered.
You can also change options or disable identification of some file types in this screen (which you probably do not want to do: In this example cr2 files were correctly recovered even if the extension was not exactly the one in the list: crw).

Here you are asked how the files were originally stored.

Next PhotoRec asks for a location to save the recovered files. I had created a new folder named "recover".

Press Y to confirm the location and the search starts

Snapshot during the search (includes estimated time)

The final report

In the end PhotoRec tells you how many files of each of the recognised types were recovered (although it reports tiff for cr2 files). The original names are not recovered but PhotoRec correctly recovered the correct file extensions in my photos (cr2 and jpg). Thanks PhotoRec!

Sunday, December 6, 2009

OpenSuSE 11.2 and Skype - Microphone setup

After the installation of SuSE 11.2 skype was also upgraded to a new beta version (version 2.1.0.47 for linux). However there was a sound problem as the microphone did not work. Pulseaudio did not seem to be installed by default. Anyway, a message in the skype blog explains that if no pulseaudio is available, skype uses alsa. So, the mic should work with or without pulseaudio.

Solution: the reason why the microphone does not work is related only to the default mixer setup in OpenSuSE 11.2, and not with pulseaudio, alsa or skype.

The microphone setup

By default the microphone is muted and is not present in the mixer window. To view the microphone status, configure the channels in the mixer window menu:

Select the microphone and maybe the Mic Boost (in case the level from your microphone is very low).

The mixer now shows the new entries and you only need to de-select the mute radio button of the microphone and choose the right one in case you have several.

Fur useful information on setting the microphone see here.

Conclusion

The Microphone works with skype both after installing pulseaudio (strange glitchy recorded sound) or using alsa (after unistalling pulseaudio again). It works in both cases!

Sunday, November 22, 2009

Upgrading from OpenSuse 10.3 to 11.2 (new installation)

The change went fine. This post is a personal placeholder for installation instructions for OpenSuSE 11.2, which might be useful.

Dual boot and multi/boot

This computer has two versions of windows XP next to SuSE 10.3. Only the linux installation is replaced without partitioning or breaking the boot. The following describes some steps to avoid problems before the installation.

  • Open YaST and from the partition tool write down the relevant information (partitions, file-system and mount-points). In this case

    /dev/sda1 NTFS C
    /dev/sda2 NTFS D
    /dev/sda3 (extended partition)
    /dev/sda5 swap
    /dev/sda6 EXT3 /
    /dev/sda7 EXT3 /home
    /dev/sda8 FAT32
    ...

    Be careful not to change anything!

  • Check in YaST how the boot is configured and write it down. Understand where the bootloader is installed. In my case grub was in the master boot record (MBR). The default grub entry starts Suse 10.3 (root=/dev/sda6) and one other starts the NT/XP bootloader installed in /dev/sda2 (which selects which XP to start).

  • During installation OpenSuSE 11.2 automatically proposed a configuration which did not change the windows partitions but modified the mountpoints of the linux partitions. I decided to keep the old partitions and manually change the proposal to have the table look like the original one (using the above listed mountpoints). The linux partitions / and /home were reformatted to EXT4 (the standard fs in the latest distributions). EXT4 had to be explicitly requested when doing the manual adjustments!

  • Finally, the suggested place for the bootloader (grub) was not the master boot record (MBR) but with a click it was easy to enable installation in the MBR.

All the changes were easy with the installation interface of OpenSuSE 11.2. This was a bit surprising, since experience taught me never to use the latest version before it's fixed. Installation went well, the bootloader works fine. However, grub detected the two XPs and created two entries for windows, one I must remove because I have them set up to boot from only one partition. So far so good.

Wrong keyboard layout

Even if a portuguese keyboard was chosen at installation, KDE was by default using the US keyboard. To solve the problem to "System settings -> Regional and language -> Keyboard layout". Enable keyboard layouts and drag the layout of your keyboard from "available layouts" to "active layouts". Finally either press the up arrow to make this the default layout or move the wrong layout back to available layouts (simpler and you avoid a layout icon in the panel). Press "Apply".

Microphone default setup

See this post

Friday, August 7, 2009

Skype with the Logitech Quickcam Pro 5000

Some owners of this webcam face problems and report that it does not work with Skype for Linux. It does work. It is a problem with Skype and the solution in this post applies to many other cameras.

A previous post shows how to install the camera under Linux (openSUSE 10.3 and 11.0).

The latest Skype for Linux (version 2.0.0.72) dates from June 2008. Skype did not release any updates. A post in January 2009 announced that Skype for Linux is definitely not dead [...] Stay tuned for more developments. The next post on 31st of July 2009 says: can’t make any promises about when it’ll be released, but watch this blog for further updates. How many popular open source projects get no updates during an entire year? Skype is not open source and no one can fix even simple bugs. That's why.

[Update: Also works under SuSe 11.2 and the new skype version 2.1.0.47. For microphone issues see here]

How to solve it

The solution only takes one command but a detailed explanation could be useful for beginers:

  1. Install or test the webcam (see the previous post).

  2. Close skype if it is running (CTRL-Q)

  3. Open konsole, xterm or any terminal (e.g. from the menu under System->Terminal).

  4. Start skype from the terminal (so that any error messages appear there)

    user@host:~> skype
  5. In Skype select Options -> Video Devices.

     
  6. Confirm that your webcam is selected. If you have several devices select the webcam.

  7. Press "Test"

    If you see the image from the camera, great. Most likely you see only black, green, white or something else that you do not regard as a success. The terminal might also show errors such as:

    Skype V4L2: Could not find a suitable capture format

    Skype Xv: No suitable overlay format found

  8. Quit skype (or simply use CTRL-C in the terminal)

    What is the problem?

    The newer Linux kernels support many webcam drivers but the legacy Video4Linux API has been dropped and only Video4Linux version 2 is supported. Since skype 2.0.0.72 uses Video4Linux version 1, there is an incompatibility.

    What is the solution?

    The solution is to dynamically load a shared library that provides compatibility between version 1 and 2. Theses libraries are now in your system but the paths depend on the distribution (try "locate v4l2convert.so" or use a find utility to locate v4l2convert.so and v4l1compat.so). If you run a 64bit system use the 32bit version of the library with skype.

  9. Start skype from the terminal with one of the following commands (these are paths for SuSE. Both worked.):

    me@host:~> LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so skype

    me@host:~> LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so skype

    Repeat steps 5-7 and it should work.

Increase your confort

Here are three possibilities to avoid having to type the command. The first method is the favorite and incidentally the only one which works in any normal circumstance (the others fail if you leave to your window manager to restore the last session on login).

  • Add the following line to either one of .bashrc or .xinitrc in your home directory (if there is no .xinitrc, you can make a copy of .xinitrc.template and edit the section "# Add your own lines here...").

    export LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so

    Or if your LD_PRELOAD variable is already set:

    export LD_PRELOAD="/usr/lib/libv4l/v4l2convert.so $LD_PRELOAD"

    Since either with .bashrc or .xinitrc the variable will be set before the session is restored, Skype will start with the compatibility library in place :-).

  • If you start skype from a shell, an alias can be crated by adding a line such as the following to .bashrc.

    alias skype='LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so skype'

    Next type you type skype the alias will be used.

  • If you launch Skype from the KDE menu, locate the icon in the application menu and right click on it. Choose "Edit Item" and replace "skype" with:

    LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so skype

    Do not forget to save the change. If there is a Skype button in the Pannel, just edit it and also replace the command there.

Wednesday, August 5, 2009

Logitech Quickcam Pro 5000 on SuSE Linux

To replace a Phillips ToUcam Pro which broke after being squeezed too hard into its "egg case" we got an unidentified second-hand webcam. With a flexible mount, it fits easily any screen but did not work out-of-the box either under Linux or XP.

This post describes the steps to install the camera under Linux and the next post explains a trick to make it work with the "latest" skype video (version 2.0.0.72).

Logitech Quickcam Pro 5000

We use openSUSE (tested on 10.3 and 11.0) but it is trivial to make it work with other popular distributions (e.g. Ubuntu, etc) by using their package installation tools.

[Update: Tested also on SuSE 11.2]

1. Does the device connect to a USB bus?

USB devices may be listed with the command lsusb. After the webcam is connected to a usb port the result of lsusb should include one more line. In my case:
Bus 003 Device 005: ID 046d:08c5 Logitech, Inc.
So, this webcam identifies itself as 046d:08c5. From this it was possible to identify the model of the our webcam. Many people have a version of the Quickcam Pro 5000 reporting another ID:
Bus 001 Device 003: ID 046d:08ce Logitech, Inc. QuickCam Pro 5000
Anyway, if you see one of these your webcam is connected.

2. Installing the UVC drivers

As can be seen from the devices page from the Quickcam Team, the Quickcam Pro 5000 is a USB Video Class (UVC) compatible camera device (there are compatibility issues with some USB controllers).

[You might need to select a repository of drivers for webcams. In YaST->Community Repositories, select "openSUSE BuildService - Drivers for webcams"]

To install the driver in SuSE open YaST->Software Management (search with "uvc" for convenience) and install packages uvcvideo (choose the one for your kernel, usually uvcvideo-kmp-default) and luvciew (useful to test the camera). You will also need packages related to Video4linux. We have libv4l and v4l-conf installed (in YaST search "v4L" and install if necessary):

3. Testing

After rebooting, connect the webcam and run luvcview from a terminal. You should see a window such as this (after removing the lens cap and pointing the webcam to a postcard from London :-)

Photo of the luvcview window (not true image quality).

That's it! The Logitech Quickcam Pro 5000 is now working.