# Virtual Data Optimizer (VDO)

In this section, you can find information on how to enable deduplication using basically any block storage available. We assume that you have prepared your storage provider and have exposed the block device to the system where Storware Backup & Recovery Node is installed.

## Preparation

{% hint style="info" %}
Disable Secure Boot option for the VM to allow VDO work properly. Run below command to check status of Secure Boot option:

```
mokutil --sb-state
```

{% endhint %}

1. Log in to Storware Backup & Recovery Node and create a mount directory as in the example `/backupdestination`

   ```
   mkdir /backupdestination
   ```
2. List all existing disks, and find your drive. Let's assume `/dev/sdc` is your empty block device that you want to use:

   ```
   [root@vProtect01 ~]# fdisk -l | grep dev
   Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectors
   /dev/sda1   *        2048     1026047      512000   83  Linux
   /dev/sda2         1026048    62914559    30944256   8e  Linux LVM
   Disk /dev/sdc: 500 GB, 17179869184 bytes, 33554432 sectors
   Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
   Disk /dev/mapper/centos-root: 28.5 GB, 28462546944 bytes, 55590912 sectors
   Disk /dev/mapper/centos-swap: 3221 MB, 3221225472 bytes, 6291456 sectors
   ```
3. Log in to the vProtect web UI.
4. Go to **Backup Destinations.**
5. Click on **Create Backup Destination**, choose a **File system.**
6. Type the name for the new backup destination, set the retention, and select at least one node configuration.
7. Based on whether the staging space is same as backup destination or not, do one of the following:
   * If the **staging space is different than your backup destination** storage:
     * In **Storage paths** type `/backupdestination` - this path will be used to mount the prepared file system (XFS) on top of the VDO volume.
     * Check **Enable deduplication.**
     * Provide your block device (for example `/dev/sdc`) as your Deduplication device.
   * If the **staging space needs to be the same as your backup destination** storage:
     * In **Storage paths** type `/vprotect_data/backups` - this path assumes that `/vprotect_data` is your staging space path and `backups` is a subdirectory of the staging space.
     * Check **Enable deduplication.**
     * Provide your block device (for example `/dev/sdc`) as your **Deduplication device.**
     * Enable **Mount deduplicated file system to a different directory than backup destination path** and provide the mount point - your staging space path, for example `/vprotect_data` - this will force Storware Backup & Recovery to mount XFS on top of VDO in the staging space directory rather than in the backup subdirectory.

![](https://content.gitbook.com/content/pLZqcHnyZSrAssyuc8UU/blobs/mkA3fqBSRaUTWHpbcqy5/deployment-backup_destinations-file_system-file_system-vdo.png)

{% hint style="info" %}
**Note**: Only one file system backup destination with deduplication using VDO pointing to a specific directory can be used. If you want to add another backup destination using the same VDO device, but just a different subdirectory, create it without deduplication enabled.
{% endhint %}

## Importing existing VDO volumes to LVM

The python-based VDO management software has been deprecated and removed from RHEL 9/CentOS 9 Stream. It has been replaced by the LVM-VDO integration. If you are using VDO on RHEL 8/CentOS 8 Stream and plan to upgrade to version 9, you need to convert VDO volume.

In this example we have VDO volume called VDOexample created and managed by Storware Backup & Recovery.

```
[root@sbr-node ~]# lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda            8:0    0   40G  0 disk 
|-sda1         8:1    0  600M  0 part /boot/efi
|-sda2         8:2    0    1G  0 part /boot
`-sda3         8:3    0 38.4G  0 part 
  |-cs-root  253:0    0 34.4G  0 lvm  /
  `-cs-swap  253:1    0    4G  0 lvm  [SWAP]
sdb            8:16   0  100G  0 disk 
`-VDOexample 253:2    0  300G  0 vdo  /backups
sr0           11:0    1 1024M  0 rom  
```

1. On Storware Backup & Recovery Node, stop vprotect-node service.

   ```
   [root@sbr-node ~]# systemctl stop vprotect-node
   ```
2. Unmount VDO volume from backup destination path.

   ```
   [root@sbr-node ~]# umount /backups
   ```
3. Convert VDO volume. Change `/dev/sdb` to the device on which you have created VDO.

   ```
   [root@sbr-node ~]# lvm_import_vdo /dev/sdb
   Convert VDO device "/dev/sdb" to VDO LV "vdovg/vdolvol"? [y|N]: Yes
   Stopping VDO VDOexample
   Converting VDO VDOexample
       Opening /dev/sdb exclusively
       Loading the VDO superblock and volume geometry
       Checking the VDO state
       Converting the UDS index
       Converting the VDO
       Conversion completed for '/dev/sdb': VDO is now offset by 2097152 bytes
   Physical volume "/dev/sdb" successfully created.
   Volume group "vdovg" successfully created
   WARNING: Logical volume vdovg/vdolvol_vpool not zeroed.
   Logical volume "vdolvol_vpool" created.
   WARNING: Converting logical volume vdovg/vdolvol_vpool to VDO pool volume WITHOUT formating.
   WARNING: Using invalid VDO pool data MAY DESTROY YOUR DATA!
   Logical volume "vdolvol" created.
   Converted vdovg/vdolvol_vpool to VDO pool volume and created virtual vdovg/vdolvol VDO volume.
   ```
4. Rename volume group and logical volume names. They must be the same as the original VDO volume name.

   ```
   [root@sbr-node ~]# vgrename vdovg VDOexample
   Volume group "vdovg" successfully renamed to "VDOexample"
   [root@sbr-node ~]# lvrename /dev/VDOexample/vdolvol /dev/VDOexample/VDOexample
   Renamed "vdolvol" to "VDOexample" in volume group "VDOexample"
   ```
5. Edit /etc/yum.repos.d/vProtect.repo and change `baseurl` to point to `el9`.

   ```
   [root@sbr-node ~]# vim /etc/yum.repos.d/vProtect.repo

   [vProtect]
   baseurl = http://repo.storware.eu/storware/current/el9
   gpgcheck = 0
   name = vProtect repo
   ```
6. On Storware Backup & Recovery Server machine, create a vprotect database backup and copy it to safe place. Wait for all tasks to finish before stopping the vprotect-server service.

   ```
   [root@sbr-server ~]# stop systemctl vprotect-server
   [root@sbr-server ~]# /opt/vprotect/scripts/backup_db.sh
   [root@sbr-server ~]# cp /tmp/vprotect_db.sql.gz /root
   ```
7. Login to mysql and execute below SQL query.

   ```
   [root@sbr-node ~]# mysql -uroot -p vprotect

   update filesystembackupdestination
   inner join backupdestination on filesystembackupdestination.guid = backupdestination.guid
   set filesystembackupdestination.dedupvolume = CONCAT('/dev/', REGEXP_REPLACE(backupdestination.name,'\\W','_'), '/', REGEXP_REPLACE(backupdestination.name,'\\W','_'))
   where filesystembackupdestination.dedupvolume is not null;

   MariaDB [vprotect]> quit
   ```
8. Start vprotect-server service.

   ```
   [root@sbr-server ~]# systemctl start vprotect-server
   ```
9. Proceed with the system upgrade of the Storware Backup & Recovery Node machine. After the reboot, you should have new LVM-VDO mounted on your backupdestination directory.

   ```
   [root@sbr-node ~]# lsblk
   NAME                               MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
   sda                                  8:0    0   40G  0 disk 
   ├─sda1                               8:1    0  600M  0 part /boot/efi
   ├─sda2                               8:2    0    1G  0 part /boot
   └─sda3                               8:3    0 38.4G  0 part 
   ├─cs-root                        253:0    0 34.4G  0 lvm  /
   └─cs-swap                        253:1    0    4G  0 lvm  [SWAP]
   sdb                                  8:16   0  100G  0 disk 
   └─VDOexample-vdolvol_vpool_vdata   253:2    0  100G  0 lvm  
   └─VDOexample-vdolvol_vpool-vpool 253:3    0  300G  0 lvm  
       └─VDOexample-VDOexample        253:4    0  300G  0 lvm  /backups
   ```
