
# mhvtl Installation and Configuration Guide for Ubuntu 24.04

## 1. Introduction

This guide provides step-by-step instructions for installing the mhvtl (Virtual Tape Library) from source on Ubuntu 24.04. The configuration files will be moved to a custom directory: `/opt/calypso/conf/mhvtl`.

**Disclaimer:** Installing `mhvtl` involves compiling a kernel module. This process is complex and can be risky. If your kernel is updated, you will need to recompile and reinstall the `mhvtl` kernel module. Proceed with caution and at your own risk.

## 2. Prerequisites

First, update your package lists and install the necessary build tools and libraries.

```bash
sudo apt-get update
sudo apt-get install -y git build-essential lsscsi sg3-utils zlib1g-dev liblzo2-dev linux-headers-$(uname -r)
```

## 3. Shell Environment

Ubuntu uses `dash` as the default shell, which can cause issues during the `mhvtl` compilation. Temporarily switch to `bash`.

```bash
sudo rm /bin/sh
sudo ln -s /bin/bash /bin/sh
```

## 4. Download and Compile

### 4.1. Download the Source Code

Clone the `mhvtl` repository from GitHub.

```bash
git clone https://github.com/markh794/mhvtl.git
cd mhvtl
```

### 4.2. Compile and Install the Kernel Module

```bash
cd kernel
make
sudo make install
sudo depmod -a
sudo modprobe mhvtl
```

### 4.3. Compile and Install User-Space Daemons

```bash
cd ..
make
sudo make install
```

## 5. Configuration

### 5.1. Create the Custom Configuration Directory

Create the new configuration directory and move the default configuration files.

```bash
sudo mkdir -p /opt/calypso/conf/mhvtl
sudo mv /etc/mhvtl/* /opt/calypso/conf/mhvtl/
sudo rm -rf /etc/mhvtl
```

### 5.2. Systemd Service Configuration

The `mhvtl` installation includes a systemd service file. We need to create an override file to tell the service to use the new configuration directory. The `mhvtl` service file typically uses an environment variable `VTL_CONFIG_PATH` to specify the configuration path.

```bash
sudo mkdir -p /etc/systemd/system/mhvtl.service.d
sudo bash -c 'cat > /etc/systemd/system/mhvtl.service.d/override.conf <<EOF
[Service]
Environment="VTL_CONFIG_PATH=/opt/calypso/conf/mhvtl"
EOF'
```

## 6. Starting and Verifying Services

Reload the systemd daemon, start the `mhvtl` services, and check their status.

```bash
sudo systemctl daemon-reload
sudo systemctl enable mhvtl.target
sudo systemctl start mhvtl.target
sudo systemctl status mhvtl.target
```

You can also use `lsscsi -g` to see if the virtual tape library is recognized.

## 7. Reverting Shell

After the installation is complete, you can revert the shell back to `dash`.

```bash
sudo dpkg-reconfigure dash
```

Select "No" when asked to use `dash` as the default shell.
