Thursday, November 13, 2008

Backing up a new laptop

So I got a laptop, a Lenovo T500. But what to do with its funky Vista OS?

Well, wipe it out, of course! With Ubuntu perhaps. But nevertheless I'd like to keep a backup of what came in the hard drive. So, here is what I did.

1. Boot with Ubuntu Ibex. For that I had to get to the BIOS and force the Laptop to prefer to use the Intel card. Otherwise Ubuntu gets real confused about having two cards.

Once it booted I opened a terminal and got root.This assumess that networking works fine, the HDD works reliably, etc.

sudo -s


2. Mount a CIFS share to my desktop.

mount -t cifs -o user=my_username_there //mycomputer/my_username_there /mnt

cd /mnt


3. Backup the partition table

sfdisk -d /dev/sda > the-windows-partititon.dump


4. Backup the MBR

dd if=/dev/sda bs=512 count=1 of=the-windows-mbr


5. Now it is time to get to the main issue:

ntfsclone -s -o - /dev/sda1 | gzip | split -b 1000m - the-windows-sda1.img.gz_
ntfsclone -s -o - /dev/sda2 | gzip | split -b 1000m - the-windows-sda2.img.gz_
ntfsclone -s -o - /dev/sda3 | gzip | split -b 1000m - the-windows-sda3.img.gz_


To restore:

1. Boot with Ubuntu, open a terminal, get root

sudo -s


2. Mount a CIFS share to my desktop.

mount -t cifs -o user=my_username_there //mycomputer/my_username_there /mnt

cd /mnt


3. Restore the partition table

sfdisk /dev/sda < the-windows-partititon.dump


4. Restore the MBR

dd of=the-windows-mbr of=/dev/sda bs=512 count=1


5. Now Restore the partitions:

cat the-windows-sda1.img.gz_* | gunzip -c | ntfsclone --restore-image --overwrite /dev/sda1 -
cat the-windows-sda2.img.gz_* | gunzip -c | ntfsclone --restore-image --overwrite /dev/sda2 -
cat the-windows-sda3.img.gz_* | gunzip -c | ntfsclone --restore-image --overwrite /dev/sda3 -

Sunday, October 19, 2008

Towards easier suspend for my PC

I have several PCs at home (Debin Sid). It uses a lot of power. I fear the elctric bill, but I like my PCs to boot fast...

Suspend (suspend to ram) to the rescue!!! ^_^

That is, when it works. But fixing things is already discussed elsewhere. In my case it meant not using the forcedeth Ethernet card on the mother board, but a an oldish PCI 3com instead (although I'd still like to be able to WoL so I might change the 3com for another one).

But I digress. What I've done so far has been to:


  1. Convince pm-tools that yes, it is OK to force s2ram.


  2. Coax GDM to use s2ram -f


  3. Get into every account I have at home and set power management preferences to suspend after 1 hour of inactivity and to suspend on the power button.


  4. Modify the ACPI power button script to suspend instead of powering down. ACPI calls this script to make KDE and/or GNOME aware of the power button action or to shutdown by default otherwise



In short, I wanted to make it really easy to suspend instead of powering down.

For 1) I edited some file in /etc... Unfortunately I had to try so many things I do not remember what I did to successfully make suspend to work, even tough s2ram complains the machines are unknown.

For 2) one I edited /etc/gdm/gdm.conf and added under [daemon]


SuspendCommand=/usr/sbin/s2ram -f


For 3) I just logged into every account (I am root afer all) and changed the power settings for KDE and gnome. I am sure there is a way to change the default. I just got lazy. After fixing everything else.

For 4) I edited /etc/acpi/powerbtn.sh to to s2ram -f instead of the usual shutdown:


# If all else failed, just initiate a plain shutdown.
#/sbin/shutdown -h now "Power button pressed"

# regelatwork: canged to sleep instead of shutdown
/usr/sbin/s2ram -f


This is still not good enough, though. It is still too easy to shutdown from inside a session. It'd be nice to have a simple way to do a logout+suspend instead. Better still for that to be the default logout option and for shutdown to ask something like "are you sure you do not want to logout and suspend instead?"

Also, it is too easy to Shutdown from GDM (it is the default Action). I'd like a similar warning message along with suspend as the default.

Pehaps I'll have to bite the bullet, get my hands dirty and code some scripts and modify some Gnome/KDM code to have things my way.

Tuesday, September 16, 2008

Unlearning bash

At debian's IRC someone asked how to replace ***.png to ***.jpg. To which I replied a "bashism."
Fortunately someone else corrected my bash-istic ways on time.

So how to unlearn those pesky bash-ways? It seems the IEEE comes to our rescue with the Open Group Specification.

Other tools seem to be debian's checkbashism command and the ol' technique of using dash instead (with some dose of cursing in between ^_^).

Update: It is a bashism to use the nifty regexp substitution

${var/\.oldext/.newext}

One should instead use the standard way of cutting trailing substrings from a var:

${var%.oldext}.newext

Thursday, September 11, 2008

Lost Trashcan

It seems I am like other people with respect to icons on the Desktop. One day I love them, the next they are a nuisance on my beautiful wallpaper.

I use Gnome and today I wanted my icons back. Do not panic, says the ol'book. Someone else already figured it out.

Neat, ain't it?

Now, if KDE and Gnome could just agree on how to represent these pesky icons so I did not have to delete/add/recycle them every time I decide KDE Gnome is the best thing in the world.

Thursday, August 7, 2008

Hello World!

Can my first blog post be lamer?

As I'm trying to write a dissertation proposal I guess it will have to do for now.