LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Clone a bootable CF card with multiple partitions and copy to bigger drive (https://www.linuxquestions.org/questions/linux-newbie-8/clone-a-bootable-cf-card-with-multiple-partitions-and-copy-to-bigger-drive-4175534675/)

RoyLittle0 02-20-2015 11:37 PM

Clone a bootable CF card with multiple partitions and copy to bigger drive
 
Hi, all, I am new to the forum and quite new to Linux, I am running Mint and Kali from a USB drive, all is going well with with the software and I am starting to find my way around it.

So, now to my question, I have 15 machines which all run from a CF card and the card has multiple partitions and is a Windows Embedded XP, not that the operating system makes any difference, I need to upgrade all the CF cards from 2gb to 4gb, so unfortunately Windows isn't an option to use to copy the drives as it doesn't recognise multiple partitions on a removable drive, so I cant just remove the drive, clone it and fit the new one.

What I need is a method of cloning the drive completely with both partitions, I have read about dd but cant seem to see anything about doing this with multiple partitions, as Linux sees it as two drives when I plug it in, how can I use dd or anything else to clone the drive which is bootable and has two partitions?

At some point I would like to automate the process as I could have many of these machines/drives to upgrade, is there a way to write a program that will automatically back up the drives from a USB drive and then reinstall it, I have seen this done before but I am not sure if this method did the whole drive, just the main drive or all partitions?

fatmac 02-21-2015 04:29 AM

I use dd when cloning, simply because I'm used to it. Use the whole drive designations, not the partition designations.

Example:
Code:

dd if=/dev/sda of=/dev/sdb bs=1M
To create an image to put onto lots of other disks:
Code:

dd if=/dev/sda of=mydisk.img bs=1M
Then use:
Code:

dd if=mydisk.img of=/dev/sdb bs=1M
to put it onto another machine.

RoyLittle0 02-21-2015 05:55 AM

Thanks for the reply

I like the look of the "mydisk.img" I just have one quick question before I give this a try, how do I determine what my drive is a b or c as they are shown as partitions when I view them in Computer?

OK I have found it, if I type lsblk, this shows me all the disks and partitions

Can I direct the image file to a location, or where will it be stored so that I can save it as a backup

The problem I am getting is there is not enough space on the Root to store the 4gb file, the space seems to be limited to 2gb on my root, I am running linux from a 32gb USB drive?

syg00 02-21-2015 06:58 AM

Quote:

Originally Posted by RoyLittle0 (Post 5320966)
Can I direct the image file to a location, or where will it be stored so that I can save it as a backup

I have just tried it and it only copies one partition, i'll try again and see how I get on this time.

That might imply you are copying the img file to a [v]fat partition - it has a 2G file limit. Better to copy to a Linux filesystem.

Be aware that the restored CFcard will also be limited to 2 Gig (even if physically 4G) due to the fact that it is an image. Is the first partition the XP system, and the second partition data ?. Presumably you want to make the second bigger ?.

RoyLittle0 02-21-2015 07:36 AM

All I can tell you is that I currently have a 2gb CF card and I need to increase this to 4GB as I don't have any space on the card to add additional software, the 2 partitions are C:/Windows Embedded XP and D:/Data, the C drive is protected and the D is not, the D is used to user defined information

We already have 4gb cards in use on some of the machines but I need to upgrade them all

I am using Linux Kali from a bootable USB drive which has 4.66gb of space on it but the image always stops at 2gb, what are my options to create a image from a 4gb CF card and duplicate it

I do have a Linux virtual machine but I assume that will create further problems with shared drives

syg00 02-21-2015 07:51 AM

Let's see the output from the lsblk with the CF card attached to Kali. Also output from
Code:

df -hT

RoyLittle0 02-21-2015 08:12 AM

2 Attachment(s)
This is a screen shot of the drives

I think I understand now, my USB boot drive is formatted to FAT32, i'll try again with a new drive and make it NTFS

Edit,
I have created a NTFS USB drive and had the results as with the FAT32 drive

jefro 02-21-2015 02:34 PM

The embedded xp may not clone easily. Microsoft has full documentation on how to manage PE and embedded systems.

Generally I use G4U to clone but only because I'm too lazy.

Format has nothing to do with cloning. The command dd will destroy all data on the drive. (or original if you are not careful)

Linux and xp may have many files that have unique parameters that may need to be edited either before or after.

Xp can't legally be cloned with out licenses.

Some OS's know the type of geometry and won't easily clone.

schneidz 02-21-2015 10:13 PM

i think part of the problem is using microsoft filesystems on a linux system.

you may have better luck using gparted live-usb to copy partitions around.

RoyLittle0 02-22-2015 12:08 AM

Windows does not recognise a CF card that has multiple partitions, which I why I am not using Windows
Quote:

The embedded xp may not clone easily. Microsoft has full documentation on how to manage PE and embedded systems.

I was talking about the USB drive that contains the Linux operating system, which will be the destination of the files once copied, not the CF card
Quote:

Format has nothing to do with cloning. The command dd will destroy all data on the drive. (or original if you are not careful)

Our head office in Japan use Linux to make the disks to ship to us
Quote:

Linux and xp may have many files that have unique parameters that may need to be edited either before or after.

All machines are fully licence, as the original messages says, I am upgrading the card from 2gb to 4gb, which is perfectly acceptable
Quote:

Xp can't legally be cloned with out licenses.

As I have said this has been done before, I am also able to clone a single partition without issues
Quote:

Some OS's know the type of geometry and won't easily clone.

syg00 02-22-2015 02:27 AM

Quote:

Originally Posted by RoyLittle0 (Post 5321011)
I have created a NTFS USB drive and had the results as with the FAT32 drive

The source drive is irrelevant - the target (where the mydisk.img is being written to) cannot be vfat.

Looking at the attachment, it appears you want to enlarge the first partition - could be tricky as @jefro says. Or not - been too long since I messed with XP, and never embedded. Normally simply enlarging a partition/filesystem is pretty straight-forward, but you can't do that until the second partition is moved out of the way. And you certainly can't do it merely by cloning to a larger disk.

fatmac 02-22-2015 04:18 AM

Once you have a copy (mydisk.img) & have dd'ed it onto the larger disk, you should be able to boot it & use the extra space by creating a new partition with the original partitioner, then put a filesystem on it. Then make an image copy of this new disk to copy to all other needed disks.

schneidz 02-22-2015 07:43 AM

this is how I perform dd image copies and restores:
http://www.linuxquestions.org/questi...5/#post5308285

edit: im still confused. you have a 2 gb ms-xp disk and you want to clone it to a 4 gb disk (utilizing the full size) ?

I would boot up a live-usb with gparted on it. plug in both drives and perform the copy and expand (gparted is essentially a gui wrapper for dd and resize2fs).


All times are GMT -5. The time now is 03:09 PM.