Changing partition on Ubuntu 17.10

Date: January 21, 2018

  1. Description of the problem.

    It is quite a popular tool to launch Ubuntu on virtual machine in order to test some features or new tools. I personally use VirtualBox for it and Ubuntu 17.10 x64 distribution.

    Ubuntu Create VM

    But, that’s a common mistake to make a small drive partition (like 15-20 GB). And, after a while, when you have a plenty of software installed there, you get a message “Low Disk Space”

    Ubuntu Low Disk Space

    So, the typical step is to shut down virtual machine and change the virtual disk size via Virtual Media Manager.

    Ubuntu Virtual Media Manager

    But it doesn’t help on Ubuntu start, it freezes with a black screen. And on the screen you can see the line “Started User Manager for UID 121”, which means that Ubuntu can’t load the graphic interface.

    Ubuntu launch error

  2. Fixing the problem.

    Firstly, you need to press “ESC” on Virtual Machine start (which will take you to Ubuntu book menu), and load Ubuntu in recovery mode.

    Ubuntu Recovery Menu

    The tool dpkg will show exactly, if the problem is a lack of free place and how much free space operating system needs just to load GUI.

    Ubuntu dpkg

    Further steps are briefly described here. So, your Ubuntu can fix this problem by its own means, no LiveCD required. Just use the tool root from Recovery Menu list, and paste following commands there:

    sudo fdisk /dev/sda – to run necessary tool;

    p – to view listed partitions;

    d – to delete dev/sda1;

    n – to create a new one with partition type p and without removing the signature;

    Ubuntu fdisk n

    a – to make partition bootable;

    w – to write changes.

    Ubuntu fdisk w

    After that command I additionally ran sudo mount -o remount, rw / because my hard drive was mounted in read-only mode, and sudo partprobe – cause simple reboot, as it was adviced on Stackoverflow, didn’t take an effect.

    sudo reboot;

    sudo mount -o remount, rw / and sudo resize2fs /dev/sda1 – to make the filesystem to take all available space on the partition.

    Ubuntu resize2fs

    After these steps Ubuntu loads successfully.

    Ubuntu start screen