Resize Coreelec Partition

Is it possible to resize the partition where CoreELEC is installed in case it’s an external SSD? I bought an 128 GB SSD for CoreELEC (Odroid N2) because I found that smaller SSDs than 128 GB are relatively slow (at least according to the data sheets).

At the same time I backup CoreELEC as a full disk image rather than using the integrated zip-backup function because I experienced problems with the integrated backup (unreliable restore).

So each full disk image would consume 128 GB. Is there a way to decrease the size of the CoreELEC partition and to mount the rest as separate storage?

Assuming you’re starting with an empty ssd:
Make a fat32 partition called ‘COREELEC’. This can be anything from 500MB up, it’s basically where your coreelec read-only operating system sits. I use a much bigger partition so I can eg transfer backups to it, but there’s no need.
Make an ext4 partition called ‘Storage’. This holds all your data, caches, backups etc - I’d normally use at least 8GB for that but you can get away with less.
Put whatever other partitions you want on the ssd.
Install coreelec to an sd card or usb stick, and on your pc copy everything you see in the new install onto your ‘COREELEC’ partition.
Cross fingers, boot from the ssd.
Obviously none of the above is an approved method (and it’s from memory so hopefully I haven’t missed anything).
Edit: In windows I use Mini Tool Partition Wizard for all the above. It’s free and it does the job.

I’m not clear how you intend to image just the first 2 partitions though. I would have though you’re still going to end up with a 128GB image. You could try a backup by just copying everything from each partition to your pc over smb or ftp - if doing that I connect via ssh and run ‘systemctl stop kodi’ first, copy stuff, then ‘systemctl start kodi’ when I’m done.

Thanks a lot for your explanation! And of course, you’re right: I really did not think about the issue of imaging only a part of the partitions of a drive.

But maybe your workaround solves another idea of mine: dual-boot (e.g. CoreELEC and Android) from the same SSD :slight_smile:

You would only end up with a 128Gb disk image if you are doing a full sector backup.

I’m not sure which imaging program you are using to backup but see if there is a more efficient mode that only backs up the used area and can also compress it further to keep the backup as small as possible.

hello, you can completely install coreelec which only takes 2 to 8gb of space on your 128gb ssd drive, and creates partitions with the remaining space for separate storage

I know this topic is old but I have the exact same problem after upgrading from a 32 to a 128 GB SD card. What I already tried:

  • Create the file /storage/.please_resize_me : CoreELEC refuses to resize cause already initialized.
  • Resize the partition with parted - works. Then do a fsck - works. Then resize the FS online - seems to work, fsck can’t find any errors but the superblocks are corrupted beyond repair and the partition can’t be mounted cause of that.
  • Try to systemctl stop as many apps as possible to unmount the FS for offline resize: Not possible (systemd itself is one of the processes occuping /storage).
  • Add coreelec=‘debugging textmode nosplash’ to /flash/config.ini - /storage is already mounted when it stops the boot process.

So is there any way to stop the boot before /storage gets mounted or unmount it completely after booting? I think a offline resize could work but can’t try as I can’t find a way to take the FS offline.

I really don’t want to reinstall as the setup is hardcore customized and recreating that would be a PITA. Just let me use my damn backup, please. :sob:

//EDIT: Forgot one step I tried: stop as many processes as possible, then use umount -l to kick-off the FS: fsck refuses to work as “the filesystem is in use”. So mount it again but read-only: fsck works but resize2fs tries to do a online-resize which fails cause read-only… If I scrap the fsck step, so don’t remount ro, resize2fs fails cause filesystem in use but not online…

Use the cmdline cmd: break=
Like break=mount_sysroot should give you console before mounting storage partition.

@Portisch Thanks for this. Sadly it doesn’t work, CoreELEC seems to ignore the break:

CoreELEC:~ # cat /proc/cmdline && mount | grep storage
console=ttyS0,115200 console=tty0 no_console_suspend BOOT_IMAGE=kernel.img boot=UUID=0908-3440 disk=UUID=d4ae87f0-8f5c-49d8-9df6-0a45562a8c4f hdmimode=1080p50hz logo=osd0,loaded,0x3dc00000 vout=1080p50hz,enable frac_rate_policy=0 native_4k_gui=0  cvbsmode=nocvbs consoleblank=0 quiet break=mount_sysroot systemd.show_status=auto
/dev/mmcblk1p2 on /storage type ext4 (rw,noatime,data=ordered)

I also tried to set it in /flash/config.ini but it’s ignored there, too.

break= needs also debugging.

Also script file /flash/post-flash.sh could be used to execute some commands after /flash is mounted.

I finally managed to boot withoug /storage by changing the UUID in /flash/boot.ini. Sadly in that configuration resize2fs is not available (and neither is nano, making it hard to change the cmdline back to normal).

It’s the same when booting with “debugging break=mount_sysroot”.

@vpeter I guess resize2fs is stored on /storage ? If so it’s impossible to do a offline resize and /flash/post-flash.sh won’t help here, too. :frowning:

//EDIT: Made it! Steps to reproduce:

  1. Resize the partition with “parted resize 2”, type Yes when asked if you want to resize while mounted. Type 100% when asked for the new end.
  2. Copy resize2fs from /usr/sbin to /flash
  3. Reboot
  4. Add “debugging break=mount_sysroot” to the cmdline
  5. Execute "fschk.ext4 -f /dev/mmcblk1p2 && /flash/resize2fs /dev/mmcblk1p2 && fschk.ext4 -f /dev/mmcblk1p2 && poweroff
  6. Put the SD card into a PC and remove “debugging break=mount_sysroot” from the cmdline

Actually it is better to use script /flash/post-sysroot.sh


and use /sysroot/usr/... path to binaries.

Even in plain console you can mount SYSTEM file manually and use all the tools.

mkdir /sysroot
mount /flash/SYSTEM /sysroot

Thanks a lot for this, too. :slight_smile: Anyway, as you see in my last edit I already managed to resize. Yes, your way would be better but it’s already done, so… :wink: