Community
OpenEnergyMonitor

Community

emonSD-17Oct19 Image partition sizes

Just got to this, thanks work!
Sorry for the simple question, but with previous image and a 32GB card i have a nice big partition in pi/home to install home assistant. This time around with latest image, I can’t (don’t need to?) run emonSDexpand command as not found, and I no longer have the full card to put data on - missing 16GB. What have I missed?

From fdisk command (snipped /ramX disks):

Disk /dev/mmcblk0: 29.7 GiB, 31914983424 bytes, 62333952 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
Disklabel type: dos
Disk identifier: 0x6c586e13

Device         Boot   Start      End  Sectors  Size Id Type
/dev/mmcblk0p1         8192   532479   524288  256M  c W95 FAT32 (LBA)
/dev/mmcblk0p2       532480  8959999  8427520    4G 83 Linux
/dev/mmcblk0p3      8960000 30228479 21268480 10.1G 83 Linux

I’m going to split this question out. [and edited as my sizes were wrong]

The image is optimised for emoncms data going onto an Ext2 partition (to improve life of card). It is also an image designed for a 16Gb card.

sudo parted -l

gives more information.

Yes you can create a partition in the spare space but I’m not exactly sure how. Partly depends what you intend to add to this Pi.

If you use the scripts to install, you can amend the sizes of the resulting partitions so rootfs will be bigger.

I used the Raspbian script for expanding a new card and just added a new partition to it. Currently the start of the Ext2 partition is roughly 4 GB from the start of the card, so following the Pi preparation instruction on a 32GB card would result in a 28GB Ext2 partition. This can be used for other things but it might make more sense if it was 8-10GB from the end - I doubt emoncms data will exceed that - equally it could be an option when installing from the script.

Sadly I can’t remember why I ended up with 8960000 as the figure. I think it needed to be divisible by 1024 (Ext2 block size) so you could start again from scratch (Raspbian Lite image) and at the point where you copy the init_size script, edit the figure to be 26,880,000 as the start figure. I’m sure the rootfs will just fill the space.

@TrystanLea, it might make more sense if it was the Ext2 partition that was a fixed size from the end rather than the beginning.

Just looking at my card (an image I burned), the size of the Ext2 partition is 21268480 sectors ~10.1GB. I’ll use that.

That line I think would therefore be Card_Size - 10GB - 1 so

TARGET_END=$((ROOT_DEV_SIZE -  21268480 - 1))

@Tockley - you could try this if you like…

One other thought, there probably should be a check on card size during this process. You could run Emoncms on either a 4GB or 8GB card in reality so perhaps the init script should take account of that (future dev). Equally the documentation should state a minimum 16GB card for this image and the Scripted install (PR done).

1 Like

I’ll add that I’m not convinced of my numbers and if someone with more knowledge of sectors/blocks etc wants to chip in, feel free.

Thanks for the detail @borpin! I’ve ignored the skipped space for now, and gone with a docker & HA install in the new emoncms partition… 10GB is a fair amount of space still obviously. :wink:

All running ok, zero issues with the emonPi reflash, install, connection, etc. As always, ran all the latest pi and raspbian update gets (update, upgrade, dist) and no issues seen. Backup restore worked flawlessly and I was back up and running my solar graphing super quickly. Maybe I’m also well practiced!

1 Like

I love HA!

I have had a chance to try this out and the sizes above are not correct. This added to the init_resize.sh script will work.

#EmonSD Fix end of Rootfs
if [ $ROOT_DEV_SIZE -gt 16000000 ]; then
  #16GB card or above, assign last 10GB for data 
  TARGET_END=$(($ROOT_DEV_SIZE - 20972544 - 1 ))
elif [ $ROOT_DEV_SIZE -gt 8000000 ]; then
  #8GB card, assign last 4GB for data 
  TARGET_END=$(($ROOT_DEV_SIZE - 7341056 - 1 ))
fi

The original sizes I proposed did not align optimally.

For future ref, the key figure is 2048. parted wants the start of a partition to start on a multiple of 2048. Because of the calculation, and the fact the whole SD card is not a multiple of 2048, this caused a problem as the rootfs did not finish on a 2048 boundary.

The Ext2 partition is not a multiple of 2048 (it doesn’t need to be).

I am, however, not convinced this is robust for all SD cards - it assumes that the whole card is not a multiple of 2048 - I hate assumptions!

Can anyone suggest a way in bash to check the alignment figure?

1 Like

Stupid question I am sure, but here goes!
I am using previous SD Oct18, I can update to latest but what advantage would I get from this? Everything running fine at the moment.
Thanks

No such thing as a stupid question IMHO.

There are 2 levels of update. Going into the Admin page and clicking ‘update’ will give you the most recent stable release of Emoncms and the installed Modules.

The new image has introduced some changes (such as folder structure), improvements (such as log file management) and is based on the most recent Raspbian release of ‘Buster’. The value of this update, however, is up to yourself.

It is reasonably simple to move to the updated image. You can use the ‘Backup’ feature to export all your settings etc which can be imported then to the new image.

Just thought it was worth posting a quick update on this release. I haven’t done anything about the partition sizes, but everything working beautifully. Good, solid release guys - ticking along very nicely, well done yet again! :grinning:

2 Likes