How to duplicate CF card contents

49 views
Skip to first unread message

patman

unread,
Feb 23, 2010, 3:48:51 AM2/23/10
to MicroClient
Hi all,

A few months ago I purchased a Microclient Sr.
I know a thing or two about Linux, but this was an adventure :)

I ended up installing DSL 4.4.10 on the CompactFlash drive.
After reading several posts in this group and the web I managed to get
it all working (yeah).

I have networking up and running and I am looking at ways to duplicate
the CF drive, just in case it fails. And perhaps make an ISO of it
that I can happily reinstall onto new CF cards.

Do any of you have experience with this?

I have available:

source: 1x Microclient Sr.
target:
Apple OSX 10.5 or 10.6;
or a laptop running DSL 4.4.10


What can you recommend to use?
1. dd command together with netcat (nc)?
2. CloneZilla?
3. ....

any links, examples etc would be highly appreciated

Thanks!

/patman

nicolas314

unread,
Feb 23, 2010, 4:37:40 AM2/23/10
to patman, MicroClient
Hi Patman:

'dd' is not always the best tool for disk backups. It will dump a bit-wise version of your disk onto a file, including inodes, directory and disk structure. In effect you will only be able to restore the resulting file onto a support that shares the very same properties as the initial one. Typically: if you use it to image a 2Gb CF card and restore it onto a 4Gb CF card it will have restored the disk structure along and you will see a 2Gb card. If the cards have different low-level format properties you may not even be able to restore the filesystem. This is actually the main reason why there is no Linux "ISO" image installation directly installable with a simple 'dd' onto a USB drive. You can make ISO images for CDs or DVDs because they all share the same low-level disk properties but not USB drives unfortunately.

I had great success backing up Linux disks using 'cp -ar', which copes with special files pretty well. An easy solution requiring no black magic is to:
- Take CompactFlash out, insert in a card reader on a Linux box
- Mount filesystem
- Issue as root: cp -ar /mounted/filesystem /path/to/backup/space

If you have no Linux box handy you can always use a tar/netcat combination like:
On the receiving end:
netcat -l -p 1234 | gzip -c > mc-backup.tar.gz
On your MicroClient:
tar cvf - / | netcat remote 1234

When tar has finished its job you need to issue a CTRL-C on your MicroClient to stop netcat processes on both ends.

In both cases, restoring contents onto a new CF card will need a Linux box or at least something that understands a Linux filesystem in order to write the files back with all information.

Don't know about Clonezilla but it certainly looks like it has all the features you need :-)

Hope it helps
--
Nicolas <nicol...@gmail.com>

Neef Herbert

unread,
Feb 23, 2010, 5:36:05 AM2/23/10
to nicolas314, MicroClient
Hi Nicolas,

Thanks for your quick response.
I changed the params a bit for netcat (Mac) and I do receive the files.

MC
tar cvf - / |nc -v  192.168.0.26 1234

Backup machine
nc -lv -p 1234|gzip -c > mc-backup.tar.gz

Next, I will mount CF (spare) on a different machine and restore the backup.

I will keep you posted.

Also will try your cp -ar aproach!

/patman

Bart N.

unread,
Feb 23, 2010, 6:26:06 AM2/23/10
to MicroClient
My 2 cents for the discussion: dump / restore ( http://dump.sourceforge.net/
but probably just included in your distro )

It copies the entire ext2/3 filesystem keeping all metadata intact. As
such it's something in between dd and cp/tar. I use it all the time
for replication. It's faster than dd because it doesn't copy blocks
not-in-use and it's faster than cp/tar because it follows the extfs
disk format, rather than recursing through the directory tree. Don't
be put off by the many tape-archive options you see in the man page,
it's still a good tool even though most of us moved past tape backups.

The dump and restore commands will write to/read from stdout/in
respectively using the -f - option.

Examples of use:

dump -0 -f - /dev/sda1 | bzip2 > sda1.dump.bz2

That's ^ a zero, indicating a level zero (non-incremental) backup.
To restore, you need to mkfs the new partition, mount it, cd into the
root dir and then:

cat sda1.dump.bz2 | bunzip2 | restore -r -f -

Or to clone from one partitition to another:

mkfs /dev/sdb1; mount /dev/sdb1 /mnt; cd /mnt
dump -0 -f - /dev/sda1 | restore -r -f -

This will work fine over netcat/ssh as well.

Hope this is of use.

Best regards,

Bart

> > Nicolas <nicolas...@gmail.com>

Neef Herbert

unread,
Feb 23, 2010, 7:42:00 AM2/23/10
to Neef Herbert, nicolas314, MicroClient
Help :|

I unmounted, mounted CF on different laptop w/USB cardreader

Just did the cp -ar stuff to /opt/backup/
and it worked.

unmounted and re-inserted the card into the microclient

After the complete bootstrap it says:

cloop: Initializing cloop v2.01
INIT: Entering runlevel: 3
Invalid device sda1
Press enter to continue:

When I press enter everything is okay.

Can any of you guru's enlighten me on what is happening?
I check /etc/fstab, /etc/mtab, etc/lilo.conf for sda1

any ideas where the error is coming from?

thanks.

PS What is the best way to format the CF card?
I have used cfdisk /dev/sda1 (type=83) so far.

/patman

Neef Herbert

unread,
Feb 23, 2010, 1:52:56 PM2/23/10
to Augusto Bott, nicolas314, MicroClient
Hi,

No I was talking about my original (fully functional) card,not the spare one.

/patman
On 23 feb 2010, at 19:31, Augusto Bott wrote:

> After copying the entire filesystem contents, did you install a boot
> loader (such as lilo, grub) in the new card?
>
> --
> Augusto Bott

>> --
>> You received this message because you are subscribed to the Google
>> Groups "MicroClient" group.
>> For more options, visit this group at
>> http://groups.google.com/group/microclient?hl=en

Augusto Bott

unread,
Feb 23, 2010, 1:31:23 PM2/23/10
to Neef Herbert, nicolas314, MicroClient
After copying the entire filesystem contents, did you install a boot
loader (such as lilo, grub) in the new card?

--
Augusto Bott

On Tue, Feb 23, 2010 at 09:42, Neef Herbert <neefh...@gmail.com> wrote:

Kelvin Nicholson

unread,
Feb 25, 2010, 3:24:15 AM2/25/10
to micro...@googlegroups.com
Hello:

My first thoughts were that the cp route wouldn't get you very far, and
that dd would be the best way to make sure you get the partition table
and MBR. On second though, I second Bart's instructions as using dump
would likely be much more efficient..

Good luck,

Kelvin

Neef Herbert

unread,
Feb 25, 2010, 4:49:01 AM2/25/10
to Kelvin Nicholson, micro...@googlegroups.com
Hi Kelvin,

I agree. I tested cp -ar and it does the job, but leaves some additional chores to be taken care of.

I have not been able to compile dump. I run DSL 4.4.x.
Installing tcc compiler was not enough, as ./configure indicated

./configure CC=/usr/bin/tcc

...
configure: error: C preprocessor "/lib/cpp" fails sanity check

and now I am lost.

ps Sorry for this since it is not completely related with the Subject of the original message

Bart Noordervliet

unread,
Feb 25, 2010, 8:09:55 AM2/25/10
to micro...@googlegroups.com
On Thu, Feb 25, 2010 at 10:49, Neef Herbert <neefh...@gmail.com> wrote:
> I agree. I tested cp -ar and it does the job, but leaves some additional chores to be taken care of.

Dump leaves some things to be done as well, most notably setting up
the boot loader. Grub works with block-offsets in its early stages,
which dd leaves intact, but tools like cp/tar/dump do not. So with the
latter, you'll always need to fix up /boot/grub/devices.lst and re-run
grub-install. Also, if your kernel parameters indicate the root
partition by UUID, you'll have to change that as well, because
whenever you mkfs, a new UUID is generated. Once more dd just copies
that over, which can be convenient.

> I have not been able to compile dump. I run DSL 4.4.x.
> Installing tcc compiler was not enough, as ./configure indicated
>
> ./configure CC=/usr/bin/tcc
>
> ...
> configure: error: C preprocessor "/lib/cpp" fails sanity check
>
> and now I am lost.

I'm afraid I can't help you there, I only use dump on debian
(apt-capable) systems.

Regards,

Bart

Neef Herbert

unread,
Feb 25, 2010, 8:24:00 AM2/25/10
to Bart Noordervliet, micro...@googlegroups.com
Hey Bart,

Thanks (dank je),

I still use LILO.
I will have a go with 'dd'.

/patman

Neef Herbert

unread,
Mar 1, 2010, 7:25:42 AM3/1/10
to MicroClient
Hi all,

Thanks for your input(s).
I found the bit that caused the 'Invalid device sda1'

I started DSL in X to find a command that would (maybe) allow me to duplicate the CF card.
Upon shutdown of X server a tickbox for Backup (settings) was enabled and wrote the entry "sda1" in /opt/.backupdevice

Now it is removed and solved.

/patman 

Andrew

unread,
Apr 13, 2010, 3:31:23 PM4/13/10
to MicroClient

Well, I actually use dd to backup and copy the CF filesystem on my
server. It has some advantages. I can mount the image using a loop
device and edit it. It copies everything. It is very easy to copy the
contents back to a CF device, or a USB device or even a hard drive
partition.

Obviously restoring to a smaller device is a problem. Restoring to a
larger device is no problem: after I restore the filesystem I resize
it using parted.

One handy trick is to write zeros to the empty space before I compress
the image file. To do that, I mount the image, then create a file full
of zeros:

dd if=/dev/zero of=/mnt/loop/zerofile.zero bs=512
rm -f zerofile.zero

Now all the empty space has zeros in it and it will compress smaller.

If you decide to use the cp command and you are copying the active
filesystem then you should relocate the /dev directory and use the -x
switch:

cd /
mkdir /udev
mount --move /dev /udev
cp -ax / /mnt/backup_device

Remember to move the udev directory back when you are done:

mount --move /udev /dev

later,
andrew.

Reply all
Reply to author
Forward
0 new messages