Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

[SOLVED] How do I resize the filesystem?



  • I have recently cloned my retropie install onto a larger sd card. How do I rerun the expand file-system from the initial install?



  • @frob I think you should exit emulation station and run

    sudo raspi-config

    from the command line. Once in this, I think option 1 is expand the file system.

    However, I am unsure of how a clone of say a 32GB install, could be written to a card greater in size as the settings in the cloned image are all for that initial size. It may work, but I have never tried to do it.

    It may not be as easy as I say, so take a look at this for further info: http://superuser.com/questions/460657/cloning-an-sd-card-onto-a-larger-sd-card



  • Thank you, I will give that a try tonight. I am moving from a 4GB to a 16GB so hopefully I will not run into that problem.



  • That worked, Thank you very much. It does require a reboot afterward, but that's no matter.

    Thank you.



  • @frob Good to hear. Thanks for reporting back as it will help others.



  • How long does expanding the file system take for most people? I'm doing this for the first time: I cloned my 32gb card onto a 128gb card (that 128gb card has been PERFECT for multiple installs before -it was running perfect earlier today- so the card is definitely good), and ran the raspi-config to expand, and rebooted.

    ...it's been running lines of code on the screen for a GOOD half hour+ now....just want to make sure that's normal. Saying things like "inode 1065439 us in use, but has dtime set. Fix? yes", and "Inode 1065440 has a extra size (1) which is invalid Fix? yes", and "Inode 1065441, i_size is 1093285472039455873204857, should be 0, Fix? yes". (and these are scrolling across so fast I had to take a picture of the screen just to be able to read it)

    If this isn't normal, I'll pull the 128gb card and use ApplePi-Baker on it again to restore from my backup of the 32gb card (which hopefully works as I have a good 10+ hours into that setup....most from the hours it takes to install the packages I use from source, and the friggin slow scraper...).

    EDIT....I'm at 3.5 hours now...I pulled the plug and am starting over...no way this should take that long...



  • I have a backup image of my retropie from a 32 gb sdcard and i want to restore this backup to a new 128gb sdcard so i can add more roms.
    Do i only have to add this command line -> sudo raspi-config and then just press expand the file system and reboot?
    Will this work?



  • @soulfunkdjx said in How do I resize the filesystem?:

    I have a backup image of my retropie from a 32 gb sdcard and i want to restore this backup to a new 128gb sdcard so i can add more roms.
    Do i only have to add this command line -> sudo raspi-config and then just press expand the file system and reboot?
    Will this work?

    In theory yes, but from my above post you can see that it doesn't always work...don't know if my image was bad or what...I had to start ALL over.


  • administrators

    @Dochartaigh Sounds like you have filesystem corruption there - you should not get an error like that. Probably badly cloned/written image (unless the card has developed problems).



  • @BuZz said in How do I resize the filesystem?:

    @Dochartaigh Sounds like you have filesystem corruption there - you should not get error like that. Probably badly clones/written image (unless the card has developed problems).

    My thoughts too. Totally stinks. This is why I always used BerryBoot for super-easy backups (until you told me the BerryBoot kernels were outdated ;) I may try to find some other program than ApplePi-Baker program on my mac and see if that does it correctly (i know the built-in Disk Utility can make images - but I've never tried it on an SD card)...and I'm afraid I don't have a 2nd 128gb card that the new RetroPie install is now on to test it - and don't want to take the chance of formatting my one card and trying to restore that backup in case it's corrupted again.



  • Most of these programs are just a GUI that runs the dd command. Checkout the official doc on creating images https://www.raspberrypi.org/documentation/installation/installing-images/mac.md and look at the Command Line options.

    dd is used in the unix world to create/restore images of drives. It is normally pretty reliable, but always remember to image and manually backup the retropie directory.

    Also, if you are using dd directly, always double check your command. A typo here and it can easily start to image retropie over your main hdd.



  • another question would be whether it is also reversed? so from a 128GB card to a 64GB card? my complete system even has only 32GB.



  • @cybermen No reverse.You would have to shrink the image down to fit on a smaller card.


  • Global Moderator

    @cybermen said in [SOLVED] How do I resize the filesystem?:

    another question would be whether it is also reversed? so from a 128GB card to a 64GB card? my complete system even has only 32GB.

    You might try using https://github.com/billw2/rpi-clone - it seems to support synchronising the current image to a new media with a different size.
    You could get a new sd card, put the standard RetroPie image on it, then use an USD card reader to synchronise the running SD card to it.



  • thanks for the reply, it will try it.



  • For mac users of sierra, I use a program called Etcher it burns image files perfectly!



  • RetroPie will give you an LBS error trying to resize on boot with retropie 4.4 with berryboot. It will also not allow you to resize it from retropie raspi-config nor while you have retropie booted and using the command line.

    If you are using berryboot with retropie you will need to reboot the pie and do this from berryboots terminal via the berry boot menu with ctrl + alt + F2. I was able to resize an image I took of a 16G SD card written to a 64G card and resize it to expand all available space to the SD.

    Links~
    https://raspberry-projects.com/pi/pi-operating-systems/raspbian/troubleshooting/expand-filesystem-issues
    https://www.chrisnewland.com/resize-raspberry-pi-sd-card-partition-to-fill-32gb-card-from-a-running-raspberry-pi-245

    I cannot take credit for this, but will link what helped me after I spent a few hours trying to figure it out. Back up your SD pay no attention to drive space numbers in the examples below.

    Backup your SD card to an image file first!

    Enter this to see the current partition usage:
    df

    E.g.
    Filesystem 1K-blocks Used Available Use% Mounted on
    rootfs 3698504 3351472 146524 96% /
    /dev/root 3698504 3351472 146524 96% /
    devtmpfs 494800 0 494800 0% /dev
    tmpfs 99820 240 99580 1% /run
    tmpfs 5120 0 5120 0% /run/lock
    tmpfs 199620 0 199620 0% /run/shm
    /dev/mmcblk0p1 57288 19400 37888 34% /boot

    The rootfs and /dev/root is the same thing, its just a debian thing the have them both appear as separate

    Enter this:
    sudo fdisk /dev/mmcblk0

    Then press 'p' to see the current partitions on the disk. E.g.

    Disk /dev/mmcblk0: 7860 MB, 7860125696 bytes
    4 heads, 16 sectors/track, 239872 cylinders, total 15351808 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
    Disk identifier: 0xa6202af7
    Device Boot Start End Blocks Id System
    /dev/mmcblk0p1 8192 122879 57344 c W95 FAT32 (LBA)
    /dev/mmcblk0p2 122880 15351807 7614464 83 Linux

    Now delete the 2nd partition (it won't actually delete the data on it)
    Press 'd' > Enter
    Press '2' > Enter

    Now re-create it:
    Press 'n' > Enter
    Press 'p' > Enter
    Press '2' > Enter

    Enter the First sector and the same value as the original /dev/mmcblk0p2 partition (122880 from the above example).

    For the Last sector just press enter to use the maximum value.

    Now press 'p' > Enter to see the new partition setup.
    Finally press 'w' > Enter to write it

    Now reboot:
    sudo shutdown -r now

    Once its back do the resize:
    sudo resize2fs /dev/mmcblk0p2

    This may take a little while to complete…

    Now enter the command
    df

    and hey presto, you've expanded to use all the space :-)

    Filesystem 1K-blocks Used Available Use% Mounted on
    rootfs 7513804 3352360 3810208 47% /
    /dev/root 7513804 3352360 3810208 47% /
    devtmpfs 494800 0 494800 0% /dev
    tmpfs 99820 240 99580 1% /run
    tmpfs 5120 0 5120 0% /run/lock
    tmpfs 199620 0 199620 0% /run/shm
    /dev/mmcblk0p1 57288 19400 37888 34% /boot



Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.