Archive for the 'Linux' Category

Recovery of a Vista Laptop Hard Drive (using Linux).

Tuesday, February 15th, 2011

Some bad sectors cropped up on my wive’s laptop and her Vista Home Premium x86 would not boot. I, of course, am the resident tech support dude in the house, so it was up to me to restore Vista to a boot-able state.

I took a new drive allocated for the long overdue Windows 7 upgrade and copied a backup of the damaged Vista drive to it. At first, I tried to use SpinRite to scan and repair defects of the original Vista disk, however it took too long. So, I decided to use ddrescue to recover the data on the disk:


DDRLOG=/tmp/ddrescue-20110208.log
# see info ddrescue for more complete notes on its use.
# avoid the bad sectors on the first dump of data
ddrescue -n /dev/sda /dev/sdb $DDRLOG

# rescan the drive around the bad sectors and recover data (attempt 3 reads
# on bad sectors)
ddrescue -d -r3 /dev/sda /dev/sdb $DDRLOG

# save DDRLOG to some place.
ddrescue is part of the excellent “Ubuntu Rescue Remix” distribution. Boot into this Linux distro and then let the magic happen with the above ddrescue commands. For info about this distribution and other recovery tools please see this article.

Note: I had to rescue the disk in its entirety to have Windows Vista boot normally after the data recovery on the new drive. “ddrescue -n /dev/sda2 /dev/sdb2″ did not work for me. I am not sure why. A Vista setup DVD was able to detect /dev/sda2 and found a Vista OS installed on the partition. More over the Vista Setup DVD was able to repair the file system. And it attempted to perform Start Up Recoveries of the Vista partition. However in the end I was not able to make Vista boot properly using the single partition ddrescue copy. [I wasted three calendar days because of this mistake. Don’t repeat my mistake.]

Copying the disk and all its partitions in its entirety in one fell swoop did work for me. So I recommend the first set of ddrescue commands documented in this post when working with Vista.

Why was restoring Vista to a boot-able state so important before the Windows 7 upgrade? In order to install Windows 7 in an “upgrade” mode, Windows Vista must be boot-able and able to run the Windows 7 installer. (Thanks, Microsoft, for making the simple hard.) The Upgrade mode of the installer was preferred by my wife. The Upgrade mode retains all the installed Windows applications and other things added to Windows (such as fonts in my wife’s case).

After the original Vista Home Premium x86 was restored to a bootable state, I attempted an upgrade from Vista to Windows 7. (It was overdue anyway!) We had purchased a Windows 7 Ultimate 64-bit edition DVD, however this edition of Windows can not be applied to a Vista HP (32 bit) in Upgrade mode. Nice, Microsoft! Thanks again for making the simple hard!

So back to the store, I picked up a copy of Windows 7 Home Premium (32 bit). This version of Windows 7 allowed the original Vista Home Premium x86 edition to be upgraded.

After all this, Windows 7 happily boots on the laptop with the restored data. To date of this post, no lost data has been reported by my wife, so I assume the majority of the data on the Windows partition was preserved by ddrescue.

Thank you ddrescue for making the hard easy!

Simple Linux Backup Method

Thursday, May 13th, 2010

For a simple Linux backup solution, I often use rsync.

You need to identify the file systems that need to be backed up. From the command line:

df -h

As a side note you should create a separate file system for your applicaton. RHEL or Linux does not normally do this for you. The advantage to doing this is, it is much easier to upgrade the operating system when your application files are not stored on the root file system.

Back to the task at hand, let’s say you added an extra disk to your server and have it mounted at /backup. You can run rsync from the command line:

rsync -aPv --one-file-system / /backup/root/

The above command should backup your root file system to /backup/root/. I usually like to add dates to these backup directory so I can restore a file from a point in time. The -P rsync option gives you verbose progress information. This is great when you run it interactively.

You can automate this command by putting it into a shell script.

# create file: /etc/cron.daily/backup.sh

#!/bin/bash

/usr/bin/rsync -av --one-file-system / /backup/root/

You will need to set the execute bit on the newly created backup.sh script

chmod +x /etc/cron.daily/backup.sh

Once you have created /etc/cron.daily/backup.sh it should be run every day by the Linux cron.

How to make audio work with a Windows XP VMware guest hosted on Fedora 11

Sunday, July 12th, 2009

Update: December 2010. I have given up using Skype under VMware for quite some time now; for almost a year! The Linux Skype Beta Client 2.1.0.81 software is quite good and supports my “Skype-In” and “Skype-Out” features I previously needed VMware for. So, if you need to use Skype with Linux, I recommend you install the Linux Client it is very stable and full featured now!

My Windows XP instance has enjoyed running on bare metal for the last time in my office. The machine flaked out for no apparent reason and crashed every 10 to 45 minutes. I have a Linux laptop where I do most of my work: e-mail, documents, web browsing and Java development. However recent clients have engaged me to write (gulp) .NET projects. So I have needed a XP workstation for the past several years for SharpDevelop, Visual Studio and the odd Windows tool.  Along with these Windows tools I have fostered an addiction to Skype 3.8.

I use Skype to route calls from my office number to answer on my Desktop. I also use Skype Out to dial US long distance numbers and to conference call multiple parties together on one line to make decisions happen. I should use SIP and Ekiga but I don’t at the moment.

So when my XP workstation melted down, my development and communication tools melted down at the same time.

I was so put off by Microsoft for destroying my productivity that I was determined to put XP into a virtual machine to make restoring it back to health faster. I am no stranger to VMware Workstation and Linux is my friend. So I thought it would be a snap to cobble together a working Windows XP virtual machine with Skype 3.8. I was partially right but it took the better part of two days to make VMware audio work the way I needed.

I installed 64 bit Fedora 11 on a pair of new software raided disks that I installed in my Dell Workstation which previously ran XP SP3. The Fedora 11 install went smooth. Everything worked well. The new Noveau NVIDIA driver drove my dual monitor setup well. The PulseAudio system delivered rock solid audio. VMware installed with relatively little effort after following the instructions found on this site: http://communities.vmware.com/thread/203231

With VMware working, I took my Windows XP virtual machine and resized its partition from 16 GB to 64 GB using clonezilla, gparted and ntfsresize. This all took some time and a lot of patience to execute (By the way why can’t XP check it’s file system reliably and why doesn’t NTFS continuously defrag its file system like ext3?). However there was still one nagging problem, the sound card was not being detected by VMware. Apparently the Linux version of VMware 6.5.2 requires a working /dev/dsp OSS device file to work. The default PulseAudio installation in Fedora 11 doesn’t provide a /dev/dsp device file. Nor did the PulseAudio padsp utility work for me with VMware 6.5.2.
I desperately needed audio support in VMware to run Skype 3.8 in XP. (Yes I know Skype 2.0 runs natively under Linux, but Skype 3.8 supports conference calling with real phone numbers, a 3.8 feature I have become accustomed to.)

Running “padsp vmware” did not produce working sound for me. VMware complained of not being able to detect the sound card.

I found these instructions to make VMware work with PulseAudio under Ubuntu 8.10 as described on this site: http://communities.vmware.com/thread/163605 . However the instructions lead me down a dead end and did not work under Fedora 11.
I experimented a little on my 32bit Fedora 10 and 64 bit Fedora 10 workstations. I discovered I could make audio work under VMware quite easily on Fedora 10. I also discovered that Fedora 10 provides a /dev/dsp device file from its OSS sound adapter. Determined that this was the answer to my 64 bit Fedora 11 workstation audio problem, I researched how to restore the /dev/dsp device file to Fedora 11.

I removed the alsa-plugins-pulseaudio RPM.

  • yum remove alsa-plugins-pulseaudio

Then I made sure the OSS modules were being loaded

  • sudo modprobe snd_mixer_oss
  • sudo modprobe snd_pcm_oss
  • sudo modprobe snd_seq_oss

I added my user account to the “audio” group . I explicitly specified my XP VMware instance to use the /dev/dsp device file with the sound.file parameter and set sound.autodetect = “FALSE”. I rebooted and crossed my fingers.

After more research I discovered this Fedora 11 bug, https://bugzilla.redhat.com/show_bug.cgi?id=501051. The author of comment #17 suggests:

“I needed to uncomment a line in /etc/modprobe.d/dist-oss.conf to load those
modules.. Appears they’re caught up in the “disable OSS” feature of F11.”
Uncommenting the referenced line in dist-oss.conf, ensures the aforementioned oss sound modules are loaded when Fedora boots.
To my surprise VMware was able to detect the sound card and allowed XP access to it. Skype 3.8 is now able to make calls. It appears I am back in business. I wanted to share the steps I took to make audio work with VMware and Fedora 11 in the hope they save someone the time and effort I spent to find my solution.

I also wanted to express my concern that the Fedora project is not good at maintaining backward compatibility. I can see the benefit of PulseAudio. It seems to make sound much more reliable under Linux. But the Fedora Project should make a better effort to maintain backwards compatibility with applications behind the curve such as VMware. From an outsider’s perspective it seems like it would be trivial to create /dev/dsp device files on demand and send the audio to the PulseAudio system. (padsp is suppose to do this but apparently doesn’t work with all applications including VMware) If such a capability existed, it would have been easier to resolve my VMware problems.

Enough ranting. Happy hacking.