.. _drive_control:

Drive control
-------------

.. index:: drives;drives list
.. index:: drives;drives add
.. index:: drives;drives reassign
.. index:: drives;drives offset
.. index:: drives;drives reassign
.. index:: drives;drives create_volume
.. index:: drives;drives remove_logical
.. index:: drives;drives remove_volume


.. _19.2.1|VOSS-497:


In order to reduce the risk of *disk full* errors, the platform divides the
file system over several disks keeping areas liable to grow outside the main
root filesystem. The areas with the highest growth such as logs and database
storage are kept on their own private file systems.

.. note::
   The database mount point is stored in a logical volume.

These disk mounts can be migrated onto new, larger disks and some other locations can
optionally be moved onto their own disks. This is managed through the **drives**
command.

The current mounted filesystems and mount points can be displayed using **drives list mounted**
and **drives list mountpoints** respectively.

A screen showing drives list mounted and mountpoints::

   platform@VOSS:~$ drives list
   Used disks and mountpoints:
       sde1 -  insights-voss-sync:database
       dm-0 -  mongodb:dbroot
       sdc1 -  services:SWAPSPACE
       sdd1 -  services:backups
   
   Unused disks:
   sdf
   
   Unused mountpoints:
   
   Volume Groups
       voss - 25 GB free, 252 GB total
         Physical volumes:
           sdg1
         Logical volumes:
           dbroot/dm-0 - 227 GB


The mount points are as follows:

* ``insights-voss-sync:database`` is the volume used for the insights database storage
* ``mongodb:dbroot`` is the volume used for database storage
* ``services:backups`` is used for default backup storage
* ``services:SWAPSPACE`` is the swap volume used by the system

.. note::

   While the system is carrying out a backup, additional `Unused disks`,
   for example ``dm-1``, ``dm-2``, may show when the **drives list** command
   is run. These disks are used for snapshots and will not display once 
   the backup is completed.

In order to add or extend an existing disk volume, follow the following steps:

* Under VMware, add an additional disk volume to the VM
* **drives list** displays any unused available volumes
* A free mount point can be linked to a new disk using **drives add <disk> <mountpoint>**.

  .. note::

     The **drive add** command on a Generic NBI node (for Billing Data Extract)
     is not in use.

* An existing used mountpoint (i.e. currently linked to a disk volume) can be linked to a new disk
  volume of greater size using **drives reassign <disk> <mountpoint> <new disk size in GB>**. 

  The `<new disk size in GB>` specification means the volume need not be the size
  of the entire disk. However, a specified size must *not* be more than 90%
  of the disk size (or more than <disk size less 10GB> if the disk size is 100GB or smaller).

  Existing data on the current disk will be copied to the new disk volume, and once successful,
  the new disk volume will be linked.

For example, the following steps can be followed to add a 250GB hard disk to the system:

1. Log into the VMware console and select Server.
#. Right-click and select Edit settings.
#. Click **Add...** and select Hard Disk.
#. Step through the rest of the wizard and edit parameters - in this case 250GB, thick provisioned.
#. Once done, log into system as the platform user.
#. Carry out a disk listing with the command **drives list**.
#. Reassign the disks with the command:

   * For the *database mount point* (`mongodb:dbroot`), a Volume Group must be reassigned:

     a. **drives create_volume <volume_name> <new disk name>**.
     #. Carry out a disk listing to check the Volume Group with the command **drives list**.
     #. **drives reassign <volume_name> mongodb:dbroot <size in GB>**.
        The `<size in GB>` specification means the volume need not be the size
        of the entire disk. However, a specified size must *not* be more than 90%
        of the disk size (or more than <disk size less 10GB> if the disk size is 100GB or smaller).
     #. Old volumes can be removed with:
       
        * **drives remove_logical <volume_name> <logical_volume_name>**
        * **drives remove_volume <volume_name>**
   * For *other mount points*, a disk must be reassigned:  **drives reassign <disk> <mountpoint>**
#. Start the application with **app start**.
#. Verify the new reassignment with the command **drives list**.

.. note::

   Volume Groups for database mount points reserve a 10% or 10GB space - 
   whichever is the largest - which is used for and then released during database backups.

SAN alignment is implemented using the offset value in **drives offset**.  This value can be changed if
necessary; however the default should be sufficient for most SAN hardware.




Example output
'''''''''''''''

The example below shows reassigining ``insights-voss-sync:database``
to a new, resized drive ``sdh``:

::

   platform@VOSS:~$ drives reassign sdh insights-voss-sync:database
   You are about to stop services. Do you wish to continue? y
   da67c964-c46c-473f-98cd-169a7cfd02f7
   Application insights-voss-sync processes stopped.
   Migrating data to new drive - this can take several minutes
   Data migration complete - reassigning drive
   Checking that /dev/sdh1 is mounted
   Checking that /dev/dm-0 is mounted
   /opt/platform/apps/mongodb/dbroot
   Checking that /dev/sdc1 is swapspace
   Checking that /dev/sdd1 is mounted
   /backups
   
   Application services:firewall processes stopped.
   Reconfiguring applications...
   Application insights-voss-sync processes started.
   platform@VOSS:~$

