[ubuntu-uk] Script to dd from an SD card only partitioned area
rmcw at allmail.net
Mon Sep 19 16:18:35 UTC 2016
On Mon, 19 Sep 2016, at 14:21, Colin Law wrote:
> I do a fair amount of work with SD cards and use dd to create an image
> for backup or for burning onto other cards. If I burn an image from an
> 8GB card onto a 16GB card then I get a card which is only half used.
> If I then make an image from that one then I get a 16GB image (of
> which only 8GB or less is partitioned) which is larger than it needs
> to be and also if I burn that onto another 8GB card then it fails as
> the card is not large enough (or at least it says it has failed, the
> card will in fact be ok).
You can copy a single partition by pointing dd at the partition rather
than the device, e.g. sda1 rather than sda. I expect that would achieve
the same thing as giving dd offset and size that you can get from fdisk
(but less likely to get those wrong).
Neither approach will give you an image that you can (reliably) put back
onto a card with (just) dd. It won't include the partition table. It
will work if the destination card is partitioned the same as the source
and you write to the same offset, or if you've got a partition the same
size and you update the offset to hit that, but otherwise you'd need to
update the partition table (and other partitions) to make an
appropriately sized gap for it and then write to that.
I think it's better to look at what you're trying to do, and see if dd
is the right tool. I can understand wanting to use dd for archiving or
backing up cards since it'll also catch things that have been deleted or
lost to filesystem corruption that you can then (try to) recover once
you've noticed that something is missing. I'm less convinced it's a good
idea going the other way; it causes the problems you're seeing when
sizes aren't the same and it means you're writing more to the cards than
you need to. I think you'd be better to mount the image file and copy
the files across to the card.
Robert McWilliam rmcw at allmail.net www.ormiret.com
Apparently, three out of four people make up 75% of the population.
More information about the ubuntu-uk