{% extends "dashboard/base.html" %} {% load staticfiles %} {% load i18n %} {% block title-page %}{% trans "Resize how-to" %}{% endblock %} {% block content %}
{% blocktrans %} If you don't have enogh space on your virtual machine you can ask for more. After a request has been made an administrator can extend your HDD. If the request is granted you have to manually rescan and extend a logical volume on your machine to acquire the extra space. To do so you need root access/administrator rights. {% endblocktrans %}
df -h
command.
As you can see below we need more space on
/ so we will extend
/dev/mapper/cloud–x–vg-root.
{% endblocktrans %}
Filesystem | Size | Used | Avail | Use% | Mounted on |
---|---|---|---|---|---|
/dev/mapper/cloud–x–vg-root | 39G | 37G | 65M | 100% | / |
none | 4.0K | 0 | 4.0K | 0% | /sys/fs/cgroup |
udev | 487M | 4.0K | 487M | 1% | /dev |
tmpfs | 100M | 368K | 100M | 1% | /run |
none | 5.0M | 0 | 5.0M | 0% | /run/lock |
none | 498M | 0 | 498M | 0% | /run/shm |
none | 100M | 0 | 100M | 0% | /run/user |
/dev/vda1 | 236M | 37M | 187M | 17% | /boot |
lvdisplay
{% endblocktrans %}
— Logical volume — LV Path /dev/cloud-x-vg/root LV Name root VG Name cloud-x-vg LV UUID xlGizo-eVyj-aqRn-Us7d-BRzj-dsKW-U6kp0F LV Write Access read/write LV Creation host, time cloud-x, 2014-07-31 13:17:53 +0200 LV Status available#
open 1 LV Size 38.76 GiB Current LE 9923 Segments 2 Allocation inherit Read ahead sectors auto-
currently set to 256 Block device 252:0
pvdisplay
{% endblocktrans %}
— Physical volume — PV Name /dev/vda5 VG Name cloud-x-vg PV Size 39.76 GiB / not usable 2.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 10178 Free PE 0 Allocated PE 10178 PV UUID JDp5TP-PHjT-Cgwk-MN4h-iAnk-9dfT-lYoldd
fdisk /dev/vda
and press p.
This will show something similar:
{% endblocktrans %}
Device | Boot | Start | End | Blocks | Id | System |
---|---|---|---|---|---|---|
/dev/vda1 | * | 2048 | 499711 | 248832 | 83 | Linux |
/dev/vda2 | 501758 | 83884031 | 41691137 | 5 | Extended | |
/dev/vda5 | 501760 | 83884031 | 41691136 | 8e | Linux LVM |
{% blocktrans %} As you can see, the /dev/vda5 is in the /dev/vda2 Extended partition. To resize it we have to recreate the Extended partition. {% endblocktrans %}
{% trans "Delete the Extended partition:" %}
{% blocktrans %} Press d and the number of the partition. In the example above the extended partition name is vda2 so press 2. {% endblocktrans %}
{% trans "Create extended partition:" %}
{% blocktrans %} Press n to create new partition. Type e to choose extended type. Set partition number - the same as you deleted above: 2. You can use the default starting and ending sector. {% endblocktrans %}
{% trans "Create logical partition:" %}
{% blocktrans %} Press n to create new partition. Type l to choose logical type. Set partition number - the same as the Linux LVM (vda5) has above: 5. You can use the default starting and ending sector. {% endblocktrans %}
{% trans "Change the logical partition’s type:" %}
{% blocktrans %} Press t to change type. Set the logical partition’s number: 5 (vda5). Type 8e to choose Linux LVM type. (to show the full list, press L). {% endblocktrans %}
{% trans "Save and exit: Press w." %}
{% trans "If you list the partitions again, you will see the difference:" %}
Device | Boot | Start | End | Blocks | Id | System |
---|---|---|---|---|---|---|
/dev/vda1 | * | 2048 | 499711 | 248832 | 83 | Linux |
/dev/vda2 | 499712 | 89338673 | 44419481 | 5 | Extended | |
/dev/vda5 | 501760 | 89338673 | 44418457 | 8e | Linux LVM |
{% trans "Reread partition table:" %}
partprobe -s /dev/vda
/dev/vda: msdos partitions 1 2 <5>
{% trans "Resize logical partition:" %}
pvresize /dev/vda5
Physical volume “/dev/vda5” changed 1 physical volume(s) resized / 0 physical volume(s) not resized
{% trans "Check Free PE / Size:" %}
vgdisplay
... Free PE / Size 666 / 2.60 GiB ...
{% trans "Extend LVM:" %}
lvextend -L
+2.6G
/dev/mapper/cloud--x--vg-root
Rounding size to boundary between physical extents: 2.60 GiB Extending logical volume root to 41.36 GiB Logical volume root successfully resized
{% trans "Finally, resize filesystem:" %}
resize2fs /dev/mapper/cloud--x--vg-root
resize2fs 1.42.9 (4-Feb-2014) Filesystem at /dev/mapper/cloud–x–vg-root is mounted on /; on-line resizing required old_desc_blocks = 3, new_desc_blocks = 3 The filesystem on /dev/mapper/cloud–x–vg-root is now 10843136 blocks long.
{% blocktrans %}
The df -h
will show now some free space on your /:
{% endblocktrans %}
Filesystem | Size | Used | Avail | Use% | Mounted on |
---|---|---|---|---|---|
/dev/mapper/cloud–x–vg-root | 41G | 37G | 2.6G | 94% | / |
none | 4.0K | 0 | 4.0K | 0% | /sys/fs/cgroup |
udev | 487M | 4.0K | 487M | 1% | /dev |
tmpfs | 100M | 368K | 100M | 1% | /run |
none | 5.0M | 0 | 5.0M | 0% | /run/lock |
none | 498M | 0 | 498M | 0% | /run/shm |
none | 100M | 0 | 100M | 0% | /run/user |
/dev/vda1 | 236M | 37M | 187M | 17% | /boot |
{% blocktrans %} If we don’t have enogh space on our virtual machine, we can ask more. After the request, the administrator will extend your HDD, but you have to rescan and extend it manually on your machine. {% endblocktrans %}
disk management
.
Click the Create and format hard disk partitions
{% endblocktrans %}
Rescan Disks
on the Action
menu.
{% endblocktrans %}
Extend Volume
." %}
{% trans "You can also create a new partition from the unallocated space." %}