Can duplicate system image on USB memory stick, but not on microSD card

The Raspberry Pi is a series of credit card-sized single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science in schools and developing countries.

Post Reply
User avatar
/RaspberryPi
Corporate
Posts: 2449
Joined: Wed Jun 05, 2019 1:29 am

Can duplicate system image on USB memory stick, but not on microSD card

Post by /RaspberryPi »


My goal is to be able to create a RPi system that I can easily copy over from the source USB stick to another USB stick or a microSD memory card. Also, I want to be able to copy this system from a smaller device to a larger one. Eventually all the steps will be in a Python script. When I use the terms "drive" or "device," I mean the USB stick or microSD card, not an actual SDD or HDD.

I use sfdisk in script mode to read the partition table from the source drive to a file. Then I use the file as input to recreate the same partitions on a 2nd device. Once that is done, from the command line, I format the partitions to match the source, so I always have a root partition with a FAT fs on it and a larger root partition with an extfs on it. I also copy the bootable flag for each partition as well as any labels. Then I use parted to extend the last partition to fill up any unused space on the destination drive. ere's the partition info from "sfdisk -l /dev/sda" on the source:

Disk /dev/sda: 57.8 GiB, 62026416128 bytes, 121145344 sectors
Disk model: USB DISK 3.0
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x31517bf8

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 8192 532479 524288 256M e W95 FAT16 (LBA)
/dev/sda2 532480 121145343 120612864 57.5G 83 Linux

When I use a 128GB USB stick, I get the same, except the capacity amounts are bigger. Partitions are formatted with the same fs, bootable flags are the same, and so on.

Here's the output from the same command on the microSD card:

Disk /dev/mmcblk0: 119.3 GiB, 128043712512 bytes, 250085376 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xd71b07fc

Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 * 8192 532479 524288 256M e W95 FAT16 (LBA)
/dev/mmcblk0p2 532480 250085375 249552896 119G 83 Linux

(This is from a test run from a 128GB USB stick source to a 128GB microSD card.)

The problem I'm running into is when I copy from a USB stick source to a USB stick destination, things work okay. After I'm done, I can boot the destination. But when I copy to a microSD card, it never boots. Same process, data looks good, but the microSD card image won't boot.

What do I need to look at or investigation that differs between the USB sticks and the microSD cards? What differences between the two types of devices that could keep the card from booting with the same partitioning table and info and the same files on it?
submitted by /u/ImaginaryTango
[link] [comments]

Source: https://www.reddit.com/r/raspberry_pi/c ... ory_stick/
/RaspberryPi
Post Reply

Return to “Raspberry Pi Forum”