LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   *BSD (https://www.linuxquestions.org/questions/%2Absd-17/)
-   -   duplicate CF card using dd (https://www.linuxquestions.org/questions/%2Absd-17/duplicate-cf-card-using-dd-703915/)

doxJeremy 02-11-2009 11:20 AM

duplicate CF card using dd
 
Hello everybody,
I have a CF card with NetBSD installed on it that I need to duplicate. I have a linux box with one external USB CF card reader that I'm using to put the image on the hard drive using dd. Then I put that image on the new CF card. The problem is when I boot from the new CF card the NetBSD bootloader starts, but then the computer reboots. It cycles like this 4-5 times then the computer tells me there's no bootable disk available. Here's my dd commands:

From CF card to hard drive:
Code:

dd if=/dev/sdc of=cf_card
From hard drive to new CF card:
Code:

dd if=cf_card of=/dev/sdc
I've tried this several times and I'm getting the same results. Shouldn't dd work for my purpose? The original CF card works just fine when booting from it. Is my dd command somehow wrong?

Thanks!

clvic 02-12-2009 05:03 PM

Are you sure that the name of the device is /dev/sdc both the first time you insert a card and the second time? I mean, I suspect that when you copy from the first card to the hard disk, the card device name is /dev/sdc. Maybe when you insert the second card, its name becomes /dev/sdd
Can you verify this?

jschiwal 02-12-2009 06:46 PM

See if you can mount the cf_card file using a loop device. If it has a partition on it, you could try adding an offset of 63*512 bytes for the first partition. This is just to verify that the filesystem on the file is OK.

Code:

sudo /sbin/losetup -fs cf_card -o $((63*512))
sudo mount -t <vfat?> /dev/loop0 /mnt/<mountpoint>

file cf_card
sudo file -s /dev/loop0

Some cards don't have a partition, and you mount them using the disk device instead. I.E. /dev/sdc instead of /dev/sdc1.

Perhaps the data wasn't entirely flushed to the card before you ejected it. After creating the copy, try mounting it and then running "sync". Then run "eject". Don't remove or reboot until you know that the filesystem is OK. Also look at the device used for the card using "sudo file -s /dev/sdc"

Use "sudo /sbin/fdisk -l" and "udevinfo -q env -n /dev/sdc" to double check that the device nodes haven't changed.
Since it is a clone, the filesystem on the new cf card will have the same UUID number.

I'm not familiar enough with BSD to know what kind of filesystem is on the card, but I'm sure it is something that Linux understands. Eject and reinsert the card and double check that it is bootable, "sudo file -s /dev/sdc" and that the partition is mountable.

doxJeremy 02-13-2009 04:51 PM

Thank you for your replies!

Quote:

Are you sure that the name of the device is /dev/sdc both the first time you insert a card and the second time? I mean, I suspect that when you copy from the first card to the hard disk, the card device name is /dev/sdc. Maybe when you insert the second card, its name becomes /dev/sdd
Can you verify this?
Both of them are /dev/sdc

@jschiwal:
Mounted image using loop device and verified the filesystem is ok.

file cf_card resulted in:
cf_card: x86 boot sector; partition 1: ID=0xa9, active, starthead 1, startsector 63, 8027649 sectors

sudo file -s /dev/loop0:
/dev/loop0: Unix Fast File system [v1] (little-endian), last mounted on /, last written at Thu Oct 30 12:06:58 2008, clean flag 255, number of blocks 1940904, number of data blocks 1910655, number of cylinder groups 21, block size 16384, fragment size 2048, minimum percentage of free blocks 5, rotational delay 0ms, disk rotational speed 60rps, TIME optimization

I don't have time right now to do the other things you suggested, but I'll try them and let you know in the next few days.

Thank you guys again for your replies.

doxJeremy 02-16-2009 02:11 PM

I used /dev/sdc1 for the device. /dev/sdc won't even mount. The devices listed are /dev/sdc, /dev/sdc1, /dev/sdc5 and /dev/sdc6. The fdisk and udevinfo commands on both cards have identical output. But,

on the source card:
Code:

linux-j368:/mnt # file -s /dev/sdc1
/dev/sdc1: Unix Fast File system [v1] (little-endian), last mounted on /, last written at Thu Oct 30 12:06:58 2008, clean flag 1, number of blocks 1940904, number of data blocks 1910655, number of cylinder groups 21, block size 16384, fragment size 2048, minimum percentage of free blocks 5, rotational delay 0ms, disk rotational speed 60rps, TIME optimization

on the destination card:
Code:

linux-j368:/mnt # file -s /dev/sdc1
/dev/sdc1: Unix Fast File system [v1] (little-endian), last mounted on /, last written at Thu Oct 30 12:06:58 2008, clean flag 255, number of blocks 1940904, number of data blocks 1910655, number of cylinder groups 21, block size 16384, fragment size 2048, minimum percentage of free blocks 5, rotational delay 0ms, disk rotational speed 60rps, TIME optimization

Notice the "clean flag" number, the source card is 1 and the destination card is 255. Does that make a difference?

alex2002 02-27-2009 04:53 AM

problem to clone cf
 
I have the exact problem. Did you solve it?

regards
alex

doxJeremy 02-27-2009 03:41 PM

Yes! I finally did! About 5 min ago.

I ended up using two IDE to CompactFlash adapters to do the transfer directly. I just used dd to copy the image from the source card to the destination card (both unmounted of course).

alex2002 03-02-2009 01:01 AM

I did the same thing, but no success!? I want to copy from cf 128Mb to cf 4Gb. Data on 4Gb is ok, but the OS won't boot.

regards
Alex

doxJeremy 03-02-2009 11:30 AM

I used two identical cf cards, same size and all. You could try creating a partition on the 4 gb cf card and just copy the image to that partition.

this post might be helpful:
http://www.linuxquestions.org/questi...ommand-362506/


All times are GMT -5. The time now is 11:34 PM.