1

I'm trying to clone a bootable 1GB compactflash to a second 1GB complactflash, but when I try to mount it, i get an error like so,

sudo mount /dev/sdb1 /media/frank/cloned/

frank@ThinkPad2:~$ sudo mount /dev/sdb1 /media/frank/cloned/
mount: /media/frank/cloned: wrong fs type, bad option, bad superblock on /dev/sdb1, 
missing codepage or helper program, or other error.

I'm using a single USB CF drive and swapping the original and target CF. It seems to be copying everything, even down to the UUID (not sure if this is bad), but I'm unable to mount the cloned CF, or explore it. Below are the steps I'm taking.

The CF I'm cloning is ext3. When I stick the card in the drive it mounts automatically and shows up as **/dev/sdb1 mounted in /media/frank/c44c8412-bf87-4fa4-a6fa-8259aa78bd24 **

I formatted the target CF with the command mkfs.ext3 /dev/sdb1

Then copied form the original CF using dd if=dev/sdb1 of=/home/frank/CFdisk.image

To check that the image was good: mount -o loop CFdisk.image /media/frank/compactflash

Then.. ls /media/frank/compactflash

frank@ThinkPad2:~$ ls /media/frank/compactflash/ 
bin   etc    lib         mnt    proc  sbin   sys  var
boot  fifos  lost+found  opt    root  share  tmp  vmcores 
dev   home   media       overlay  run   srv    usr www

So it looks like the CFdisk.image file has been copied correctly.

Then putting the target CF in the drive, running lsblk i get see it is at /dev/sdb1

The use dd if=CFdisk.image /dev/sdb1

Afterwards it doesn't automaticly mount. And if I try to mount it manually to a directory, sudo mount /dev/sdb1 /media/frank/cloned/ then I get the error....

frank@ThinkPad2:~$ sudo mount /dev/sdb1 /media/frank/cloned/
mount: /media/frank/cloned: wrong fs type, bad option, bad superblock on /dev/sdb1, 
missing codepage or helper program, or other error.

The command lsblk -f shows that it on the system the cloned CF is...

sdb                                                                   
└─sdb1
     ext3         c44c8412-bf87-4fa4-a6fa-8259aa78bd24    

On the original CF lsblk -f shows

sdb                                                                       
└─sdb1 ext3           c44c8412-bf87-4fa4-a6fa-8259aa78bd24  311.2M    60% /media/frank/c44c8412-bf87-4fa4-a6fa-8259aa78b

So, what am I not doing correctly?

1 Answer 1

1

If you want to clone a bootable drive, it is not enough to clone a partition, but you should clone the whole drive, including the head end. You can do that with dd with source (and target) as /dev/sdx (not /dev/sdx1 which is cloning partition number one and not the whole drive).

But using dd this way is risky because it does what you tell it to do without any questions, and it is very easy to point to the wrong drive and overwrite valuable data. For that reason I suggest that you use a cloning tool with a final checkpoint, where you can double-check, that things are set up correctly.

Plain cloning should work when using an MSDOS partition table and when the target drive is 'not one single byte smaller' than the source drive. If there is a GUID partition table, GPT, and there are different sizes, you must fix the backup partition table at the end of the drive. This is done automatically, when you use mkusb to clone or extract from the image. Otherwise you can use gdisk to fix it after the cloning.

You may find the following links helpful,

9
  • I tried dd if=/dev/sdb of=image then dd if=image of=/dev/sdb but when trying to mount /dev/sdb or /dev/sdb1 I got the same error I mentioned before.
    – Frank
    Commented Aug 31, 2021 at 1:29
  • @Frank, The method you describe (in the comment above this one) should work when using an MSDOS partition table and when the target drive is 'not one single byte smaller' than the source. If a GUID partition table, GPT, and there are different sizes, you must fix the backup partition table at the end of the drive. This is done automatically, when you use mkusb to clone or extract from the image. Otherwise you can use gdisk to fix it after the cloning.
    – sudodus
    Commented Aug 31, 2021 at 6:14
  • Thanks for the help! Now It appears to me that the problem is that the source drive is larger than the target, even though they are both 1GB. DD report "No space left on disk" I didn't realize that that is an error.
    – Frank
    Commented Aug 31, 2021 at 17:10
  • OK. I've confirmed that the source is 1,024,966,656 bytes and the target is only 964,583,424 bytes. According to the utility "parted --list" the partition table is MSDOS. Is there a way I can clone with DD still? According to the command "ls -alk" on the target drive, only 116K is used for files and directories.
    – Frank
    Commented Aug 31, 2021 at 17:18
  • No, but you can clone to a new drive, that is big enough, and if you do some advanced editing cloning will maybe work. Try this procedure: Clone to an intermediate drive, for example a USB pendrive or and old hard disk drive that you can overwrite (the previous content of the intermediate drive will disappear). The you can shrink some partition and make sure that all the partitions are within the size of the target card. Finally clone from the intermediate drive to the target card.
    – sudodus
    Commented Aug 31, 2021 at 18:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .