Wednesday, December 29, 2010

Linux to the Rescue: Data Recovery

I had a user bring a machine running Windows to me earlier today that wasn't working right. I did something that I've done a bunch of times before to recover the data off of it. Here's what I did.

First I took a live Linux boot disk (I typically use OpenSUSE) and booted from it.

Once it's booted fire up a terminal. Using the live KDE version of OpenSUSE I pressed Alt-F2 and typed 'konsole'. Once the terminal is up type:

cd /dev

then:

ls

look for sdaX where 'X' is number. These are partitions on the first hard drive. If there's more than one hard drive in the machine check sdb, sdc, and so on. In the case from this morning there was an sda1 and an sda4. Being a Windows XP laptop sda1 was the primary partition on the first hard drive and sda4 was the 'recovery' partition put there by the people who put the laptop together. So what we've got to do now is mount that primary partition so we can get at the data. First I needed to created a directory to mount the partition on so I typed:

su

this made me root. There wasn't a password needed because it was a live disk boot. Then:

md /media/hd

This command created the directory to mount the partition on. The next step is to mount the thing. This I did by typing:

mount -o loop /dev/sda1 /media/hd

This mounts the device /dev/sda1 as a loopback device at the directory that was just created in /media/hd.

Once mounted you can go into the mounted partition and get at the data. So...

cd /media/hd
ls

will show you the contents. Now in my case I had a NAS on the network so I could copy the data off to that. I did this by again pressing Alt-F2 and typing:

dolphin /media/hd

This opened the default graphical file manager in KDE and pointed it at the freshly mounted hard drive partition. In my case the data that I was after was in "/media/hd/Documents and Settings/" so I navigated there. Once there I was able to see the files in the user's Desktop, My Documents, etc. folders. At this point I needed the connection to the NAS so I pressed Ctrl-t to get me a new tab in Dolphin. Then I did Ctrl-l so I could type the address I wanted to access. Again, in my case I typed in

smb://username@nas-hostname/sharename

A moment later the NAS responded asking me to enter in the password to access it. I entered it and created a folder by right-clicking-->new-->folder and called in FROM_OLD_MACHINE. Then I went into that newly created folder and flipped back to the first tab in Dolphin where the files that I wanted were. I clicked on the files and folders that I wanted to recover then dragged them to the tab in Dolphin that was showing the folder on the NAS; hovered there for a moment. When it switched over to that second tab I moved the cursor into that folder and let go of the mouse button. I then selected 'copy' and it started copying the files into the folder on the NAS.

As it turned out in this case the fix was relatively straight forward on the Windows side and I didn't need this backup but at least I had it.

Also, I know this wouldn't work if there was something screwie with the filesystem on that partition that I mounted. Never the less, in a large majority of cases where I'm given a Windows machine that won't boot I've been able to recover the data with this method. Even if I do end up having to re-install I've got the data from the original install.

Thursday, December 16, 2010

Time of Use Energy Billing

I just wrote to my MPP Peter Tabuns after hearing about a consultant's report delivered to the Ontario Energy Board that suggested a wider gap between 'On Peak' and 'Off Peak' times. Call me cynical but that sounds like higher on-peak rates rather than lower off-peak rates to me. The print version of the story I heard on the radio can be found at the CBC here.


Hi Peter,
I'm just hearing a story on the CBC's morning show news about a report from a consultant suggesting that there be a greater difference between energy rates depending on the time of use. (http://www.cbc.ca/canada/toronto/story/2010/12/15/ontario-electricity.html)

I don't suppose that the intention is to lower the off-peak time?

I'm concerned because like many I'm employed in a job that I don't have much control over what time I show up at so that tends to dictate what time I'm using energy.

It's kinda funny, I seem to remember reading a book that proposed something radical. Public power at cost. Humm, who wrote that... Howard something. Seems like a good idea. Too bad so many throw their votes away by voting Conservative and Liberal.

Anyway, I just felt that I needed to say something after seeing that story.

Keep up the good work.

kev.

The book I referenced is Public Power by former Ontario NDP leader Howard Hampton.


Later in the afternoon yesterday I got this reply from Peter's office:

Kevin, thanks for passing this along. The price is like a balloon. You
push in on one side and the other side bulges out. Any price change they
make affects all the others. You are in the same position as many -
their ability to change consumption at key times is really limited. Take
care. Peter

Doesn't really change anything. I guess there's a reason it's called 'peak'; because people are using it. Still, pretty good turnaround time on a random constituent's email.

Saturday, December 4, 2010

Farewell Transit City... We Hardly Knew Ye

Earlier this week the new mayor of Toronto announced that he had killed the plan to vastly expand the city's light rail network called Transit City (see the map below for the proposed routes). All the studies had been done and the shovels had gone into the ground. So instead of bringing rapid transit lines to areas all over the city the mayor has elected to go back to the drawing board and start another study; pretty much guaranteeing that it is going to be years before we get to see any substantial improvements to the public transit system. The preference for subways pretty much guarantees that any expansion will not be as extensive as that called for in Transit City. Personally I find this decision disappointing to say the least. Earlier today I went to the site of construction of the first line to say goodbye to Transit City.




Farewell Transit City... We Hardly Knew Ye

Saturday, November 13, 2010

Camp X

In December of 1941 Camp X was established on the shore of Lake Ontario. 69 years later (2 days after Remembrance Day here in Canada) I went there and took these photos in remembrance of some who aren't usually thought of when people think of Remembrance Day:

Camp X

Sunday, November 7, 2010

A November Sunday in Port Credit and Back

Went out to Port Credit in Mississauga this afternoon and took some pictures. I took a couple shots of Diwali celebrations in the Gerrard India Bazaar on my way back. Here's the route I took:


View A November Sunday in Port Credit and Back in a larger map

and the pictures:

A November Sunday in Port Credit and Back

Saturday, October 30, 2010

Walk through the Don Valley

Took my my new camera for a walk through the Don Valley today. Went from the Science Centre down to Gerrard St. It was too bad we had a bunch of wind earlier this week. I suspect it would've been a lot more colourful last weekend but at any rate. Here are the results.

Here's the Map as recorded with the MyTracks app for Android:

View Saturday Walk in the Don Valley in a larger map

And the photos:
Saturday Walk in the Don Valley


kev.

Saturday, October 2, 2010

Resizing the /boot Partition in OpenSUSE Linux

So after a couple of weeks (it was my home machine not a critical production server) of seeing the latest kernel update failing on my OpenSUSE 11.2 system because there wasn't enough space on the /boot partition I finally had to deal with this. Trouble is I had no idea how to deal with this. I've resized /home before but /home is right at the end of the drive array so shrinking it and growing it is relatively easy with the disk partitioning tool in YaST.

So with the help of this article http://www.timelordz.com/blog/?p=456 here's what I did.

From the command line I went into init 1 with the command:

su

Then the root password.

init 1

It'll shut down just about everything running and bring you to a prompt asking for the root password to enter maintenance mode. I again entered the root password then unmounted /home with:

umount /home

Then I brought up the command line version of yast with

yast

and brought up the partitioning tool and changed the size of the partition that gets mounted at /home (I brought it down by 1.5 GB). I've been caught in yast resizing partitions before with not entering the GB (or MB or TB) after the number. It took a while with this operation as the /home partition is fairly large but in the end I had 1.5 GB of unpartioned space.

Once done I went back into run level 5 by typing

init 5

The next step was to create a 1.5 GB partition and following the article in the link above I named it newboot. This was easy enough again using the partitioner in yast.

Once that was done again following along with the article I copied the contents of /boot into /newboot as root

cp --verbose --recursive /boot/* /newboot

The next step was to edit the /newboot/grub/menu.lst file. Trouble was that it wasn't immediately clear to me what to change it to. After a bit of trial and error (not really advisable when dealing with bootloaders I know!) I found that the newboot partition was at (hd0,9) in grubspeek (the old one was hd0,4). So, I got them changed over in menu.lst, crossed my fingers and typed 'reboot'.

When the thing booted I was quite pleased with myself until I realised that it was still booting from the old /boot partition. The fix was easy if a bit scary. I hadn't done the bit from the article where it says to:

# grub
grub> root (hd0,9)
grub> setup (hd0)
grub> quit
# reboot

So again crossed my fingers and typed reboot.

This time it booted but didn't have the fancy grub menu that openSUSE comes with. I then saw that I hadn't modified the gfxmenu line. I changed that to match the (hd0,9) of the kernel image I was wanting to boot from and all was good....

Well, at least until I tried to run the kernel update with:

zypper -n up

It was still erroring out saying there wasn't enough space on /boot to install. So, it's trying to install to /boot rather than /newboot. Makes sense, the standard place for it is /boot. No developer has any idea that I've gone and told my machine to boot from /newboot. So, back into the yast partitioning tool. I changed the mount point of /boot to /oldboot and that of /newboot to /boot saved the changes and rebooted just for good measure.

When the system came back up it booted from hd0,9 as written to the master boot record when I ran the commands at the grub prompt before. This time however the partition at (hd0,9) was being mounted as /boot rather than /newboot. So again I ran the update:

zypper -n up

This time with all the pieces in place the new kernel installed on my new 1.5GB /boot partition.

So thank you Pete Eby for the article that pointed me in the right direction.