Ddrescue saves the day…eventually

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Linux | One comment

So, after a Linux crash that caused my previous ddrescue to fail(after 350GB), I started to look into how to speed it up, because 30+ hours did not sound like a good idea to me.
I look into ways to speed it up and using a larger block size did the trick. I experimented with a few different sizes and figured out that using 2M gave me the best throughput. So instead of a couple of megs a second i was getting over 24 MB/s. So about a 4 1/2 hour recovery after that.

ddrescue -b 2M /dev/sda2 /media/newdisk/olddata /media/newdisk/logfile

The ddrescue process will attempt to recover any lost sectors and retrim the lost data. Luckily, I only lost about 3100k of data so the most of my data is safe.

You can attempt to rerun ddrescue with the -r <# of times to retry> and it will continue to attempt to read those failed sectors that were unrecoverable. There is no guarantee that you will get back all the data.

Once this data is recovered, you can (hopefully) mount this file as a disk under linux.

 mount /media/newdisk/olddata /mnt/newdisk 

Now remember to back up your data and you will not go through the pain that I did to recover this data.

Part 1 of article

Tags: , ,

When a hard drive fails, ddrescue could save the day

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Hardware, Utilities | One comment

So I was trying to do some work the other morning in my hotel room and my Windows 7 computer gave me the dreaded blue screen of death and would not boot past loading a certain library file. I was able to boot into an Ubuntu disk that I happened to have and found that there were many S.M.A.R.T. errors on the disk and wished I had thought to monitor this. So it seemed that my drive was cooked and I could not get any of the data from it.

    I was disappointed that Spinrite was unable to save me from the problems that I was having and I paid 90 bucks for it. So I turned to tools in Linux that might do the job. I had used the dd utility to copy the contents of my drive to a new drive in the past, but dd will exit on the first error. So I found that there is an addition to the dd program called ddrescue which is part of the GNU Project.

This utility will let you copy the contents of a disk or partition and allow you to skip the errors or even retry the error spots a number of times.

The command line is something like:

    ddrescue -r 3 /dev/sda1 /media/newvolume/diskimage.iso /media/newvolume/logfilefordiskimage

The really nice thing is if you have to stop the command for some reason, it will restart from the end of the log file. It does take quite a bit of time. I am 6 1/2 hours into recovering a 500GB disk, but it beats losing all my data. I will follow up this post with the results of the rescue and the next steps I took to recover the data.

Part 2 of article

Tags: , ,

Mounting drives in Linux

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Linux, OS, Uncategorized, Utilities | No comments yet.

Sometimes you have a drive that your want to mount under Linux. The mount command can make the drive available to you. But you need to also create a directory to hold the mount point.

mkdir /mnt/drivepoint

Then you can mount the drive to that mount point by using the mount command and giving the device identifier, in this case it is /dev/sda1, and the mount point which we created as /mnt/drivepoint. One thing to note, is that the mount will use whatever directory you specify, so if there are files located in the directory you use as a mount point, they will no longer be visible.

mount /dev/sda1 /mnt/drivepoint

This must be run as root or with the sudo command.

Tags: , ,

WordPress blank pages after updating

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Wordpress | No comments yet.

Recently I upgraded to WordPress 3.2.1 and in the midst of this I was fixing a problem in my functions.php file. It turned out that using the editor happened to leave an extra line at the end of my functions.php file and this caused all of the admin pages to no longer load. I removed the extra space at the end of the file and now I am able to admin my site.

So check any recently updated files and make sure there are no erroneous spaces at the end of the files.

Tags:

WordPress fix for 28px margin issue

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Wordpress | No comments yet.

I was tearing my hair out the other night trying to figure out why there was a 28px margin at the top of the page that I don’t remember setting up. I searched the for the issue and found that there is an issue with the version I am stuck on and the work around is to put the following code just before the </body> tag in footer.php.

 <?php wp_footer(); ?>;

Tags:

Perl: CPAN installing modules

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Perl, Programming, Scripting | No comments yet.

Sometimes it is necessary to install other modules into the Perl environment. Luckily there is a great repository of modules known as CPAN (The Comprehensive Perl Archive Network). This lets you install modules to help with encryption, XML,YAML, and many other things. There are a few ways to install a package and here are the ones that I use the most.

Using the CPAN shell:

perl -MCPAN -e shell

This will open a command prompt that will let you search for CPAN modules with:

i /PACKAGENAME/

or install a new module:

install /DateTime/

The nice thing about installing with CPAN is that it will look for the dependencies and suggest installing them before the module you requested.

NOTE:This can take some time and your dependencies could have dependencies.

The other method I use is to skip the CPAN prompt and just directly execute the install of the module:

perl -MCPAN -e 'install DateTime'

This is just the most basic of usage, and there is probably a lot more you can do, but I have not had to use much more than this.

Tags: , ,

Gallery of Hello World!

digg del.icio.us TRACK TOP
By Eric Downing | Filed in C/C++, C#, Java, Perl, PHP, Programming, Python, Ruby, Rust, Shell | No comments yet.

Here is a list of the Hello World Programs for different languages:

C

#include <stdio.h>
int main()
{
printf("Hello World!");
}

C++

#include <iostream.h>
int main()
{
cout << "Hello World!" << endl;
}

C#

public class HelloWorld
  public static void Main()
  {
    System.Console.WriteLine("Hello World!");
  }

Java

class HelloWorld {
static void main(String[] args)
{
System.out.println("Hello World!");
}

SHELL

echo "Hello World"

Python 2

print "Hello World!\n"

Python 3

print ("Hello World!")

Ruby

puts "Hello World!"

Perl

print "Hello World!n";

PHP

  <?php      
    print "Hello World!";
  ?>

Rust

fn main() {
    println("Hello World!");
}

This is the simplest form of Hello World for most of these languages.

Tags: , , , , , , ,

Using tar over ssh

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Scripting, Uncategorized, Utilities | No comments yet.

Every once in awhile, I need to backup a large directory from another computer. This can be done by creating a zip or tar of the files you are looking to save and then copying those zips to the other computer. But what it you have a very large directory and not enough room to store the extra file. Here is a way to use tar over ssh:

ssh tar zcvf – /wwwdata | ssh root@backupserver.mydomain.com “cat > /backup/wwwdata.tar.gz”

Setting timestamp with Touch

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Linux, Scripting, Uncategorized, Utilities | No comments yet.

Did you know? You can Set file timestamp using touch command. One way to do this is:
touch -c -t YYMMDDhhmm filename.txt

Best Learning sites(in progress)

digg del.icio.us TRACK TOP
By Eric Downing | Filed in Uncategorized | No comments yet.

Learnable
www.learnable.com
Brought to you by Sitepoint. They have created a site to host their on-line classes and a place for people to create their own as
well.

Udemy
www.udemy.com
Just checking this one out, I found some interesting courses, but many seem to be placeholders for classes to come later.

LiveMind
www.livemind.com
Just read about this one and have not looked thorugh it very much yet.