.. _Preparing Disks for Virtuozzo Storage:

Preparing Disks for Virtuozzo Storage
-------------------------------------

Each chunk server is a service that handles a single physical disk in the cluster. Although the disk should be used solely by the CS service, technically, you can use it for multiple purposes. E.g., create a small partition for the operating system and leave the rest of disk space for Virtuozzo Storage. If the disk is already partitioned, skip this section and proceed to creating a chunk server. Otherwise follow the instructions in this section to prepare the disk for use in Virtuozzo Storage.

New disks attached to and recognized by the Hardware Node need to be prepared for use in the Virtuozzo Storage cluster by means of the ``/usr/libexec/vstorage/prepare_vstorage_drive`` tool. The tool does the following:

1. Removes existing partitions from the disk.

2. Creates and formats the required partition(s).

After that, manually add the new partition to ``/etc/fstab`` and mount it.

.. note::

   1. If you do not need the disk to be bootable, run the tool with the ``--noboot`` option to skip GRUB bootloader installation.

   2. For SSD drives, use the ``--ssd`` option.

   3. To have the tool proceed without confirmation prompts, use the ``-y`` option.

.. _Preparing Disks for Use as Chunk Servers:

Preparing Disks for Use as Chunk Servers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1. To prepare an HDD or SSD for use as a chunk server, run the tool with the physical drive name as the option. For example:

   ::

       # /usr/libexec/vstorage/prepare_vstorage_drive /dev/sdb --noboot
       ALL data on /dev/sdb will be completely destroyed. Are you sure to continue? [y]
       y
       Zeroing out beginning and end of /dev/sdb...
       Partitioning /dev/sdb...
       Waiting for kernel...
       Formatting /dev/sdb1 partition...
       Done!

   .. note:: The tool does not accept partition name as the option.

2. Find out partition UUID:

   ::

       #  ls -al /dev/disk/by-uuid/ | grep sdb1
       lrwxrwxrwx 1 root root  10 Jun 19 02:41 f3fbcbb8-4224-4a6a-89ed-3c55bbc073e0 -> ../../sdb1

3. Add the new partition to ``/etc/fstab`` by UUID and specify the ``noatime`` and ``lazytime`` mount options. For example:

   ::
   
       UUID=f3fbcbb8-4224-4a6a-89ed-3c55bbc073e0 /vstorage/stor1-cs1    ext4 \
          defaults,noatime,lazytime   1 2
 
4. Mount the partition to ``/vstorage/<cluster>-cs<N>``, where <cluster> is cluster name and <N> is the first unused CS index number.

   .. note:: If ``/vstorage/<cluster>-cs<N>`` does not exist, create it.

.. _Preparing SSDs for Write Journaling or Caching:

Preparing SSDs for Write Journaling or Caching
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1. To prepare an SSD for write journaling or caching, run the tool with two options: ``--ssd`` and physical drive name. For example:

   ::

       # /usr/libexec/vstorage/prepare_vstorage_drive /dev/sdb --ssd
       ALL data on /dev/sdb will be completely destroyed. Are you sure to continue? [y]
       y
       Zeroing out beginning and end of /dev/sdb...
       Partitioning /dev/sdb...
       Waiting for kernel...
       Formatting /dev/sdb1 partition...
       Done!

   .. note:: The tool does not accept partition name as the option.

2. Find out partition UUID:

   ::

       #  ls -al /dev/disk/by-uuid/ | grep sdb1
       lrwxrwxrwx 1 root root  10 Jun 19 02:41 f3fbcbb8-4224-4a6a-89ed-3c55bbc073e0 -> ../../sdb1

3. Add the new partition to ``/etc/fstab`` by UUID and specify the ``noatime`` and ``lazytime`` mount options. For example:

   ::
   
       UUID=f3fbcbb8-4224-4a6a-89ed-3c55bbc073e0 /vstorage/stor1-ssd1   ext4 \
          defaults,noatime,lazytime   1 2

4. Mount the partition to ``/vstorage/<cluster>-ssd<N>``, where ``<cluster>`` is cluster name and ``<N>`` is the first unused SSD index number.

   .. note:: If ``/vstorage/<cluster>-ssd<N>`` does not exist, create it.
