Creating a copy of the OSMC SDCard

I’ve searched the Community and the Web for ways to make a copy of the SDCard currently used for my OSMC RPi installation without a lot of success :face_with_spiral_eyes: . I have avoided all of those links older the 5 years which all too often are not currently valid.

I’m left with one question: “Why is it so complicated to create a copy of my configured OSMC - OS SDCard?”, without having to use two computers (Windows and/or Pi’s) and being a Linux or Windows technical expert? My Debian RPi installation Desktop/GUI has an app which does this in 4 or so clicks.

Thanks…RDK

Well it’s 7 years old but still works. Download this to your home directory on the Pi, attach an empty SD card (with a USB cardreader) and go sudo bash osmc-restore -f /

1 Like

@grahamh Super, I’ll give it a try later today. Many thanks…RDK

@grahamh I tried to run your script this morning and got this error:

sudo bash osmc-restore -f /
Mon Mar 9 10:03:28 CET 2026 Restore version 0.1.12

This script needs pv but I can’t find it
Try: sudo apt-get install pv (or similar)

Didn’t I install/set it up correctly? I’m running a Pi4B…RDK

Did you try what it suggested?

Since OSMC is a special version of the RPI OS, I’m hesitant to add something which might break it…RDK

OSMC is a version with lots of stuff removed from what might be a typical Linux install to keep it lightweight but if you want to do extra things then you probably have to install the required components. I’m going to try this script myself as it looks as though it would be quite useful to have on a headless OSMC Setup on a Pi4.

ok, after your comments and “recommendation” is installed the PV app and ran the “Restore” script. I find the name a bit counter logic, since it is really a clone or save and nothing is being restored to the RPi.

But, it did job and when I swapped out the original and inserted the copy/clone, the system came up normally. @grahamh thanks again for the script…RDK

Yeah, the name isn’t ideal but restore means make a bootable SD card, whether it’s from a backup or a live SD card. Maybe I’ll change it one day but tbh SD card corruption isn’t an issue now I use only Veros. I haven’t looked at those scripts for years although osmc-backup still runs every night on my daily driver.

@grahamh I think something has changed?? Tried to run the RESTORE script this AM and got this message.

me@MedCtr:~$ sudo bash osmc-restore -f /
Sat May 23 11:47:40 CEST 2026 Restore version 0.1.12
Going to copy the working filesystem
ls: cannot access ‘//system/boot’: No such file or directory
sda 1.8T disk
sdb 29.7G disk
mmcblk0 29.5G disk
Please enter the device name of the media to restore to … sdb^C

It is normal? Thanks…Rdk

Nothing has changed. I can see the problem and wonder why you (or I) haven’t seen that message before. it has no effect for RPi. As long as you get ‘Please enter the device name …’ you are good to continue.

I’ve pushed a fix to the repo. Grateful if you can test - I don’t have a RPi spare atm to test.

@grahamh I’ll run as is today and test it next time. Thanks…RDK

@grahamh OK, this time I giot thses messages before I aborted:

rob@RDKP4MedCtr:~$ sudo bash osmc-restore -f /
Sat May 23 14:37:42 CEST 2026 Restore version 0.1.12
Going to copy the working filesystem
ls: cannot access ‘//system/boot’: No such file or directory
sda 1.8T disk
sdb 29.7G disk
mmcblk0 29.5G disk
Please enter the device name of the media to restore to … sdb

Going to erase all of /dev/sdb, press Y to continue …
/dev/sdb1 is mounted
Unmounted /dev/sdb1
Unmounted /dev/sdb2
Formatting USB stick sdb
Information: You may need to update /etc/fstab.

mkfs.fat 4.2 (2021-01-31)
mke2fs 1.46.2 (28-Feb-2021)
/dev/sdb2 contains a ext4 file system
last mounted on / on Sat May 23 14:38:15 2026
Proceed anyway? (y,N) y
Creating filesystem with 7728256 4k blocks and 1933312 inodes
Filesystem UUID: 749a098e-4d8c-40a8-958a-a014ddc52058
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Looking for existing partitions on sdb
Partitions found: 2 sdb1 sdb2

Cannot find a suitable vfat partition for boot

Checking size of working system
1449380KiB in system

Cannot find a suitable ext partition for system

Cannot not find one or more suitable partitions
Partitions on sdb are as follows
Model: Mass Storage Device (scsi)
Disk /dev/sdb: 31.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 4194kB 260MB 256MB primary fat32 lba
2 260MB 31.9GB 31.7GB primary ext4

Do you want to re-format the card and try again (Y/N)?

I’m going to reformat the card on my laptop and try again…RDK

@grahamh Well, reformatting the SDCard did not change anything. The script messages are below and it appears that it is in a loop to find a suitable SDCard? I have a new SDCard which I will try. Will the new script be a better idea?..RDK

me@P4MedCtr:~$ sudo bash osmc-restore -f /
Sat May 23 15:01:07 CEST 2026 Restore version 0.1.12
Going to copy the working filesystem
ls: cannot access ‘//system/boot’: No such file or directory
sda 1.8T disk
sdb 29.7G disk
mmcblk0 29.5G disk
Please enter the device name of the media to restore to … sdb

Going to erase all of /dev/sdb, press Y to continue …
/dev/sdb1 is mounted
Unmounted /dev/sdb1
Formatting USB stick sdb
Information: You may need to update /etc/fstab.

mkfs.fat 4.2 (2021-01-31)
mke2fs 1.46.2 (28-Feb-2021)
/dev/sdb2 contains a ext4 file system
last mounted on Sat May 23 15:01:19 2026
Proceed anyway? (y,N) y
Creating filesystem with 7728256 4k blocks and 1933312 inodes
Filesystem UUID: 2d563301-8e5a-483f-862a-59ee90138407
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Looking for existing partitions on sdb
Partitions found: 2 sdb1 sdb2

Cannot find a suitable vfat partition for boot

Checking size of working system
1449116KiB in system

Cannot find a suitable ext partition for system

Cannot not find one or more suitable partitions
Partitions on sdb are as follows
Model: Mass Storage Device (scsi)
Disk /dev/sdb: 31.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 4194kB 260MB 256MB primary fat32 lba
2 260MB 31.9GB 31.7GB primary ext4

Do you want to re-format the card and try again (Y/N)?
Going to erase all of /dev/sdb, press Y to continue …
Aborting …
me@MedCtr:~$ sudo bash osmc-restore -f /
Sat May 23 15:03:00 CEST 2026 Restore version 0.1.12
Going to copy the working filesystem
ls: cannot access ‘//system/boot’: No such file or directory
sda 1.8T disk
sdb 29.7G disk
mmcblk0 29.5G disk
Please enter the device name of the media to restore to … sdb

Going to erase all of /dev/sdb, press Y to continue …
/dev/sdb1 is mounted
Unmounted /dev/sdb1
Unmounted /dev/sdb2
Formatting USB stick sdb
Information: You may need to update /etc/fstab.

mkfs.fat 4.2 (2021-01-31)
mke2fs 1.46.2 (28-Feb-2021)
/dev/sdb2 contains a ext4 file system
last mounted on Sat May 23 15:03:10 2026
Proceed anyway? (y,N) y
Creating filesystem with 7728256 4k blocks and 1933312 inodes
Filesystem UUID: c07dea38-592b-4bab-9185-1d777eb836b8
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Looking for existing partitions on sdb
Partitions found: 2 sdb1 sdb2

Cannot find a suitable vfat partition for boot

Checking size of working system
1449148KiB in system

Cannot find a suitable ext partition for system

Cannot not find one or more suitable partitions
Partitions on sdb are as follows
Model: Mass Storage Device (scsi)
Disk /dev/sdb: 31.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 4194kB 260MB 256MB primary fat32 lba
2 260MB 31.9GB 31.7GB primary ext4

Do you want to re-format the card and try again (Y/N)?
Going to erase all of /dev/sdb, press Y to continue …
/dev/sdb1 is mounted
Unmounted /dev/sdb1
Unmounted /dev/sdb2
Formatting USB stick sdb
Information: You may need to update /etc/fstab.

mkfs.fat 4.2 (2021-01-31)
mke2fs 1.46.2 (28-Feb-2021)
/dev/sdb2 contains a ext4 file system
last mounted on Sat May 23 15:04:25 2026
Proceed anyway? (y,N) y
Creating filesystem with 7728256 4k blocks and 1933312 inodes
Filesystem UUID: 4c1a8e86-c242-4956-b7f2-1e46ca0bc552
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Looking for existing partitions on sdb
Partitions found: 2 sdb1 sdb2

Cannot find a suitable vfat partition for boot

Checking size of working system
1449180KiB in system

Cannot find a suitable ext partition for system

Cannot not find one or more suitable partitions
Partitions on sdb are as follows
Model: Mass Storage Device (scsi)
Disk /dev/sdb: 31.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 4194kB 260MB 256MB primary fat32 lba
2 260MB 31.9GB 31.7GB primary ext4

Do you want to re-format the card and try again (Y/N)?
Cannot find a suitable vfat partition for boot

Cannot find a suitable ext partition for system

WARNING: only 0 of 2 partitions were restored
Time to restore: 00h:00m:07s

@grahamh Good news!! I changed SDCards and now it works, but still gives the

ls: cannot access ‘//system/boot’: No such file or directory

message. I’ll try your new script later, maybe even with the “bad card”…RDK

I’ve had that problem with the -f option sometimes. If the card appears to have formatted correctly just try again without the -f. It should then recognise the two partitions properly.

@grahamh OK, tomorrow…

@grahamh OK I ran the the original script without the -f and it seemed to have worked,

However, when I tried to run the new script I got these messages…RDK

sudo bash osmc-restore2 -f /
osmc-restore2: line 2: $‘\r’: command not found
osmc-restore2: line 5: $‘\r’: command not found
osmc-restore2: line 10: $‘\r’: command not found
osmc-restore2: line 12: $‘\r’: command not found
osmc-restore2: line 15: $‘\r’: command not found
Sun May 24 14:44:09 CEST 2026 Restore version 0.1.12a
osmc-restore2: line 17: $‘\r’: command not found
osmc-restore2: line 52: syntax error near unexpected token elif' 'smc-restore2: line 52: elif [ “$2” == “-f” ]; then

Oops. Let me see …

I dug out a RPi and it works for me. Did you by chance edit the script in Windows? Those \r look like wrong line endings.

@grahamh Maybe it is my “oops”. Yes, I did a copy paste from Windows to the Pi via SAMBA. I’ll do it over and another test, but “tomorrow”. Thanks…RDK