How to get a larger root partition on Touch
I'm trying to make Touch (14.10) work as an Ubuntu server. However the root partition is only 2 GB and is insufficient for the packages I need to install. Is there any way to get more space on the root partition?
Thus far I've tried:
resize2fs on /dev/loop0 won't work since the kernel doesn't support online resizing and I can't unmount root (ro doesn't cut it, even with -f).
Adding 2 GB to the end of /userdata/ubuntu.img works, but resize2fs on the file doesn't help.
This solution worked for me:
https://github.com/plasma-mobile/plasma-phone-dev-setup/blob/master/usr/bin/resize-root-partition
Basically, it's KDE Plasma Mobile's super-simple install script. Just run it, take a nap, and you should have a 6 GB root partition.
Here's the quickest way I've figured out to do it.
Warning: This may break your phone if typed incorrectly. Ensure you have full backups before beginning and are willing to make mistakes in case you lose all data on your phone. This example command resizes the root filesystem to 6GB, so if it's already bigger than that it will be truncated and your phone likely will become unbootable (until re-imaged). Only use this command if your root filesystem image is less than 6GB (the Ubuntu Touch default is 2GB).
$ sudo -s
# dd if=/dev/null of=/userdata/ubuntu.img bs=1M seek=6000 count=0
# resize2fs -f /userdata/ubuntu.img
# reboot
I had a similar problem, ultimately I decided to move my /usr
to /home/usr
(/home
is mounted from 14G file system, which gives me plenty of space for additional packages).
This is a little bit hackish way to do this, but it seems to work for me. The follwing code examples are using $
to indicate that command should be run as normal user and #
to indicate root user role (which can be gained either by sudo or loggig as root).
-
Set password for root user, you will need the ability to log as the root in case you screw anything up with your
/usr/bin/sudo
. To do so:$ sudo su # passwd
-
Copy contents of
/usr
preserving ownership and permissions:$ cd /usr $ sudo find . -depth -print0 | sudo cpio --null --sparse -pvd /home/usr/
-
The next logical step would be to use
fstab
to mount/home/usr
as/usr
on boot, however all changes that I tried to make to thefstab
were disappearing after rebooting Ubuntu. So I've created simple script to do the mounting, and saved it as/etc/init.d/bind.sh
:#!/bin/sh if [ "X$1" = "Xstart" ]; then echo "Binding /home/usr to /usr..." chmod 4755 /home/usr/bin/passwd /home/usr/bin/chsh /home/usr/bin/pkexec /home/usr/bin/sudo /home/usr/bin/newgrp /home/usr/bin/gpasswd /home/usr/bin/chfn /home/usr/lib/pt_chown /home/usr/lib/eject/dmcrypt-get-device /home/usr/lib/openssh/ssh-keysign /home/usr/lib/dbus-1.0/dbus-daemon-launch-helper /home/usr/lib/policykit-1/polkit-agent-helper-1 /home/usr/lib/arm-linux-gnueabihf/oxide-qt/chrome-sandbox /home/usr/lib/arm-linux-gnueabihf/lxc/lxc-user-nic mount -o bind,suid /home/usr /usr echo "...done" fi
The chmod line is needed, as I noticed that
suid bit
is sometimes missing after mounting. The list of the files that had thesuid bit
set on can be found by running# find /usr -user root -perm -4000
on the original/usr
directory. Please note, that if you install anything later on which is using thesuid bit
it may become broken unless you add it to the list.You will need to create symbolic link in
/etc/rcS.d
forbind.sh
:# ln -s /etc/init.d/bind.sh /etc/rcS.d/S36bind.sh
Note: you might want to pick different number than 36 depending on the state of your
/etc/rcS.d
.Alternatively you can edit
/lib/init/fstab
as described here to have persistent changes in fstab. -
After rebooting the system should be now using
/home/usr
as/usr
so hopefully you should have more space for additional packages. Note that old/usr
still exists but is unreachable as long as the new directory is mounted.In case anything goes wrong you can return to previous state by renaming the symbolic link in
/etc/rcS.d
and rebooting:# mv /etc/rcS.d/S36bind.sh /etc/rcS.d/K36bind.sh