On 19 September 2016 at 18:37, Robert McWilliam <r...@allmail.net> wrote:
> On Mon, 19 Sep 2016, at 17:49, Colin Law wrote:
>> On 19 September 2016 at 17:18, Robert McWilliam <r...@allmail.net> wrote:
>> 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?
> Put a 4 in front of that end sector number, lose one of the 3's, and
> yes, I think you'd get partition table and those two partitions. That
> kind of transcription error is why I don't think you should play with
> offsets directly. That looks like a human transcription error so you
> wouldn't have exactly that type of error in a script, but parsing text
> to get a number is really fragile (what appears in the "Boot" column
> there when it has something? Will your parsing be thrown off that? What
> else might change?).
Indeed, that is precisely why I hoped there would either be better
ways of determining the partion information or a better way of doing
the whole exercise.
> For a whole card image you can make loopback devices for the partitions
> in it:
> $sudo losetup -Pf --show disk_image.raw
> then mount the partitions
> $sudo mount /dev/loop0p1 /mnt/point
> then copy the files to a card (or anywhere else) with normal file
> management tools, unmount the image:
> $sudo umount /mnt/point
> and detach the loopback device
> $sudo losetup -d /dev/loop0
That is interesting, thanks.
> For the single partition image you don't need the loopback device and
> can mount it directly with:
> $sudo mount -o loop partition_image.raw /mnt/point
> As for partitioning the destination card: I'd keep them all partitioned
> with one partition the full size of the card. If you want a clean card
> to restore an image too: rm -rf /where/its/mounted (be very, very,
> careful if putting that in a script with something to determine the
> mount point...).
I don't have full control of the partitions. The example I showed is
is a bootable raspbian lite card. Another is a NOOBS card running
raspbian, another is a SheevaPlug running Ubuntu 9.04 and so on. So if
I want an automatic script it will have to clean and re-partition the
new card appropriately.