12

I was trying to perform an update and an error told me that I hadn't enough free space. So I connected to my Raspberry through SSH to ask for disk usage with:

df -h

And I obtained the following result:

Filesystem                Size      Used Available Use% Mounted on
devtmpfs                185.1M     87.5M     97.6M  47% /dev
/dev/mmcblk0p1          124.7M     96.2M     28.6M  77% /flash
/dev/mmcblk0p2          755.9M    739.4M         0 100% /storage
/dev/loop0               87.5M     87.5M         0 100% /
tmpfs                    74.6M         0     74.6M   0% /dev/shm
tmpfs                    10.0M    684.0K      9.3M   7% /var

The thing is my SD card is an 8Gb SD card and the size it displays is more like 1Gb, so my question is why can't I see the whole space?

syb0rg
  • 8,188
  • 4
  • 37
  • 51
darkheir
  • 223
  • 1
  • 2
  • 7

7 Answers7

19

OpenELEC resizes /storage on first boot after creating the SD. I looked for the script that does that. It's https://github.com/OpenELEC/OpenELEC.tv/blob/master/packages/sysutils/busybox/scripts/fs-resize?source=c The first code line checks for /storage/.please_resize_me file.

So... to resize storage to fill the SD you need to:

touch /storage/.please_resize_me
reboot

Done that on my OpenELEC 4.0.7 and worked fine.

Marcin
  • 191
  • 1
  • 2
  • tried it on 5.0.3 and it worked as stated – LowvaPrg Feb 23 '15 at 02:24
  • On the second line of the script it says that it can't resize if there exists a folder named kodi, config or cache. I got all 3 of them... So how do I resize now? – Peter Raeves Jan 03 '16 at 16:04
  • I tried this and a message flashed up on the screen that said something like "can't resize because system is already initialized", but then strangely, my "Used" column in the system info storage page went down from 6G to 872M but I still couldn't upload. So I just did: https://raspberrypi.stackexchange.com/a/124640. disk usage stats are still messed up but I can upload again – Alex028502 May 08 '21 at 07:58
13

Modified from here, SSH into your Raspberry Pi running OpenELEC and follow these steps.

  1. SSH in as root, by default you’re in /storage; switch to root partition:

    $ cd /
    
  2. Keep XBMC from restarting:

    $ touch /var/lock/xbmc.disabled
    
  3. Stop XBMC, so we can unmount /storage:

    $ killall -9 xbmc.bin
    $ umount /storage
    
  4. Verify mounts:

    $ mount
    $ parted /dev/mmcblk0
    
  5. In parted, change to sectors display:

    $ unit s
    
  6. Show partitions, make note of starting sector of your partition:

    $ p
    
  7. Remove the partition:

    $ rm 2
    
  8. Re-create it, using same starting sector number and ending in "-1" to use remaining space:

    $ mkpart primary 258048 -1
    $ quit parted
    $ e2fsck -f /dev/mmcblk0p2
    $ resize2fs /dev/mmcblk0p2
    $ mount /dev/mmcblk0p2 /storage
    $ df -h
    $ rm /var/lock/xbmc.disabled
    
  9. XBMC will start up again on its own.

syb0rg
  • 8,188
  • 4
  • 37
  • 51
4

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 !

Guest
  • 41
  • 1
  • Doesnt work, connmand restarts itself automatically before the terminal can run the umount – Rob Dec 29 '13 at 19:47
2

In case anyone has this problem with newest version:
syb0rg answer is great but
$ touch /var/lock/xbmc.disabled
$ killall -9 xbmc.bin

does not work anymore! Use:
$ systemctl stop kodi.service instead!

lewiatan
  • 713
  • 2
  • 8
  • 15
2

Openelec 5:

Check what process are blocking the partition /storage to be unmounted

lsof | grep "/storage" (will return the PID of the process)

Check if these processes are in the systemd tree and are controlled by systemd.

systemctl status will show the systemd tree.

In may case I had to stop the following:

systemctl stop cron.service
systemctl stop connman.service
systemctl stop kodi.service

Check with fuser -m /storage if there are still process blocking that directory. In case some PID are returned you can check what process is associated with that PID running ps -ef | grep $PID.

If you see something like -sh it is your ssh session that is in the /storage directory. cd / to go in the root.

Otherwise you can kill that process with kill -9 $PID.

Now you can safely unmount the /storage directory via

umount /storage

Now you can resize the partition (I will report again since some commands are changed)

  1. Ensure which particion /storage belong to

    df -h

In most of the case will be /dev/mmcblk0p2 (which is partition 2)

  1. Open parted for the device /dev/mmcblk0

    parted /dev/mmcblk0

  2. Show partitions (we alredy now which partition we want to resize)

    p

  3. Resize the partition (this case partition 2 till the end)

    resize 2 -1

    quit parted

  4. Resize the file system

    e2fsck -f /dev/mmcblk0p2

    resize2fs /dev/mmcblk0p2

    mount /dev/mmcblk0p2 /storage

    df -h

If you want to resize /flash is a completely different story.

Jero
  • 21
  • 2
1

I solved the issue about "unmount storage/" killing in this way:

fuser -m /storage

5161

kill -9 5161 && umount /storage

That's worked for me.

user11691
  • 11
  • 1
0

None of the above immediately worked, so I just put the SD card into my ubuntu computer and resized the disk using the disk utility

so far so good

Alex028502
  • 149
  • 1
  • 10