first-setup: Automatically expand root partition

- Show expansion option in the UI only if the partition expansion failed during
  first setup.

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2018-06-18 16:00:12 +05:30 committed by James Valleroy
parent db5a66c1d0
commit 3940868f21
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 12 additions and 14 deletions

View File

@ -27,7 +27,7 @@ from django.utils.translation import ugettext_lazy as _
from plinth import actions
from plinth.menu import main_menu
version = 1
version = 2
name = _('Storage')
@ -39,6 +39,8 @@ logger = logging.getLogger(__name__)
manual_page = 'Storage'
is_essential = True
def init():
"""Intialize the module."""
@ -164,3 +166,11 @@ def format_bytes(size):
size /= 1024**4
return _('{disk_size:.1f} TiB').format(disk_size=size)
def setup(helper, old_version=None):
"""Expand root parition on first setup."""
disks = get_disks()
root_device = get_root_device(disks)
if is_expandable(root_device):
expand_partition(root_device)

View File

@ -83,8 +83,8 @@
</tbody>
</table>
<h3>{% trans "Partition Expansion" %}</h3>
{% if expandable_root_size %}
<h3>{% trans "Partition Expansion" %}</h3>
<p>
{% blocktrans trimmed %}
There is {{ expandable_root_size }} of unallocated space
@ -98,18 +98,6 @@
role="button">
{% trans "Expand Root Partition" %}</a>
</p>
{% else %}
<p>
{% blocktrans trimmed %}
There is no unallocated space after your root partition.
There is no need to expand it.
{% endblocktrans %}
</p>
<p>
<a class="btn btn-primary btn-md disabled"
href="{% url 'storage:expand' %}" role="button">
{% trans "Expand Root Partition" %}</a>
</p>
{% endif %}
{% endblock %}