Set partition sizes when flashing



  • FWIW, on the Nexus 5 I found it on /userdata/system.img
    I'm very tempted to up-size the image file and see if I can get a bigger root!



  • @unisuperbox assume someone has a device that currently installs into the partition. and assume they are sufficiently motivated and prepared to deal with the occasional footbullet. how would they go about installing their device with an image file?



  • @vandys I just did this on a M10 frieza an it worked like a charm.

    sudo -s
    dd if=/dev/null of=/userdata/ubuntu.img bs=1M seek=6000 count=0
    resize2fs -f /userdata/ubuntu.img                                            
    reboot
    

    How I understand it, it writes zero bytes in the image file after skipping 6GB. This leads to growth of the image file. Then resize2fs is used to grow the ext4 to the full extend of this file. The reboot is necessary to make the kernel aware about the changed filesystem.
    Now, the root partition is big enough for all the apt goodness:

    phablet@ubuntu-phablet:~$ ls -lash /userdata/ubuntu.img 
    2.6G -rw------- 2 root root 5.9G Oct 18 09:34 /userdata/ubuntu.img
    phablet@ubuntu-phablet:~$ df -h /
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/loop0      5.8G  2.3G  3.3G  41% /
    

    Warning: could have bad consequences for your phone. Execute the commands without much interruption - especially if your root partition is already mounted rw. You don't want to corrupt your filesystem.

    Have fun with it! 😉



  • @haveaniceday said in Set partition sizes when flashing:

    @vandys I just did this on a M10 frieza an it worked like a charm.

    "Fools rush in where angels fear to tread". Given your prompting, I did it too (ubuntu.img and
    system.img appear to be two links to the same underlying inode) and... success. I now have
    lots of room on my partition for any more packages. Very nice! So mark as a workable
    technique on Nexus 5, too. Many thanks.



  • @haveaniceday
    This worked for me too. Thanks for that.

    What I can't seem to figure out though, is where the extra space is being deducted from. I had expected that the free space on /userdata would be reduced, but that doesn't seem to be the case. But this space must be coming at the expence of something, shouldn't it?



  • I for one, as a user rather than a developer, think that the policy should be that things should be as un-footshootable as possible no matter how much rope that you might give us. 😉



  • @halucigenia not to worry. youll be able to sleep easy while youre staying away from commandline tools of which youre not sure what they do like ubports-qa 😉



  • @haveaniceday Fantastic, thank you very much for this. Another happy Nexus 5 user. After the first reboot, df -h / wasn't showing any change while the ls was. Ran the resize2fs -f /userdata/ubuntu.img again and rebooted a couple more times and finally succeeded. Just in case anyone else has similar issues when attempting this.


  • Banned

    This post is deleted!


  • Apologies to all for the mass call-outs used in this post -- I wouldn't usually do this. I've encountered a situation where extending rootfs and all subsequent customisations are lost. I'm sharing this as a warning for those who have already resized, a caveat for those considering to do so, and as a discussion point for how to move forwards.

    Switching the release channel loses the extended rootfs

    With hindsight, there's nothing surprising about this since the process of switching channels replaces /userdata/ubuntu.img.

    @haveaniceday above:

    Of course, this will probably break OTA updates...

    @UniSuperBox above:

    The image file can be resized, and I'm considering ways to make ubports-qa do this in case the user would prefer to use apt and turn off system-image upgrades.

    I never had any issues with OTA updates, even after some fairly extensive hacking and customisations. Other than switching the channel, what other system-image upgrades could lead to this outcome?

    Moving forward

    @haveaniceday above:

    I'll just repeat the steps for each release.

    Essentially, this is all that can be done. But I managed to do some decent testing and found that this reconfiguration process can be made much easier. In my case, I made promising progress with SaltStack configuration management. Solutions involving tools such as this become viable once rootfs has been extended (in that the necessary packages can be installed). It wouldn't be too difficult to have a repo for collecting formulas that help automate this.

    @vandys @arubislander @doniks Since you all appear to have gone through the resizing process, I hope you don't mind me drawing your attention to this post.



  • One strange experience to share about extending rootfs after switching the release channel. Following the instructions above, using 6000 worked fine for the rc channel. However, after switching to the dev channel, I couldn't get this to work for that value, no matter how many times I resized and rebooted. I did manage to get other sizes to work, though. Ultimately, I settled for 6144 (6 * 1024) to get 6.0GB, i.e.:

    dd if=/dev/null of=/userdata/ubuntu.img bs=1M seek=6144 count=0
    


  • Most system-image upgrades are differential, where only the changes from one image to the next are downloaded and applied. So, any updates in upstream Ubuntu as well as our own packages are changed. If you run sudo apt dist-upgrade, you will already have these newer packages and won't see any changes when the upgrade happens. This could be seen as a bug or a feature depending on who you are. It's a bug in that an image may not be in a known good state after an upgrade.

    Upgrades which download a whole system image will always rewrite all of your changes. Full updates will happen in the following scenarios:

    • You specify a full upgrade to system-image (There's a way to do this, but I'm not sure how at this time)
    • The system-image-server does not have a diff from the image you are using to the new image (you've skipped a few updates, for example I went from devel 2018-12-21 to 2018-12-28 today and had to download the full image)
    • You are switching release channels

    This is why I said that ubports-qa should disable system-image updates. After you've changed your system image, it is no longer in a known good state and may behave in unexpected ways.



  • @unisuperbox Fantastic, detailed explanation -- appreciate you taking the time to go through that.

    • The system-image-server does not have a diff from the image you are using to the new image (you've skipped a few updates, for example I went from devel 2018-12-21 to 2018-12-28 today and had to download the full image)

    This leaves me with some food for thought since it appears that I've increased my risk of this happening by switching to the dev channel.

    This is why I said that ubports-qa should disable system-image updates. After you've changed your system image, it is no longer in a known good state and may behave in unexpected ways.

    Is there a simple way of testing this out in the meantime?



  • I have been rad with the Nexus5 where rootfs is not constrained by a small physical partition size. I wish all devices could be converted to that layout.
    So far I enabled very easy resizing of rootfs via atuTools4UT: https://sourceforge.net/projects/all-things-ubuntu-library/files/releases/

    And the related portion in the sourcecode: https://sourceforge.net/p/all-things-ubuntu-library/code/HEAD/tree/trunk/ATUpackages/ATU/ATU-src/atulib.pas#l1329

    Currently working on a GUI for also resizing rootfs based on physical partition layout, ie. on Meizu PRO 5. Not sure if I will be able to do it on-device, but am still exploring this possibility, even using pivot chroot method.