Backup & Restore in Knoppix

Everyone has nightmares about losing their machines. If the worst happens, you should be OK if you took a backup.

A colleague of mine, Colin Markwell, compiled a helpful little guide to doing just this with Knoppix. (I liked this, as Knoppix once saved me from a very difficult situation!). He pointed out to me:

note the links at the bottom of the file where most of the info came from.  My notes are pretty-much just a compilation of info from them Still helpful, Colin!

Heres the guide, not prettily formatted, but easy to follow.







Source: The first partition of the first hard drive (/dev/hda1), which is

10Gb and formatted with the FAT32 file system.

Destination: A ext3 partition on an external hard disk (/mnt/sda2).




Boot into Knoppix and mount "sda2" (destination drive we’re backing up to)

by right-clicking on the icon and selecting "mount", then make it writable

by right-clicking the icon again and selecting Actions > Change read/write

mode.  Open a root shell (KDE Menu > Knoppix > Root shell).

Back up the Master Boot Record – MBR – (this contains code to boot first

partition and the partition table for up to 4 primary partitions):

  dd if=/dev/hda of=/mnt/sda2/hda-mbr-20041124 count=1 bs=512

Note: bs = block size (in bytes) – the MBR is 512 bytes long.

Back up the partition:

  dd if=/dev/hda1 bs=1k conv=sync,noerror | gzip >/mnt/sda2/hda1-20041124.gz

Note: gzip compression used to backup faster and reduce the file size.

sync,noerror ensures that if there’s a problem reading the source drive, dd

still writes the correct number of bytes so that later data isn’t incorrectly

offset.  Using a block size of 1k minimises the amount of data lost if a block

can’t be read.

Make a note of the partition sizes:

  fdisk -l /dev/hda >/mnt/sda2/hda-partition-info.txt


To back up the extended partition table (Not used this in the restore, as I

was restoring to a smaller drive and only wanted to restore the first

primary partition):

  sfdisk -d /dev/hda | dd of=/mnt/sda2/hda-partition-table-20041124





Boot into Knoppix and mount "sda2" (drive that contains the backup)

by right-clicking on the icon, DON’T make it writable (prevents accidently

overwriting the backup).  Open a root shell (KDE Menu > Knoppix > Root shell).

If you need to create the partition (not necessary if restoring the partition

table as part of backing up the mbr, or if the partition already exists):

  fdisk /dev/hda


  n [new partition]

  p [primary]

  1 [1st partition]

  <accept default first cylinder>

  1275 [end cylinder – obtained from hda-partition-info.txt]


  Note: The partition can be larger than the source partition if necessary


  p [print table – confirm size matches the source partition]


  t [change partition’s system ID – use l to list]

  c ["Win95 FAT32 (LBA)"] – NTFS is 7 I think


  a [toggle bootable flag on]

  1 [1st partition]


  w [write and quit]


  Reboot Knoppix so everything’s aware of the new partition layout.

Restore the MBR (without the partition table):

  dd of=/dev/hda if=/mnt/sda2/hda-mbr-20041124 bs=446 count=1


Note: The partition table is at the end, bs=446 ensures we don’t overwrite it.

To restore the partition table too, leave off the "bs" and "count" arguments.

Restore the partition:

  gunzip -c /mnt/sda2/hda1-20041124.gz | dd of=/dev/hda1 bs=1k conv=sync,noerror

To restore the extended partition table (Not used this in the restore, as I

was restoring to a smaller drive and only wanted to restore the first primary


  sfdisk /dev/hda </mnt/sda2/hda-partition-table-20041124

  Reboot Knoppix so everything’s aware of the new partition layout.




Splits into 1Gb files, named as follows:



hda1-20041124.gz.02  …and so on.

  dd if=/dev/hda1 bs=1k conv=sync,noerror | gzip -c | split -b 1024m -d – /mnt/sda2/hda1-20041124.gz.

Note the dot at the end of the command




cat hda1-20041124.gz.* | gunzip -c | dd of=/dev/hda1




Format a partition with the FAT32 file system:

  mkfs.vfat -F 32 /dev/whatever


Note that this is useful as Windows XP doesn’t allow you to format partitions

larger than 32Gb with FAT32.






On the machine containing the backup destination:

  Open a root shell (KDE menu > Knoppix > Root shell)

  Change the root password: (Enter this when prompted by ssh on the client)


  Start the ssh daemon:

    /etc/init.d/ssh start

Backing up partitions


On the machine that is to be backed up:   

  Backup MBR:

    dd if=/dev/hda count=1 bs=512 | ssh -c blowfish root@ "dd of=/mnt/sda2/oldpc-mbr-20041127"

  Backup /dev/hda1

    Method 1: Compress on source machine and send over network compressed to a file:

    dd if=/dev/hda1 bs=1k conv=sync,noerror | gzip -c | ssh -c blowfish root@ "dd of=/mnt/sda2/oldpc-hda1-20041127.gz"

    Method 2: Send over the network uncompressed and compress on the

    destination machine.   Use this if you’re backing up a slow machine to a

    quick machine over a quick network:

    dd if=/dev/hda1 bs=1k conv=sync,noerror | ssh -c blowfish root@ "dd bs=1 | gzip >/mnt/sda2/oldpc-hda1-20041127.gz"

    Method 3: Don’t compress.  Use if backing up slow machines over a quick


    dd if=/dev/hda1 bs=1k conv=sync,noerror | ssh -c blowfish root@ "dd of=/mnt/sda2/oldpc-hda1-20041127"

    (replace filename with device (e.g. /dev/hda1) if restoring partition, rather than backing up to a file)

    Method 4: Compress, send over network, uncompress.  Use if backing up

    over a slow network.   


    dd if=/dev/hda1 bs=1k conv=sync,noerror | gzip -c | ssh -c blowfish root@ "gzip -d -c | dd of=/mnt/sda2/oldpc-hda1-20041127"

    (replace filename with device (e.g. /dev/hda1) if restoring partition, rather than backing up to a file)

  Copy across partition table information

    fdisk -l /dev/hda | ssh -c blowfish root@ "cat >/mnt/sda2/oldpc-partitions.txt"

Use "top" to monitor CPU performance (gzip + ssh bottlenecks) and KDE System

Guard to monitor network usage (KDE menu > System > KDE System Guard, look

under Network > Interfaces > eth0 > Receiver > Data, drag+drop onto graph

grid thing as "Multimeter" type).


Backing up files


On the source machine:

  Mount relevant partition (for example):

    mount /mnt/hda1


  Copy files:


    cd /mnt/hda1

    tar cv . | ssh -c blowfish root@ "cd /mnt/sda1/OldPC-C ; tar x"

To compress files using gzip, use the z flag:

    tar zcv . | ssh -c blowfish root@ "cd /mnt/sda1/OldPC-C ; tar zx"


Note that a list of files being copied will be output to the screen on the

source machine (due to the tar "v" flag).




This doesn’t use encryption, so may be faster than ssh if CPU resources

are limited.

Backing up partitions


Backup MBR:

On the destination machine, enter the following:

  netcat -l -p 10000 | dd of=/mnt/sda2/hda-mbr-20060326


  "-l" = listen for incoming connection

  "-p 10000" = listen on port 10000 – change if required.

On the source machine, enter the following:

  dd if=/dev/hda count=1 bs=512 | netcat -w 5 10000

Backup /dev/hda1:

Destination machine:

  netcat -l -p 10000 | dd of=hda1-20060326.bin


Source machine:

  dd if=/dev/hda1 bs=1k conv=sync,noerror | netcat -w 5 10000

Compressing on source machine (sent over network compressed):

  dd if=/dev/hda1 bs=1k conv=sync,noerror | gzip -c | netcat -w 5 10000

Compressing on destination machine (sent over network uncompressed):

  netcat -l -p 10000 | gzip -c | dd of=hda1-20060326.gz

Copying across partition table info:

  Destination machine:

    netcat -l -p 10000 >hda-partition-info.txt 

  Source machine:

    fdisk -l /dev/hda | netcat -w 5 10000

Backing up files


On the destination server, go to the directory you want the files to be

copied to and enter the following:

  netcat -l -p 10000 | tar x

If you want to see a list of files on the destination server as they’re

copied, add the "v" switch to tar:

  netcat -l -p 10000 | tar xv

Ensure the destination server is running before running the command

on the source machine.


On the source machine, go to the directory you want the files to be copied

from and enter the following:

  tar c . | netcat -w 5 10000

  "-w 5" = wait 5 seconds for input before closing connection and ending.

If you want to see a list of files on the source machine as they’re copied,

add a "v" option to tar:

  tar cv . | netcat -w 5 10000

If you want to gzip compress the files as they go over the network, add

the "z" option to tar:



  netcat -l -p 10000 | tar zx


  tar zc . | netcat -w 5 10000




Mount the shared drive:

  mkdir /mnt/win_share

  smbmount // /mnt/win_share -o username=colin,password=secret

Then backup/restore as you would do locally.

[ From: ]




Lessons from Jamie Zawinski

I’ve loved stuff on the internet for quite a while. having had a variety of presence back for 14/15 years.

When I started using Netscape I remember being able to do “about:jwz” and find all sorts of interesting things.

I like clever people; I look bemused at the stuff Paul Downey (@psd) does – and loved The URI Is The Thing and The Web is Agreement.

He has a bee in his bonnet about Flash (OK, he has other bees) and style over content

You don’t need stuff to be unreadable to be attractive.

One of Paul’s erstwhile colleagues, Phil Hawksworth, (@philhawksworth), is a passionate advocate ofUnobtrusive Javascript and Progressive Enhancement  – and made an explanatory site about this. You can see the site at, and read how unobtrusify works.

So, you can make stuff look good and read properly.

So, why the link to jamie Zawinski (@jwz)? Because the problem’s been there forever.

Back in 2001 Jamie put up a post about Design; some of the stuff in there has dated, a little – time has moved on since 2001.

Having said that, some quotes give you a flavour.

“Now, there’s nothing wrong with trying to make your web pages look good to the largest number of people. But it’s a matter of priorities: if you place a higher value on the layout than on the meaning, then you don’t value your words very highly.”

“More often, you see sites whose top-level page is entirely devoid of text and hyperlinks. It’s usually black, and usually has some kind of time-wasting animation going on. These days, more often than not, a huge Flash file with a spinning logo.”

If the site uses all the latest crap, then it means that whoever’s site it is is more concerned with appearance than content, and the only reason for that would be that their content is crap. If they had worthwhile content, they wouldn’t have to dress it up in gaudy trappings to get people to think that there’s something there.”

If all these clever people recognise the problems – why don’t some web designers, and the companies they work for?

I couldn’t follow all that stuff; I can’t even keep up with my email

<img src=””&gt;

I was talking about Twitter and Facebook, to a group of friends who are mixed age, but all professional.

They were aghast when I said I read blogs, used Facebook and Twitter. None of them knew what RSS was, or how it could help you manage the stream of data.

One colleague said “Well, I don’t see how you manage *your* email. You must have hundreds of addresses.” [I run the,, domains, and several others, and post from whichever one is appropriate].

I explained I did them all from one mail client – which was my gmail (OK, Google Apps for Your Domain email, but I didn’t feel like quibbling); I’m fairly certain they didn’t believe me. *I* felt like crying.

There has to be scope to offer some easy training to peers; I’d happily do this pro bono.

Never mind a Windows 7 party.

Anyone ever fancied running RSS and gmail parties?

Image Credit: a4gpa

removing your signature from Posterous

More and more people are using posterous, and I can see why.
I use it as a sort of mini-blog/maxi-Twitter – as it’s so easy to get content into it.

I’ve notice one or two  people using Posterous and ending each entry with their email signature…

Reading the FAQ , I learn

Remove your email signature
End your post with ‘#end’ and we’ll ignore any text we find after that.

I hope that helps anyone new to Posterous a bit.

Streaming Spotify through Squeezebox – easily!

After my last solution, I was pointed to a simple solution using DSBridge.

vagskal at
provided the following briefing, which I reproduce here for reference:

“It is quite simple on Windows:

1. Close Spotify (right click on the Spotify tray icon and select

2. Find your Spotify folder (where spotify.exe is). It is usually under

3. Download DSBridge from Put the
files “DSound.dll” and “dsbridge.ini” in your Spotify folder.

4. Find on the Internet the file “lame_enc.dll”, preferably v. 3.98.2
(hint: Put the
file “lame_enc.dll” in your Spotify folder.

5. Start Spotify and play something. You will notice a new tray icon.

6. Go to your web browser and open SqueezeCenter (you will need a
computer running SqueezeCenter to use DSBridge, I think). Go to
Favourites and choose Edit. Choose New Favourite and type a name for the
favourite (i.e. Spotify). If you are running Spotify on the same PC as
SqueezeCenter: Type “http://localhost:8124/&#8221;; as the url for your new
favourite. – If you are running SqueezeCenter and Spotify on separate
machines on a local network, you will have to find the IP address (on
your local network, something like 192.168…..) of the machine running
Spotify and type that instead of “localhost”.

7. “Play” the new Spotify favourite, via the web interface or iPeng,
and whatever is playing on Spotify will play on your SB3.”

It works fine on my old Squeezeboxes.