Set partition sizes when flashing



  • Dear community,

    the problem of the root partition (and other ones) being too small to install any software via apt is quite known. One can bind mount and use symlinks to counteract, but it would be much easier and presumably more stable to just install an image with adequate partition sizes.

    Do you know of a solution like setting the partition sizes when flashing a new image?

    Of course, this will probably break OTA updates, but that's okay. I'll just repeat the steps for each release.

    Kind regards and have a nice day ☺



  • I don't know the answers to your exact questions, but a related thought:

    On some devices the root filesystem is not written to the "system" partition, but to a "system.img" file on the "data" partition. My Nexus 7 is like this. That way it is quite easy to increase the space with resize2fs in recovery.

    I don't see a reason why an image file couldn't be used on other devices and I don't know how it is determined whether to use an image file or a partition, but I think this could be a route towards more space.


  • Community

    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. Of course we wouldn't be able to help people if they broke things in this state, but we can give them just enough rope to shoot themselves in the foot...



  • @unisuperbox are all devices equally footshootable? what I mean is, do we always install into an image or on some devices it goes into a partition?


  • Community

    No, actually...

    The devices which Canonical shipped have Ubuntu Touch installed on their /system partition. It is generally unsafe to resize this partition because Android devices are weird... More akin to a doomsday than stepping on a Lego

    The others (the Nexus 5, Oneplus One, and Fairphone 2) are installed to an image file which resides on /data/.



  • 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!


Looks like your connection to UBports Forum was lost, please wait while we try to reconnect.