1

I am using the SD Card Copier accessory to make a micro-sd card back-up. The back-up card (in a micro-sd to USB adapter) is recognized by the copier as sdb, and I know that the copying is OK, because I can replace the OS micro-sd card by the back-up card, and the Pi boots successfully with everything in place.

On my previous Pi (model 3B) I could check the back-up card by simply removing it from the USB port (as it was unmounted) and re-plugging it so that I could inspect it via pcmanfm.

On the Pi 4 the re-plugged micro-sd back-up card is not recognized by the system and is impossible to mount or read. I can read it in the File Manager on my desktop PC, so there is presumably no problem with the micro-sd card itself.

Is there anything I can do to read the back-up card on the Pi 4?

  • What does a dmesg command show when you plug it in? Do the partitions need an fsck -f -y /dev/sdxx run to clean them? – Dougie Aug 31 '19 at 22:15
4

I don't think the Pi model is a factor here.

When you made your backup, did you select New partition UUIDs?

screenshot of piclone

If not, that's likely the problem. SD Card Copier help says this:

Under Raspbian Stretch and later versions, you cannot mount two partitions with the same UUID, so you will not be able to mount a cloned SD card when booted from the disk from which it was cloned. If you need to do this, check the "New Partition UUIDs" box before copying.

You can change the UUID with this command:

sudo tune2fs /dev/sdb2 -U random

After that, unplug the microSD adapter, then reinsert it. It should auto-mount from now on. If not, try rebooting.

| improve this answer | |
  • Good point (I always change PARTUID) which is what the SD Card Copier does, but AFAIK when SD Card Copier creates the new ext4 partition it should have a unique UUID - although other methods of cloning a card may not. – Milliways Sep 1 '19 at 0:27
  • The correct command to generate a new UUID is sudo tune2fs /dev/sdb2 -U random NOTE partition /dev/sdb2 rather than disk /dev/sdb – Milliways Sep 1 '19 at 0:28
  • @Milliways Good catch. My answer is updated. – Botspot Sep 1 '19 at 0:47
  • 0 Thanks, Botspot. Just goes to show, when all else fails, read the manual! Although I do note that my Pi 3B was running Raspbian stretch - which the manual suggests shouldn't have behaved as it did – Peter N Sep 2 '19 at 21:26
  • @PeterN, it says uuids have to be unique on on Stretch AND BEYOND. So it is correct. – Botspot Sep 2 '19 at 22:16
0

I regularly read SD Cards on my Pi4, so this is possible.
(The USB3 ports on the Pi4 have some limitations with USB2 devices, although I would not expect this to affect a SD Card reader, but have had occasional problems and usually use one of the USB2 ports.)

I have experienced only one problem which proved to be due to a faulty Card.

I need to manually mount the Card, and can post the script I use to do this.

#!/bin/bash
# 2017-05-06
# 2018-11-18

BOOT_MOUNT='/mnt/SDA1'
ROOT_MOUNT='/mnt/SDA2'

# Check/create Mount Points
if [ ! -e $BOOT_MOUNT ]; then
    mkdir $BOOT_MOUNT
fi
if [ ! -e $ROOT_MOUNT ]; then
    mkdir $ROOT_MOUNT
fi
    echo "mounts " $BOOT_MOUNT  $ROOT_MOUNT
if [ -e /dev/sda ]; then
    SD1='/dev/sda1'
    SD2='/dev/sda2'
else
    SD1='/dev/sdb1'
    SD2='/dev/sdb2'
fi
echo $SD
# Mount Partitions
if ! $(mountpoint -q $BOOT_MOUNT); then
    mount $SD1 $BOOT_MOUNT  # mount partition containing boot files
fi
if ! $(mountpoint -q $ROOT_MOUNT); then
    mount $SD2 $ROOT_MOUNT  # mount root partition containing OS files
fi

The following unmounts SD Cards

#!/bin/bash
# 2017-05-06
# 2018-11-18

BOOT_MOUNT='/mnt/SDA1'
ROOT_MOUNT='/mnt/SDA2'

umount $SD1 $BOOT_MOUNT # mount partition containing boot files
umount $SD2 $ROOT_MOUNT # mount root partition containing OS files
| improve this answer | |
0

The point raised by Botspot is valid.

You should give SD Card copies a unique PARTUUID which needs to be changed in several places. (SD Card Copier has an option to do this.)

The following script set-diskid will set PARTUUID on a booted system in all the correct places.

It can be invoked with sudo set-diskid -n

NOTE you need to reboot after running the script.

#!/bin/bash

errexit()
{
  echo ""
  echo "$1"
  echo ""
  exit 1
}

usage()
{
  errexit "Usage: $0 [-n | diskid]"
}

if [ $(id -u) -ne 0 ]; then
  errexit "$0 must be run as root user"
fi

PTUUID="$1"
if [ "${PTUUID}" = "" ]; then
  usage
fi
if [ "${PTUUID}" = "-n" ]; then
  echo ${PTUUID} 
  PTUUID=$(uuid | cut -c-8)
fi
PTUUID="$(tr [A-Z] [a-z] <<< "${PTUUID}")"
if [[ ! "${PTUUID}" =~ ^[[:xdigit:]]{8}$ ]]; then
  errexit "Invalid DiskID: ${PTUUID}"
fi
echo ""
echo -n "Set DiskID to ${PTUUID} on /dev/mmcblk0 (y/n)? "
while read -r -n 1 -s answer; do
  if [[ "${answer}" = [yYnN] ]]; then
    echo "${answer}"
    if [[ "${answer}" = [yY] ]]; then
      break
    else
      errexit "Aborted"
    fi
  fi
done
echo ""
fdisk /dev/mmcblk0 <<EOF > /dev/null
p
x
i
0x${PTUUID}
r
p
w
EOF
sync
PARTUUID="$(sed -n 's|^.*PARTUUID=\(\S\+\)\s.*|\1|p' /boot/cmdline.txt)"
if [ "${PARTUUID}" != "" ]; then
  sed -i "s|PARTUUID=\S\+\s|PARTUUID=${PTUUID}-02 |" /boot/cmdline.txt
  sed -i "s|${PARTUUID:0:(${#PARTUUID} - 1)}|${PTUUID}-0|" /etc/fstab
fi
sync

NOTE PARTUUID and UUID are different entities.

UUID is a 128-bit number used to identify information in computer systems, in particular it is used to identify partitions on GPT & Linux filesystem.

MBR does not support partition UUIDs, but Linux supports PARTUUID for MBR partitions.
The format is SSSSSSSS-PP, where SSSSSSSS is a 32-bit MBR disk signature (stored in the MBR label-id field), and PP is a partition number.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.