#!/bin/bash # Fix MHVTL configuration to properly map drives to library # Problem: Drive IDs must follow convention: Library_ID + Slot_Number # For Library 10, drives should be 11, 12, 13, 14 (not 00, 01, 02, 03) echo "Fixing MHVTL configuration..." # Stop mhvtl service first echo "Stopping mhvtl service..." systemctl stop mhvtl # Wait for processes to stop sleep 2 # Backup current configuration cp /etc/mhvtl/device.conf /etc/mhvtl/device.conf.backup-$(date +%Y%m%d-%H%M%S) cp /etc/mhvtl/library_contents.10 /etc/mhvtl/library_contents.10.backup-$(date +%Y%m%d-%H%M%S) # Fix device.conf: Change Drive IDs from 00,01,02,03 to 11,12,13,14 echo "Updating device.conf..." sed -i 's/^Drive: 00 /Drive: 11 /' /etc/mhvtl/device.conf sed -i 's/^Drive: 01 /Drive: 12 /' /etc/mhvtl/device.conf sed -i 's/^Drive: 02 /Drive: 13 /' /etc/mhvtl/device.conf sed -i 's/^Drive: 03 /Drive: 14 /' /etc/mhvtl/device.conf # Fix library_contents.10: Map drive slots to correct drive IDs echo "Updating library_contents.10..." sed -i 's/^Drive 1: 00$/Drive 1: 11/' /etc/mhvtl/library_contents.10 sed -i 's/^Drive 2: 01$/Drive 2: 12/' /etc/mhvtl/library_contents.10 sed -i 's/^Drive 3: 02$/Drive 3: 13/' /etc/mhvtl/library_contents.10 sed -i 's/^Drive 4: 03$/Drive 4: 14/' /etc/mhvtl/library_contents.10 # Remove old lock files rm -f /var/lock/mhvtl/mhvtl* 2>/dev/null || true # Verify changes echo "" echo "=== Updated device.conf ===" grep -E "^(Library|Drive):" /etc/mhvtl/device.conf echo "" echo "=== Updated library_contents.10 ===" head -10 /etc/mhvtl/library_contents.10 echo "" # Start mhvtl service echo "Starting mhvtl service..." systemctl start mhvtl # Wait for devices to initialize sleep 3 # Check status echo "" echo "=== MHVTL Service Status ===" systemctl status mhvtl --no-pager -l echo "" echo "=== Running Processes ===" ps aux | grep -E "(vtltape|vtllibrary)" | grep -v grep echo "" echo "=== SCSI Devices ===" lsscsi -g echo "" echo "Fix completed!"