[Soekris] Cloning a bootable CF
Stephen Melvin
melvin at zytek.com
Tue Nov 24 21:59:09 UTC 2009
I've done this a few times on FreeBSD when CF sizes don't match and have
found the
following sequence to work swimmingly:
Assumes you have another FreeBSD system that has a CF card reader and enough
disk space to store a memory image of the new CF card. First find out
the exact size
of the new card (assume card installed on /dev/ad10)
bsdlabel -Awn ad10
Look for the "sectors/unit" number. This number may also show up in the
/var/log/messages file when you first plug in the card.
Now create a memory image of a blank bootable file system with this exact
number of sectors:
1. create block of zeros: dd if=/dev/zero of=disk_image.bin bs=512
count=<sectors/unit>
2. create vnode: mdconfig -f disk_image.bin -u 0
3. create boot sectors: bsdlabel -Bw md0 auto
4. create partitions: bsdlabel -e md0
5. create file system: newfs -b 8192 -f 1024 -U /dev/md0a
6. mount image: mount /dev/md0a /mnt2
Now mount the old card and copy the files over:
1. mount old card: mount /dev/ad10a /mnt
2. copy files: ( cd /mnt ; tar cPf - . ) | ( cd /mnt2 ; tar xf - ) ;
3. unmount: umount /mnt2
4. detach: mdconfig -d -u 0
5. unmount: umount /mnt
The mounting and copying steps may depend on how you have partitioned
the old
card. Now you have a new bootable memory image and you can just
transfer it to the
new card:
1. install new card in /dev/ad10
2. dd if=disk_image.bin of=/dev/ad10
Your mileage may vary. Hope this helps. Regards,
Steve
Bill Maas wrote:
> Hi Marco,
>
> On Tue, 2009-11-24 at 10:17 -0600, Darrick Hartman wrote:
>
>> Marco A. Calamari wrote:
>>
>>> On Tue, 2009-11-24 at 06:40 -0600, Darrick Hartman wrote:
>>>
>>>> Marco A. Calamari wrote:
>>>>
>>>>> On Tue, 2009-11-24 at 10:51 +0100, Flemming Jacobsen wrote:
>>>>>
>>>>>> Hey
>>>>>>
>>>>>> Why don't you just clone it using dd:
>>>>>> Insert old card
>>>>>> dd if=/dev/DEVICE of=/tmp/soekris.image bs=64k
>>>>>> Insert new card
>>>>>> dd of=/dev/DEVICE if=/tmp/soekris.image bs=64k
>>>>>>
>>>>> The original CF is 512Mb and the new is 4Gb.
>>>>> I don't know if that works, but for sure would waste
>>>>> 3.5Gb
>>>>>
>>>>> Many thanks. Marco
>>>>>
>>>> What's the file system? If it's ext2, you can resize the partition
>>>> after you copy the data using dd as described above.
>>>>
>>> What you are sayng is not clear to me.
>>> If you dd a partitioned, bootable device, let's say /dev/sda,
>>> you copy also the boot block and the partition table to the image
>>>
>>> dd'ing the image on the new CF you have the original partition table, so
>>> the dimension of the partition is the same and the volume dimension
>>> are wrong.
>>>
>>> Am I missing something?
>>>
>>> Many thanks to all for your time and help. Marco
>>>
>>>
>> Correct, but after it's on the new larger device, you can expand the
>> size of the partition IF the file system supports that operation. ext2
>> does support growing the file system. Something like gparted will work
>> nicely for you if you have a Linux desktop. Otherwise, grab a bootable
>> CD that has gparted as one of the available utilities.
>>
>>
>
> It seems to me that in that case you might as well do it properly and
> mke2fs, mount, rsync the content and install the boot loader, all of
> which can easily be done from a shell script if you need to automate the
> process.
>
> A fresh installation of the OS on the Soekris box will give you the
> cleanest and most reliable installation if the CF is being moved from
> one type of box to another, if that's not too much trouble. It may take
> up less time than finding and fixing compatibility "bugs" afterwards.
>
>
> Bill
>
> _______________________________________________
> Soekris-tech mailing list
> Soekris-tech at lists.soekris.com
> http://lists.soekris.com/mailman/listinfo/soekris-tech
>
>
>
More information about the Soekris-tech
mailing list