Disk Expansion for 3CX Instance

Before proceeding with the expansion of the disk, you must:
  1. Correctly terminate all OS instance processes.
  2. Shut down the instance
  3. Back up your data and settings. To do this, we suggest using the BaaS service.
  4. Delete the instance (in this case, our data disk will remain).
  5. Expand the disk via the web interface - SIM-Cloud control panel (go to the “Disks” section and select “Expand disk” in the pop-up desired disc menu).
  6. Re-create an instance from an already expanded disk.
  7. Perform disk expansion inside OS

Next, describe the process of expanding the disk inside the OS.

After we expanded the disk in the cloud resources control panel and logged in via Dashbord console or via ssh, we will see with the command “fdisk -l” that the volume of the disk /dev/vda is 17GB while the main the /dev/vda1 partition is the same size as 4 GB.

You need to expand this section.

Note

To access the instance via ssh, you can use the default access if the user did not change it after installation.

  • Login: root
  • Password: SIM-net123

Warning

We recommend that you always change the default (standard) access parameters. after installing the instance. Please change the access parameters!

Let’s start expanding. For this you need: - enter the command fdisk /dev/vda - then “p” as a result, we will see a list of all partitions and their size

As you can see, we have 3 system partitions, we need to expand the partition /dev/vda1, but since we have 2 other partitions behind it, then for extension we need to delete them first, without this we will not be able to perform the extension.

Removing these partitions will not affect the overall performance of the instance. Let’s remove sections from the end of the list: - To remove the /dev/vda5 partition, enter “d” followed by “5”. - To remove the /dev/vda2 partition, enter “d” followed by “2”. - enter “p” and we will see that we only have the 4GB partition /dev/vda1 we need.

root@3cx:~# fdisk /dev/vda

Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/vda: 17 GiB, 18253611008 bytes, 35651584 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2e71013e

Device     Boot   Start      End Sectors  Size Id Type
/dev/vda1  *       2048  8388607 8386560    4G 83 Linux
/dev/vda2       8390654 10483711 2093058 1022M  5 Extended
/dev/vda5       8390656 10483711 2093056 1022M 82 Linux swap / Solaris

Command (m for help): d
Partition number (1,2,5, default 5): 5

Partition 5 has been deleted.

Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Command (m for help): p
Disk /dev/vda: 17 GiB, 18253611008 bytes, 35651584 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2e71013e

Device     Boot Start     End Sectors Size Id Type
/dev/vda1  *     2048 8388607 8386560   4G 83 Linux

Now you can proceed directly to expanding it, for this it also you need to delete but don’t worry, all data will remain intact.

So, - enter “d” and then “1”. (we have deleted the vda1 partition and now we will create it again but with a larger size)

Command (m for help): d

Selected partition 1
Partition 1 has been deleted.

Command (m for help): p
Disk /dev/vda: 17 GiB, 18253611008 bytes, 35651584 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2e71013e
  • to do this, enter “n”, then “p”, then “1”, at the request of the initial sector, press “Enter”, the final sector - also “Enter”.
  • enter “p” and check that we should have a partition /dev/vda1, but the size of this partition should already be 17GB.
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-35651583, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-35651583, default 35651583):

Created a new partition 1 of type 'Linux' and of size 17 GiB.
Partition #1 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: y

The signature will be removed by a write command.

Command (m for help): p
Disk /dev/vda: 17 GiB, 18253611008 bytes, 35651584 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2e71013e

Device     Boot Start      End  Sectors Size Id Type
/dev/vda1        2048 35651583 35649536  17G 83 Linux
  • enter “w” - this will save all the changes we made earlier, if we enter
    “q” then we will exit the fdisk utility without saving all our operations.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

So, we expanded partition /dev/vda1 partition to 17GB, but if we enter the df -h command, we will see the following:

root@3cx:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            488M     0  488M   0% /dev
tmpfs           100M  1.7M   98M   2% /run
/dev/vda1       3.9G  1.7G  2.0G  46% /
tmpfs           499M   12K  499M   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           499M     0  499M   0% /sys/fs/cgroup
tmpfs           100M     0  100M   0% /run/user/0
root@3cx:~#

The partition is still 3.9G in size, this is due to the fact that in addition to the partition we still need to expand the file system.

Before expanding the file system, be sure to reboot the operating system.

After rebooting, enter the resize2fs /dev/vda1 command, wait for its execution and enter df -h.

root@3cx:~# resize2fs /dev/vda1
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 3
The filesystem on /dev/vda1 is now 4456192 (4k) blocks long.

We will see that now the /dev/vda1 partition is indeed 17G in size.

root@3cx:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            488M     0  488M   0% /dev
tmpfs           100M  3.0M   97M   3% /run
/dev/vda1        17G  1.7G 15.3G   6% /
tmpfs           499M   12K  499M   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           499M     0  499M   0% /sys/fs/cgroup
tmpfs           100M     0  100M   0% /run/user/0

This completes the expansion of the disk.