Possible to duplicate SDCARD...?

Ok guys, i don’t know how… but i actually DID IT!
How? Well, i tried like 3-4 times to read the source card with Win32DiscImager and then write it to the target card. Last time it somehow worked, i don’t know how, but yea…
Thanks everyone!

If I have a SD card image from one Pi, and restore it to a different (larger) SD card for another Pi, it works fine, but not all of the larger SD card space is available.

From what I’ve read online it seems that raspi-config is an easy way to expand the partition to use the full card size.

From what I’ve read in this thread it seems like raspi-config is not available on OSMC.

Is there a straightforward (i.e as easy as raspi-config) way of expanding a smaller OSMC image to use all available space on a larger card? If there isn’t at present, I’d consider this a useful feature.

Depends what you mean by straightforward - you can use resize2fs, but, as it says, you’ll need to access the card from another system (so no OS is running on it)
Derek

I interpret this SD card duplication need as a user wanting the old OSMC data on a new larger card.

If that’s the case, here’s what I did. I recently switched Pi:s from model B to model 2B and the only thing I had to do for getting the same install up and running on the new unit was to

  • flash new card with OSMC
  • restore data using OSMC:s built-in backup & restore feature. Made sure I included “Addon data” in the backup for the most complete restore.

New Pi up and running in a matter of minutes.

1 Like

By straightforward, I mean as simple as running a command or three from the command line on the target system (like what you can do using raspi-config).

It sounds like at the moment the solutions on OSMC either involve lots of command line work, or using additional computers or software.

That’s fine, hopefully at some point in the future OSMC supports a simple way to do this.

OSMC uses the full card when installed, no need too resize after install. When cloning or imaging cards to a different size card then some additional work is required

Understood. I’m talking about transferring a complete disk image from one card to a different, larger card, not a new install.

Understooed, even transferring to n identical card you can have problems due to bad blocks or mfg batch where the 2 cards aren’t identical size so a partition editor is needed. A Gparted Live usb or VM works wonders. Raspi-config was made to resize the root partition after initial install as their installer doesn’t do it OSMC installer does it natively and therefore doesn’t need Raspi-config and most likely will never support it

OK, thanks for the info. It sounds like it’s not part of the OSMC plan, which is fine. I’d consider it a ‘nice to have’, but understand if it doesn’t get implemented.

We already provide a method to backup your Kodi installation using the MyOSMC add-on. What you are asking for is a bit niche.

I accept that. It’s useful if one wants to upgrade SD card size, but doesn’t want to completely reinstall OSMC. I understand that the backup and restore option is available. However this doesn’t cover any other OS customisations made outside of Kodi (eg startup scripts, cron jobs, custom services, VPN server etc).

Again, I understand this is not mainstream use, and I accept that it’s not part of the plan.

I did not know there was a backup mechanism built-in - that’s good to know! BUT, now that I’ve cloned an entire OSMC 4GB card and restored back to a 16GB one, I ended up with actual 8GB space only.

this 16GB card $df -h outputs:

Sist.fichs      Tama  Ocup Livre Uso% Montado em
/dev/root       7,0G  3,8G  2,8G  58% /
devtmpfs        363M     0  363M   0% /dev
tmpfs           367M     0  367M   0% /dev/shm
tmpfs           367M  5,0M  362M   2% /run
tmpfs           5,0M     0  5,0M   0% /run/lock
tmpfs           367M     0  367M   0% /sys/fs/cgroup
/dev/mmcblk0p1  240M   24M  217M  10% /boot
tmpfs            74M     0   74M   0% /run/user/1000

So, I was wondering if I could simply manually resize it via SSH following this setup: RPi Resize Flash Partitions - eLinux.org

Could you tell me, @ActionA, if that is a viable option? Would I lose data? Or should I just use OSMC’s backup mechanism → reformat my 16GB card → re-install OSMC and then restore previous OSMC backup ? Would that work?

Thanks a lot for OSMC, btw! :wink:

1 Like

Should be fine.

Which one do you mean? OSMC’s backup and restore or using fdisk and resize2fs commands?

EDIT: Ended up using gparted and everything went fine! :slight_smile:

I have just resized the mmcblk0p2 partition by using the procedure described on the elinux.org link you have provided, and all I can say is - it works. :smile:

1 Like

Yes, the procedure works indeed. I was a bit unsure about how to adapt it to the OSMC installation though. I just gave it a try, as this was anyway a backup, and it worked as reported.

For those not familiar with the fdisk commands here my walkthrough (change from the link by simply deleting only the second partition entry, there is no third partition in OSMC (2016-04)):

osmc@osmc:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        362M     0  362M   0% /dev
tmpfs           367M  5.0M  362M   2% /run
/dev/mmcblk0p2  1.6G  985M  492M  67% /
tmpfs           367M     0  367M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           367M     0  367M   0% /sys/fs/cgroup
/dev/mmcblk0p1  240M   41M  200M  17% /boot
tmpfs            74M     0   74M   0% /run/user/1000

start ‘fdisk’, p (print partition table), d (and then 2, delete second partition entry), w (write changes), ‘sudo shutdown -r now’ (reboot), and lastly use ‘resize2fs’

osmc@osmc:~$ sudo fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 7.5 GiB, 8068792320 bytes, 15759360 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: 0x000bb62a

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1        2048  499711  497664  243M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      501760 3842047 3340288  1.6G 83 Linux


Command (m for help): d, 2
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Command (m for help): p
Disk /dev/mmcblk0: 7.5 GiB, 8068792320 bytes, 15759360 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: 0x000bb62a

Device         Boot Start    End Sectors  Size Id Type
/dev/mmcblk0p1       2048 499711  497664  243M  c W95 FAT32 (LBA)


Command (m for help): n p 2
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (499712-15759359, default 499712): 501760
Last sector, +sectors or +size{K,M,G,T,P} (501760-15759359, default 15759359): 

Created a new partition 2 of type 'Linux' and of size 7.3 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

osmc@osmc:~$ sudo shutdown -r now

Pi reboots

osmc@osmc:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        362M     0  362M   0% /dev
tmpfs           367M  5.0M  362M   2% /run
/dev/mmcblk0p2  1.6G  985M  492M  67% /
tmpfs           367M     0  367M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           367M     0  367M   0% /sys/fs/cgroup
/dev/mmcblk0p1  240M   41M  200M  17% /boot
tmpfs            74M     0   74M   0% /run/user/1000
osmc@osmc:~$ sudo resize2fs /dev/mmcblk0p2 
resize2fs 1.42.12 (29-Aug-2014)
Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p2 is now 1907200 (4k) blocks long.

osmc@osmc:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        362M     0  362M   0% /dev
tmpfs           367M  5.0M  362M   2% /run
/dev/mmcblk0p2  7.2G  986M  5.9G  15% /
tmpfs           367M     0  367M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           367M     0  367M   0% /sys/fs/cgroup
/dev/mmcblk0p1  240M   41M  200M  17% /boot
tmpfs            74M     0   74M   0% /run/user/1000

You can see in with the last three commands that it successfully extended the ~2GB partition (1.6G) to the 8GB size (7.2G) of the SD card.

Thanks for the useful info here!

2 Likes

Hi fabern,
I have tried your guide above with a 32G SD Card (Image was 8G), but when rebooting, the system was shot. I think, my mistake was typing first sector and last sector. I typed in the default informations. What should I do? Thank you

I have the same problem as Ernesto. I followed Fabern’s instructions to the letter, but when I reboot, there is no root file system device /etc/mmcblk0p2 and no opportunity to “resize2fs”.

The 8gb card I was using when it ‘hosed’ is not the brand I usually use (it came with the Pi, never again), and it is slightly different in size than the 8gb one that works (in another identical system). When I try to clone I get an error that there is not enough room. So I decided to use a 32gb one and that works fine. I just cannot seem to expand the /etc/mmcblk0p2 partition to use the whole remainder of the card. I wish to keep my linux tweaks as the OP so that is why I cloned.

Sorry to reply to an older thread. This is the closest to my issue after a few hours of google searching.

Dev not etc

Post commands that don’t work so we can
advise

Sorry, I mistype it. Yes it was /dev/mmcblk0p2. But then of course it was. Sorry for the confusion.