Thursday, July 12, 2012

Su for groups only?

Got a question from #debian on Freenode:

Q: How can I restrict "su" access for users?

A: Edit /etc/pam.d/su and uncomment.
# auth       required
If needed, change the other parameters, such as time restrictions, if password is needed etc.

Homebrew and Xcode 4.3.

Installed brew and some stuff never got complied, even though I used --use-llvm (no more standard gcc is available in later version of Xcode). I downloaded the command-line-utils from Apple, but still no go.

Turns out you should install those via Xcode instead (Preferences -> Downloads -> Command Line Tools). Install them and brew away!

Xcode Preferences.

Sunday, July 8, 2012

Recover data from failing drive.

I have used dd in the past, but dd is intelligent when copying data from a failing disk. What you want is some software that intelligently copies byte data from different part of the drive not to stick in a failing area.

ddrescue to the rescue! (phun intended). ddrescue covers all of the above and is available via
apt-get install gddrescue
(There is another software called dd_rescue, but this has largely been superseded by GNU ddrescue).

Just fire up ddrescue with infile and outfile, I'll use a logfile as well since I don't want it to try previously read sectors from a failing drive.

ddrescue /dev/sdX failingdrive.img failingdrive.log

And that's it!

When people have a failing drive they usually prioritize images for recovery, and for that we can use the splendid tool photorec. Photorecovery can work directly on a drive or file, but since I'm trying to be as gentle as possible with the failing drive I rather use it on my drive image. I'll use a logfile here to for resuming recovery and specifying a directory for the recovered images:

photorec /log failing-photos.log /d ~/recovered_images failingdrive.img

After that you will have to select which partition to search for images, or just specify the whole drive and search. Use apt-get install photorec to install.