Possible to duplicate SDCARD...?

So all working now?

No. I mistyped what I did, but I was correct in what I used.

Then please post the commands you’re running and the output you are
getting

OK, again, I was following fabern’s guidance and used fdisk to remove the 2nd partition /dev/mmcblk0p2. I rebooted but instead of being able to run resize2fs, the pi did not reboot. Yes the partition I removed (there were only 2) is the one that showed as ext4.

If you need me to, I can post the terminal output of what I am doing. I just have to burn the flash again from the clone img file I made.

I think you should do that

No one really knows what you’re doing or even trying to achieve. If you’re cloning a card you shouldn’t be deleting partitions…

My apologies. When I added, I thought Pedro’s post about resizing the root partition to use the remainder of a larger SD card was the first post, the OP. Reading up to his post would clarify exactly what I am doing. Instead of including everything here, I will start another thread if needed. In the meantime I will try to resize the root partition using other means on a linux rig or VM. Thanks.

I am not just deleting partitions to no end, I was trying to resize the root partition, as in…

To be honest I just took a quick cross read on that instructions and I believe the risk of that method is as risky as a open heart surgery. Suggest to use a Linux box or a live Linux VM to resize the partition with garter.

I will agree although I have done this sort of thing before with success, it has just been awhile. The only reason I had no fear with this is because I have an IMG that I created from my other working OSMC. So I am not risking anything.

I haven’t read through this whole thread, but I have successfully cloned cards with this. You put the target in a card reader on the Pi and just go:

sudo osmc-restore -f /

and choose the card name at the prompts. It will warn you if the system won’t fit on the target card.

Thanks for that tip. Ironically, it is not the OSMC I want to back up, but the stuff I did outside of OSMC influence.

I figured it out. The instructions from fabern was missing a step. It has been a few years since I have done this but I had a feeling something was missing. The link to the solution is actually at the top of this thread. http://elinux.org/RPi_Resize_Flash_Partitions#Manually_resizing_the_SD_card_on_Raspberry_Pi

The missing step is to create a new partition with the same start sector as the deleted partition BEFORE writing changes and rebooting. I just did it and it worked for me.
BEFORE…

Command (m for help): p
Disk /dev/mmcblk0: 29.7 GiB, 31914983424 bytes, 62333952 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: 0x00095b1c

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

AFTER…

Command (m for help): p
Disk /dev/mmcblk0: 29.7 GiB, 31914983424 bytes, 62333952 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: 0x00095b1c

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

hop@osmc:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        235M     0  235M   0% /dev
tmpfs           240M  4.4M  235M   2% /run
/dev/mmcblk0p2   29G  4.4G   24G  16% /
tmpfs           240M     0  240M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           240M     0  240M   0% /sys/fs/cgroup
/dev/mmcblk0p1  240M   35M  205M  15% /boot
tmpfs            48M     0   48M   0% /run/user/0

Manually resizing the SD card on Raspberry Pi
You can also resize the partitions of the SD card that your Pi is running on.

First you need to change the partition table with fdisk. You need to remove the existing partition entries and then create a single new partition than takes the whole free space of the disk. This will only change the partition table, not the partitions data on disk. The start of the new partition needs to be aligned with the old partition!

Start fdisk:

 sudo fdisk /dev/mmcblk0

Then delete partitions with d and create a new with n. You can view the existing table with p.

  1. p to see the current start of the main partition

  2. d, 3 to delete the swap partition (may not be present in OSMC installs)

  3. d, 2 to delete the main partition

  4. n p 2 to create a new primary partition, next you need to enter the start of the old main partition and then the size (enter for complete SD card). The main partition on the Debian image from 2012-04-19 starts at 157696, but the start of your partition might be different. Check the p output!

  5. w write the new partition table

  6. Now you need to reboot:

    sudo shutdown -r now
    After the reboot you need to resize the filesystem on the partition. The resize2fs command will resize your filesystem to the new size from the changed partition table.

    sudo resize2fs /dev/mmcblk0p2

Just to confirm, that if you follow the instructions carefully then the method posted by @fabern (post #35) and @HopWorks worked for me.
But note the following…

  • When the second partition is created it must be the same as the original. Both their text outputs show 501760, which was the same for me (NOT the 157696 that HopWorks later quoted in his summary from Debian).
  • The “n p 2” command (which fabern is missing from his one-line summary but DOES have in his detailed description) asked me an additional question
    Created a new partition 2 of type ‘Linux’ and of size 9.3 GiB.
    Partition #2 contains a ext4 signature.
    Do you want to remove the signature? [Y]es/[N]o:
    Since you want to preserve and expand this partition, it seemed to me that the correct answer should be NO; which worked OK for me.
  • You may want to make the new p 2 size smaller than the device for 2 reasons.
    1. only make the new partition as big as the RPi will NEED; if you backup, the zipped image will be smaller (as long as the unused SD space is zeroed).
    2. SDs can vary in size by a few 10M; make the partition end a few 10M smaller than the SD, then an SD-to-SD copy is guaranteed to fit.

Hope that helps anyone finding this thread as I did.