Resize OpenELEC XBMC ‘storage’ Partition

The Problem

The /storage filesystem created by the Raspberry Pi build of the OpenELEC XBMC Media Center is limited to 755.9MB, no matter the size of the SD card upon which it is installed.

All of my content is stored on two ReadyNAS network storage appliances, so the space limitation was easy to overlook until I attempted to download several add-on skins that failed during installation and were not cleaned up properly. Since the /storage filesystem also caches thumbnails and other movie and episode information in a hidden folder (/storage/.xbmc/), the Media Center staunchly refused to add more content, even after I deleted and re-added all video sources.

The XBMC System Info / Storage screen shows that /storage is full, confirmed by running “df“.

# df
Filesystem           1K-blocks      Used Available Use% Mounted on
none                    189512     89556     99956  47% /dev
/dev/mmcblk0p1          127730     99214     28516  78% /flash
/dev/mmcblk0p2          774064    773968         0 100% /storage
/dev/loop0               89472     89472         0 100% /
none                    191008         0    191008   0% /dev/shm

The Solution

You will need to delete and re-create an existing partition on your SD card. While everything worked for me without any data loss, it is possible that this may forever delete all your add-ons, your cached data and thumbnails, and many of your settings. If you are comfortable and OK with doing so, then proceed onward. If not, stop and do nothing.

First, the caveat:

Author’s Note: This worked for me on my RPi running the OpenELEC 3.01 build with Linux 3.6.11 and XBMC 12.2 (“Frodo”). It might not work for you on any other version, or even on the same version. If it doesn’t work for you and you break your Raspberry Pi or your Media Center because you didn’t understand the computer science behind it (or, Heaven forbid, I made a mistake in the instructions) — well, that’s not my problem and I don’t want to hear any whinging. You assume all risk and accept any data loss. I am not liable for anything, and neither is my family, my friends, my cats, my co-workers, the good and talented folks at Raspberry Pi or the XBMC Foundation, my web hosts, my ISP, the Easter Bunny, Barack Obama, or Wil Wheaton.

  1. SSH to your Raspberry Pi as root (the default password is “openelec”, without quotes)
  2. Get out of the default /storage partition.
    cd /
  3. Disable XBMC.
    touch /var/lock/xbmc.disabled
  4. Stop the XBMC server. OpenELEC’s wiki recommends the following, but only “as a last resort”:
    killall -9 xbmc.bin

    I prefer to use a gentler approach which allows the process to close down properly.

    killall -SIGHUP xbmc.bin
  5. (Optional) Verify by running “top” that the XBMC processes are no longer running.
  6. (Optional) Verify by running “mount” that the /storage filesystem is mounted. Make a note of the name of the underlying filesystem upon which /storage is mounted, e.g. “/dev/mmcblk0p2”.
  7. Unmount the /storage filesystem.
    umount /storage
  8. (Optional) Verify by running “mount” that the /storage filesystem is no longer mounted.
  9. Start up the partition editor (the partition specified here must match the output of the underlying partition name of the /storage mount from either the “df” or “mount” commands issued earlier, without the “p*” suffix; i.e. specify the “/dev/mmcblk0” device when editing the “/dev/mmcblk0p2” partition)
    parted /dev/mmcblk0
  10. Change display mode from size to sectors. — unit s
  11. Display the list of partitions. — p
    p
    Model: SD 00000 (sd/mmc)
    Disk /dev/mmcblk0: 7995392s
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:
    
    Number  Start    End       Size      Type     File system  Flags
     1      2048s    258047s   256000s   primary  fat16        boot, lba
     2      258048s  1830911s  1572864s  primary  ext4

    Take note of the starting sector number of the second partition. The starting sector number of the second partition on my 4GB SD card is “258048”.

  12. Remove the second partition. — rm 2
  13. Re-create the partition, using the same starting sector as the ending sector and “-1” (minus one; which means use all remaining available space). — mkpart primary 258048 -1
  14. (Optional) Enter “unit GB” and then enter “p” again to verify the new partition settings.
    unit GB
    p
    Model: SD 00000 (sd/mmc)
    Disk /dev/mmcblk0: 4.09GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:
    
    Number  Start   End     Size    Type     File system  Flags
     1      0.00GB  0.13GB  0.13GB  primary  fat16        boot, lba
     2      0.13GB  4.09GB  3.96GB  primary  ext4

    The new partition on my 4GB SD card is 3.96GB (prior to allocating space needed by the filesystem).

  15. Exit the partition editor. — quit
  16. Check the updated filesystem, then resize and remount it:
    e2fsck -f /dev/mmcblk0p2
    resize2fs /dev/mmcblk0p2
    mount /dev/mmcblk0p2 /storage
  17. (Optional) Verify with “df -h” that the filesystem is correctly sized:
    # df -h
    Filesystem                Size      Used Available Use% Mounted on
    none                    185.1M     87.5M     97.6M  47% /dev
    /dev/mmcblk0p1          124.7M     96.9M     27.8M  78% /flash
    /dev/loop0               87.4M     87.4M         0 100% /
    none                    186.5M         0    186.5M   0% /dev/shm
    /dev/mmcblk0p2            3.6G    756.6M      2.7G  21% /storage

    My updated /storage filesystem is now 3.6GB. Perfect!

  18. Re-enable XBMC and the Media Center will automatically restart.
    rm /var/lock/xbmc.disabled

While at first this may seem to be a lengthy, complicated how-to, the actual steps are actually rather simple. With just a few minutes’ work, your OpenELEC SD card will be expanded to its full capacity and the Media Center will be functional once again.

As to my original problem of failed add-on installations, in my meanderings through the operating system, I discovered that XBMC does not delete the original downloaded ZIP files when you delete an add-on; it deletes only the unpacked files from the /storage/.xbmc/addons/ folder. The orphaned ZIP files (which can be 100MB or more for complex skins) are located within the /storage/.xbmc/addons/packages/ folder. I recommend only deleting those packages for add-ons that you have deleted via the user interface.

11 Responses to “Resize OpenELEC XBMC ‘storage’ Partition”

  1. Ju

    One issue I had (with version 3.1.5) :
    umount /storage
    => “umount: can’t umount /storage: Device or resource busy”

    fuser -m /storage
    => pid of the process that was locking the mount
    I tried to kill it, but everytime a new process blocked the mount. I have to kill + umount in the same time with the pipe (in this order) :
    umount /storage | kill -9 pid

    That’s do the job !

    Reply
  2. Arnaud

    Thanks a lot it worked for me. I didn’t understand at first why my movies was detected but not added to library, then, i couldn’t save any new setting, i saw my partition was 100% used and 755mb instead of 30gb.

    I also noticed that my XBMC is running much faster now, don’t know if this helped.

    Thanks again !

    Reply
  3. PAL

    I had the same issue as Ju (above) not able to umount the /storage.
    I followed his suggestion and had success too.
    Finally I have my SD card full space available now.
    Many thanks guys for your clear description and help !

    Reply
  4. NoFearWizz

    Thank you very very much. I had a 750mb storage partition on a 8gb disk. And it was full in no-time.
    Now I can use better skins. It worked like a charm. Only I also needed to kill all processes useing /storage before umount-ing it. But everything else worked like a charm even kept all my data.

    Thanks again!!

    Reply
  5. Markus

    for me this command killed the last process which used /storage

    kill -9 && umount /storage

    Reply
  6. pioupiouprod

    Wah! grateful about your article. This resolved my non-stop problem about openelec rebooting constantly when searching new contents. Thanks.

    Reply
  7. orpheus

    Dåmn, I had to search for ages for a solution to this problem, then I found this info site and thought the search was over.

    But it seems already the idea with the /var/lock/xbmc.disabled file does not prevent the system to stop restarting xbmc.bin any more. (I had a version 4.0.7 running IIRC)

    After more searching I found this VERY EASY solution which seems to be prepared by OpenELEC already: Just create a file “/storage/.please_resize_me” like here:

    touch /storage/.please_resize_me

    and reboot the machine! Reference:
    https://github.com/OpenELEC/OpenELEC.tv/blob/master/packages/sysutils/busybox/scripts/fs-resize

    Reply
  8. Matt

    I have tried to follow your instructions but get as far as step 4 and the pi reboots.
    I have tried using both commands:
    killall -9 xbmc.bin
    killall -SIGHUP xbmc.bin

    Once the pi reboots into OpenElec I have to start over!
    I am using a Raspberry Pi B+ with OpenElec 4.0.5 on a SanDisk 64GB Class 10 card.

    Help!

    Reply
  9. Uli

    Thanks for the instructions! I managed to move from a 8 GB card to a 16 GB one with only one tiny problem:
    Disabling/Re-enabling Kodi (formerly XBMC) at the beginning/end didn’t work as described.

    OpenELEC is using systemd now, so steps 3 and 4 just become:
    systemctl stop xbmc.service

    And the last step changes to:
    systemctl start xbmc.service

    Reply


Leave a Reply

  • (will not be published)