Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Saturday, December 10, 2011

LightDM fails to start

Had a quite annoying experience with my new linux laptop yesterday, after a routine update, it failed to start into X. In brief, LightDM has to wait until the nvidia kernel module is loaded. Originally, the /etc/init/lightdm.conf file had a `sleep 2` command in it, before it attempted to run `exec lightdm`. The upgrade changed the file, removing the sleep line, so that when I rebooted, X would fail, saying that it couldn't load the nvidia driver.

The fix for now, hack though it is, is to add the `sleep 2` line before the `exec lightdm` line. Boot is slower, but at least it works.

This was on Ubuntu 11.10. There is a bug here: https://bugs.launchpad.net/lightdm/+bug/873495

Saturday, July 31, 2010

Recovering Photos from a Memory Card in Linux

Well, this is one of those "mostly for me" posts but, in case you find it useful (and I make no guarantees that you will! :-), here is how I recovered some photos from a memory card.

First: Don't use the card! If you do, there's a chance the data you're interested in may be overwritten.

(Optional: Instead of putting the card on the shelf, I created a backup of the data on it, like so (/dev/sdc being the sdcard; you'll have to check to find out which device is correct by mounting the card and looking at dmesg):

> dd if=/dev/sdc  of=~/image/tempfile

This may take quite a while, depending on the size of your card.)

Second: Get the TestDisk suite. We're going to be using PhotoRec.  If you have Ubuntu, you can do:

> sudo apt-get install testdisk

PhotoRec will actually recover a number of different types of files (see their website for more details). It works by reading the raw data and determining the file type, and then saving the file to a recovery location.

Third: Run PhotoRec.  If you copied your card to a file, you can run it like:

> photorec /path/to/sdcard/file

Otherwise, you can just do:

> sudo photorec

In either case, you'll have to select the "device" (be it file or actual hardware) you want to recover from, and then the partition type (if it's an SD card, you're probably fine with "Intel"), and then the actual partition (again, for an SD card, look for FAT32), and then the filesystem type (probably other), and then whether you want to search the whole partition, or just the free space (ie deleted files). I went for whole partition because I wasn't sure whether the files were deleted or not.  Finally, you have to choose where to put the recovered files (press Y when you've navigated to the correct spot).

Fourth: take a break and let PhotoRec work. Depending on the size of the card and the number of files that are on it (deleted or no!), this may take a little while. (I had about 1500 files recovered in about 20 minutes.)

Great! All your files are back! Woohoo! Now, it's just a matter of sorting through all 1500...

Unfortunately, the files don't have useful names (or mine didn't... names were like "f1071616.jpg"). However, JPG files (can) contain metadata, stored in EXIF. Most digital cameras automatically include information about the camera and the picture, like model, exposure, and... creation time! (Assuming you set the date/time on your camera...)

So we can, at least, give the files somewhat useful names now.

Fifth: Make a backup of your recovered files, just in case something goes wrong. You don't want to have to recover them again.

Sixth: It's time for the magic of Python!  Here's a handy little script I whipped up to pull out the creation time and rename the file. Note that you'll need to have the Python Image Library (PIL) installed.

renameJpgByDateTime.py:

#!/usr/bin/env python

from PIL import Image
from PIL.ExifTags import TAGS

import os, shutil

def renameJpg(fn):
    i = Image.open(fn)
    info = i._getexif()
    for tag, value in info.items():
        decoded = TAGS.get(tag, tag)
        if decoded == 'DateTimeOriginal':
            filePrefix = value + "-"
            shutil.move(fn, filePrefix + fn.replace(filePrefix, ""))

dirlist = os.listdir('.')

for fname in dirlist:
    if '.jpg' in fname:
        renameJpg(fname)

Then, go to the directory that contains the files, and run the script (don't forget to set it to executable):

> ./renameJpgByDateTime.py

And there you go!

Sunday, November 30, 2008

Oh give me a home, where the GNU/Linuxen roam...

I'm running Linux at home again.

And I'm so very happy. (Seriously)

I am playing with programming again (currently trying to make my way through the Python Challenge; I'm on level 7), for one.

But I really like the relief and freedom I feel. Even alongside the occasional frustration. :-)

Other news (unrelated; likely to be expounded on later): my paternal grandfather is dead, and Steve and I have a new kitten named 'Rory' that we got last Monday.

Friday, February 29, 2008

I want my... I want my... I want my KDE!

So, my coworker Brett just got a new laptop, and it has Vista on it, and one thing that's true about Vista is it's shiny.

Now I want my shiny. I've decided that when I install Linux on my new desktop, I'm going to go with KDE instead of Gnome, at least to see all the shiny that KDE 4 is supposed to have.

Unfortunately, I decided to wait until my distro of choice, Gentoo, releases 2008.0, which is supposedly on March 17 (if all goes well). So I must be patient. :-/

Also, happy leap day!

Thursday, December 14, 2006

His name is Linus. He fights for the Users.

Ok, so, admittedly, I don't normally agree with Linus Torvalds. But, this time, he's got it right.

In brief: the issue at hand is whether to disallow non-GPL'd modules to be loaded into the Linux kernel. Apparently, a majority of the kernel developers said that that should be the case (it isn't now), and that it would start Jan 1, 2008. I think that this is a bad idea, because it restricts users' freedom, most specifically the freedom to modify their software to do what they want it to.

Now, don't get me wrong, these guys are also working for users' freedom. Specifically, they want to ensure the freedom of the users to modify modules that are used on their systems. But the method they've chosen is a step in the wrong direction. They are choosing to restrict the freedoms of their own software in order to pressure others to open the freedoms of the others' software (something that the FSF is often accused of doing, and berated for it, even if they don't actually do that). One of the quotes I saw was to the effect of, "in order to protect your freedoms, we have to make some restrictions on them...", which is wrong! This way leads to ever further restrictions. Think "Those who would give up their liberty to protect their liberty, um, will lose it, duh!" (This is why Nozick always slips into the State...)

Anyway, Linus has refused to add the patch to his source tree without broad consensus from major Linux distributions (which will never happen).

Again, I'm all in favor of a completely GPL'd kernel, with all modules that are needed (for anyone!) GPL'd, too. But not when it's forced on me.

The City Born Great - How Long 'Til Black Future Month?

The second story in N. K. Jemisin's anthology How Long 'Til Black Future Month? , "The City Born Great," is an exciting ta...