Hi,
first of all: hello together, I'm new to that forum, but not new to Linux & Embedded
My problem:
I want to create a complete image for a CF/sd card (kind of memory card doesn't matter) including all approriate partitions. In my case, I have 3 partitions, boot, an embedded linux and a third one for temporary stuff.
Now I want to create an image file with the size of my CF card, e.g. 1GB.
I don't want to use a CF card for that, so partitioning a CF card, copying the files and using dd afterwards to clone the whole CF-card is not an option.
We already tried that with a shell script, what actually works, but I want to ensure if there is a more common or safe way, and that our approach is not unsafe, error-prone etc.
Roughly, I do the following:
- Create an empty 1GB file with dd /dev/zero -> IMAGE_FILE
- Write the partition table to that image file using sfdisk
- create loop devices for my partitions, e.g.
/sbin/losetup /dev/loop0 IMAGE_FILE
/sbin/losetup /dev/loop1 IMAGE_FILE -o [offset for first partition ...]
etc.
- create file systems, e.g. /sbin/mkfs.ext3 /dev/loop1
- mount the loop devices
- copy files there
- install grub on /dev/loop0
- unmount, cleanup etc.
Is this a common and reilable way? Are there tools supporting this kind of work?
thanks a lot in advance!
sebastian