We use some essential cookies to make our website work.

We use optional cookies, as detailed in our cookie policy, to remember your settings and understand how you use our website.

run_the_race
Posts: 74
Joined: Wed Apr 14, 2021 5:47 pm

init_resize.sh : How to calculate ROOT_DEV_SIZE ?

Sun Nov 28, 2021 1:22 pm

I am trying to follow this unfortyunately locked thread: viewtopic.php?t=300187

How does one calculate ROOT_DEV_SIZE ?

From reading the init_resize.sh I think its specified in blocks (as opposed to the usual bits). When I try reverse calculate how people calculated it, I ways get none integer results, so I know I am incorrect. Say I have a 8GB SD card, what should I set ROOT_DEV_SIZE to use 6GB, and leave 2GB free (I wish to create a separate partition).

RonR
Posts: 3922
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: init_resize.sh : How to calculate ROOT_DEV_SIZE ?

Mon Nov 29, 2021 7:25 am

In init_resize.sh:

Code: Select all

  ROOT_DEV_SIZE=$(cat "/sys/block/${ROOT_DEV_NAME}/size")
  TARGET_END=$((ROOT_DEV_SIZE - 1))
ROOT_DEV_SIZE is the size of the device in sectors (512 bytes each).
TARGET_END is the last sector number of the device.

If you're trying to modify init_resize.sh so that it will leave 2 GB of free space at the end of the device, make the following change:

Code: Select all

  TARGET_END=$((ROOT_DEV_SIZE - 1 - ((2 * 1024 * 1024 * 1024) / 512)))

Return to “Beginners”