# SCST Installation Guide for Ubuntu 24.04

This document provides step-by-step instructions for installing SCST (SCSI Target Subsystem for Linux) on Ubuntu 24.04.

## Overview

SCST is a generic SCSI target subsystem for Linux that allows a Linux system to act as a storage target for various protocols including iSCSI, Fibre Channel, and more. This installation guide covers building SCST from source.

## Prerequisites

- Ubuntu 24.04 LTS
- Root or sudo access
- Internet connection for downloading packages and source code

## Installation Steps

### 1. Check Kernel Version

First, verify your kernel version:

```bash
uname -r
```

Expected output: `6.8.0-90-generic` (or similar for Ubuntu 24.04)

### 2. Install Build Dependencies

Install the required packages for building SCST:

```bash
sudo apt update
sudo apt install -y build-essential linux-headers-$(uname -r) git \
    debhelper devscripts lintian quilt libelf-dev perl perl-modules-5.38
```

This installs:
- `build-essential`: GCC compiler and make
- `linux-headers`: Kernel headers for module compilation
- `git`: Version control for cloning SCST source
- `debhelper`, `devscripts`, `lintian`, `quilt`: Debian packaging tools
- `libelf-dev`: ELF library development files
- `perl` packages: Required for SCST build scripts

### 3. Clone SCST Source Code

Download the SCST source code from the official repository:

```bash
cd /tmp
git clone https://github.com/SCST-project/scst.git
cd scst
```

### 4. Build SCST Packages

Prepare the build and create Debian packages:

```bash
make 2release
make dpkg
```

The `make 2release` command prepares the source tree, and `make dpkg` builds the Debian packages. This process takes approximately 2-3 minutes.

Build output will be in `/tmp/scst/dpkg/` directory.

### 5. Verify Built Packages

Check that the packages were created successfully:

```bash
ls -lh /tmp/scst/dpkg/*.deb
```

Expected packages:
- `scst_*.deb` - Main SCST package (~11 MB)
- `iscsi-scst_*.deb` - iSCSI target implementation (~70 KB)
- `scstadmin_*.deb` - Administration tools (~46 KB)
- `scst-dev_*.deb` - Development headers (~63 KB)
- `scst-dkms_*.deb` - DKMS support (~994 KB)

### 6. Install SCST Packages

Install the core packages:

```bash
sudo dpkg -i /tmp/scst/dpkg/scst_*.deb \
    /tmp/scst/dpkg/iscsi-scst_*.deb \
    /tmp/scst/dpkg/scstadmin_*.deb
```

The installation will:
- Install SCST kernel modules to `/lib/modules/$(uname -r)/`
- Create systemd service file at `/usr/lib/systemd/system/scst.service`
- Enable the service to start on boot

### 7. Start SCST Service

Start the SCST service:

```bash
sudo systemctl start scst
```

Verify the service is running:

```bash
sudo systemctl status scst
```

Expected output should show:
```
● scst.service - SCST - A Generic SCSI Target Subsystem
     Loaded: loaded (/usr/lib/systemd/system/scst.service; enabled; preset: enabled)
     Active: active (exited) since ...
```

### 8. Load SCST Device Handler Modules

Load the required device handler modules:

```bash
sudo modprobe scst_vdisk
sudo modprobe scst_disk
sudo modprobe scst_cdrom
sudo modprobe iscsi_scst
```

Verify modules are loaded:

```bash
lsmod | grep scst
```

Expected output:
```
iscsi_scst            131072  0
scst_cdrom             12288  0
scst_disk              20480  0
scst_vdisk            143360  0
scst                 3698688  4 scst_cdrom,scst_disk,scst_vdisk,iscsi_scst
dlm                   327680  1 scst
```

### 9. Configure Automatic Module Loading

Create a configuration file to load SCST modules automatically on boot:

```bash
sudo bash -c 'cat > /etc/modules-load.d/scst.conf << EOF
scst
scst_vdisk
scst_disk
scst_cdrom
iscsi_scst
EOF'
```

### 10. Verify SCST Installation

Check that SCST is working by inspecting the sysfs interface:

```bash
ls /sys/kernel/scst_tgt/
```

Expected directories: `devices`, `handlers`, `targets`, etc.

List available handlers:

```bash
ls /sys/kernel/scst_tgt/handlers/
```

Expected handlers:
- `dev_cdrom` - CD-ROM pass-through
- `dev_disk` - Disk pass-through
- `dev_disk_perf` - Performance-optimized disk handler
- `vcdrom` - Virtual CD-ROM
- `vdisk_blockio` - Virtual disk with block I/O
- `vdisk_fileio` - Virtual disk with file I/O
- `vdisk_nullio` - Virtual disk with null I/O (testing)

## Post-Installation

### Check SCST Version

```bash
cat /sys/kernel/scst_tgt/version
```

### View SCST Configuration

```bash
sudo scstadmin -list
```

### Configure SCST Targets

SCST configuration is stored in `/etc/scst.conf`. You can create targets, LUNs, and access control using either:
- `scstadmin` command-line tool
- Direct sysfs manipulation
- Configuration file editing

Example configuration file location:
```bash
/etc/scst.conf
```

## Troubleshooting

### Module Loading Failures

If modules fail to load, check kernel logs:

```bash
sudo dmesg | grep scst
```

### Service Not Starting

Check service logs:

```bash
sudo journalctl -u scst -n 50
```

### Kernel Module Not Found

Ensure kernel headers match your running kernel:

```bash
uname -r
ls /lib/modules/$(uname -r)/
```

If they don't match, install the correct headers:

```bash
sudo apt install linux-headers-$(uname -r)
```

### Rebuilding After Kernel Update

After a kernel update, you'll need to rebuild and reinstall SCST:

```bash
cd /tmp/scst
make clean
make 2release
make dpkg
sudo dpkg -i /tmp/scst/dpkg/scst_*.deb \
    /tmp/scst/dpkg/iscsi-scst_*.deb \
    /tmp/scst/dpkg/scstadmin_*.deb
```

Alternatively, install `scst-dkms` package for automatic rebuilds:

```bash
sudo dpkg -i /tmp/scst/dpkg/scst-dkms_*.deb
```

## Uninstallation

To remove SCST:

```bash
sudo systemctl stop scst
sudo dpkg -r scstadmin iscsi-scst scst
sudo rm /etc/modules-load.d/scst.conf
```

## References

- SCST Project: https://github.com/SCST-project/scst
- SCST Documentation: http://scst.sourceforge.net/
- Ubuntu 24.04 Release Notes: https://wiki.ubuntu.com/NobleNumbat/ReleaseNotes

## Version Information

- Document Version: 1.0
- SCST Version: 3.10.0 (at time of writing)
- Ubuntu Version: 24.04 LTS (Noble Numbat)
- Kernel Version: 6.8.0-90-generic
- Last Updated: 2025-12-24
