20

So I got my new pi and the only free SD I had was 2GB. I couldn't hold off playing with it so it had to do for the time being. I loaded raspbmc and then spent time loading repositories, add-ons and customizing to my liking.

I now I have a 16GB class 10 in the mail and am wondering how to go about copying my current setup to that SD. My first thought is use Win32 Disk Imager to read from the 2GB and then write to the 16GB. However this would then leave only 2GB available to the pi on the 16GB correct? Essentially I am wondering how one would go about re-sizing the partition to use all of the available space on the 16GB SD.

Looking here I see that the ext4 partition at /dev/mmcblk0p3 is the one that would need re-sizing. Is this possible without deleting the contents of that partition?

The problem is, I only have windows PC's available to me. I suppose I could load raspbian on the 2GB after I copy the image to the 16GB to get a more functional linux box but hopefully that's more work then necessary... Im open to any suggestions, just would rather not have to start from scratch with a fresh raspbmc install.

13

I think you should look into doing this so you can take and restore backups of your card from time to time. Once you get a second card and as long as you don't destroy the original one, it should be easy to experiment. And yes, it should work.

Some instructions on how to set up a card image can be found on the RPI wiki "easy SD card setup". There's also a page on resizing partitions on rpi. Raspi-config can apparently also do this automatically.

Essentially you should be able to use parted, fdisk, cfdisk or other tool to resize the root partition and use resize2fs to make the filesystem use the extra space.

This should all work from the running Linux system on the PI, so as long as you can get the image on the card correctly in windows, it shouldn't be a problem anymore.

Note that depending on your distribution of choice and version, the card may be set up in different ways and the instructions might not be correct to the letter. But the idea is the same. Find the root, stretch it, resize the filesystem and enjoy your new space (and a 16GB image you need to back up).

Related:

|improve this answer|||||
1
dd if=/dev/sdc of=/dev/sdd bs=1m

I don't see how you can do this on the pi as it has only one SD card slot.

|improve this answer|||||
  • 3
    I do not think this would help the OP much. As you point out the RPi only has one SD card slot - though it might be possible to add another one to the SPI pins on the GPIO port, or via a Card Reader/Writer plugged into a powered Hub attached to the USB bus. Using dd to read/write from/to the storage medium is best done on inactive media which requires mounting the SD Card in say a Linux PC - but as the OP is talking about using Win32 Disk Imager it is reasonable to believe that they have (only) a Windows PC! – SlySven Jan 19 '16 at 4:07
  • Think outside of the box, guys (literally): take old small SD card of of the Pi, insert into laptop, run dd if=/dev/sdc of=/tmp/image.bin bs=1m, take out old small SD card out of laptop and put in new big SD card, run dd if=/tmp/image.bin of=/dev/hdc bs=1m, take new big SD card from laptop and put it into the Pi. – Tomislav Nakic-Alfirevic Dec 9 '16 at 14:25
1

The following worked for me, with an SD card that was originally prepared with NOOBS. I was going from a 32GB SD-Card to a 128 GB Card.

  • Insert the new card into an external card reader and attach it to the Pi.
  • Close all windows that pop up
  • Open gparted using sudo gparted
  • The drop-down at the upper right will have two entries, one named /dev/mmcblk0 (that's the SD card the Pi now booted from) and one named /dev/sdb or similar, which is your new card.
  • Unmount any volumes and delete all partitions from /dev/sdb (right click on the partitions to get a menu)
  • Accept those changes, then close gparted
  • Use sudo dd if=/dev/mmcblk0 of=/dev/sdb bs=4M status=progress to clone the existing disk to the new SD card. This will take a while.
  • When it's done, open gparted again, and check that you'll now have the same partitions on the source and the target disk.
  • On the new disk, select the partition which has "extended" in the file system. This is a container for three other partitions: settings, boot and root (we want to extend the root partition, as this is the one that contains all user data and applications, but we cannot directly do that, because it's limited within that container partition)
  • Extend the size of the extended partition to fill the whole disk
  • Apply the changes
  • Note: Now the root partition still has the old size, but we could extend that now. For safety, we make sure the existing state boots first, though.
  • Now shut down the pi, and insert the new SD card into the SD card slot of the Pi.
  • Reboot, now using the new card
  • Once the Pi has booted open gparted again, and now extend the root partition to fill the whole remainder of the disk
  • Apply changes
  • Reboot
  • If everything worked well, your Pi has now much more disk space to play around with. If it failed, you still have the old card as a backup.

Note: I tried to do the partition changes on a Windows PC, using different partition tools, but they all failed with strange "Disk IO error" messages, although the SD card is clearly ok. Despite the large advertisement banners for these partition tools on google, they all failed.

|improve this answer|||||
0

In your case, where your original card is smaller, and the target is bigger you can go straight with:

dd if=/dev/sdc of=/dev/sdd bs=1m

This will make a byte level clone from sdc to sdd, but beware those might be different in your specific case.

After that, you just boot & run raspi-config on the new card and let it resize the partition, voila!.

|improve this answer|||||
0

There is an app called sdcrad copier (piclone) available now. Use that app to make a complete backup of your OS and you can use that later.

|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.