[ubuntu-uk] Script to dd from an SD card only partitioned area

Neil Greenwood neil.greenwood.lug at gmail.com
Mon Sep 19 19:13:54 UTC 2016


Sorry for the top post, I'm on my phone. 

I think partimage does what you want already. Clonezilla gives a (very slightly) friendlier front end, but I've not used either for several years... 


Neil 

On 19 September 2016 17:49:44 BST, Colin Law <clanlaw at gmail.com> wrote:
>On 19 September 2016 at 17:18, Robert McWilliam <rmcw at allmail.net>
>wrote:
>> 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.
>
>Is not the partition table in the space before the first partition? So
>in the example I posted where I had
>
>Device     Boot  Start     End Sectors Size Id Type
>/dev/sdb1         8192  137215  129024  63M  c W95 FAT32 (LBA)
>/dev/sdb2       137216 4233215 4096000   2G 83 Linux
>
>is not the partition table in sectors 0 to 8191? So if I copy sectors
>0 to 2333215 that should include the partition table and all the
>partitions.  Is that not correct?
>
>> 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.
>
>To do it that way I believe I would have to write a script to pick up
>the partition info from the original card, mount and copy the files in
>each partition, and save the partition info with the files. Then to
>restore it I would need a script to re-partition the new card and copy
>the files across to each partition.
>
>Colin
>
>-- 
>ubuntu-uk at lists.ubuntu.com
>https://lists.ubuntu.com/mailman/listinfo/ubuntu-uk
>https://wiki.ubuntu.com/UKTeam/

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-uk/attachments/20160919/7bf36485/attachment-0001.html>


More information about the ubuntu-uk mailing list