This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prevent root partion expanding
#1
Hi, 
does anybody know how to STOP the root partition expanding automatically to fill the SD card on the first boot? 
Using Debian 2.0.8.
(In Rasbian, you need to modify /boot/cmdline.txt. No such file here)
Reply
#2
Yes and no.
One option would take to partition the empty area left after the image is copied. I use to make an additional partition for /home. My data are independent from the OS installed. So the free area is limited according what one want to add later.

Another option is to edit /usr/bin/tinker-config at line 339 and try to fake the function do_expand_rootfs().
So you may rename it and put
Code:
do_expand_rootfs() {
  return 0
}
instead.
Or to comment from line 340 to line 412 (included).
Doing so the function is null, so for further tinker-config use it might take to recover the original file.
Additionally it might need some extra scripting that it will avoid to execute the /etc/init.d/resize2fs_once.
But this attempt it might cause the impossibility to boot the system, due the fact that a marginal space is needed by the system to put temporary files. So the condition fall into the first option, which takes one to set the rootfs partition prior to boot the system the first time.

Last, the TinkerOS (aka linaro) doesn't use the boot.scr to start the system, so that option for RPi has no place to go.
Light blue words might be a link. Have you try to click on them? Big Grin
Reply
#3
Thanks for the answer!

I guess tinker-config is only used if you actually use it on purpose, do I did not modify this script.
Also, I could not find etc/init.d/resize2fs_once

I did find resize-helper.service in /etc/systemd/system/basic.target.wants and /lib/systemd/system

however deleting these files resulted in the system not booting.

So I tried commenting out the contents of the script they point to: /usr/sbin/resize-helper which also resulted in boot failure.

In the end, I changed the line of the above script 

from
${PARTED} ${DEVICE} resizepart ${PART_ENTRY_NUMBER} 100%
to
${PARTED} ${DEVICE} resizepart ${PART_ENTRY_NUMBER} 40%

Now I have partition size of about 6GB of my 16GB SD-Card, which is great for my purpose, so I will leave it at that.

I am guessing that the original image  of 3GB is either too small to actually run, or something else in the /usr/sbin/resize-helper script is necessary for initialisation. BTW, after the first boot, the systemd entries disappear, so all this only happens on the first boot.

To modify /usr/sbin/resize-helper, I just mounted the SD card on another linux machine and edited the file, before inserting it into the tinkerboard for the first time.
Reply
#4
(01-06-2019, 09:10 PM)mrwinter Wrote: I guess tinker-config is only used if you actually use it on purpose, do I did not modify this script.
Also, I could not find etc/init.d/resize2fs_once
Indeed resize2fs_once is embedded in the thinker-config and written on-the-fly to use once. It will probably disappear after has ran.

But you shed a light that there's a systemd service that is kicking in for that.
For myself curiosity, I investigated what is done for this matter.
So to disable resizing it might be the simplest way to modify the link /etc/systemd/system/basic.target.wants/resize-helper.service , just after the image has cloned to the memory, prior boot. It takes to change the simlink to /dev/null, which will inhibit any further action. It might be done by this:
  1. mount the partition (it should be the second inside the media)
  2. look for the mentioned file
  3. By a GUI tools it would be simple to check the properties and find the simlink
  4. Change the simlink as above stated
  5. CLI option
Code:
$ sudo mount /dev/sdXY /mnt       ## X and Y will be for the partition
$ sudo rm /mnt/etc/systemd/system/basic.target.wants/resize-helper.service
$ sudo ln -s /dev/null /mnt/etc/systemd/system/basic.target.wants/resize-helper.service

Another dirty way it would fake the executable /usr/bin/resize-helper with a shell script which would be empty or even better if it will resize for a wanted amount of space, which is pretty necessary.

But this is pretty a linux job, since there are difficulties doing with a different OS, because the file system is most suited within linux OSes.
Light blue words might be a link. Have you try to click on them? Big Grin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)