1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#!/bin/bash
# License: GPL
# Author: Steven Shiau <steven _at_ clonezilla org>
# Description: Program to show the kernel messages about removable disks
# //NOTE// This program is used to work with screen.
DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
. /etc/drbl/drbl-ocs.conf
. $DRBL_SCRIPT_PATH/sbin/ocs-functions
# Load the config in ocs-live.conf. This is specially for Clonezilla live.
# It will overwrite some settings of /etc/drbl/drbl-ocs.conf, such as $DIA...
[ -e "/etc/ocs/ocs-live.conf" ] && . /etc/ocs/ocs-live.conf
# Settings
ask_and_load_lang_set
#
now="$(LC_ALL=C date +%Y/%m/%d" "%T)"
echo "$now"
[ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
echo -e "$msg_insert_storage_dev_now"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
echo "Scanning devices... Available disk(s) on this machine:"
# Show it like:
# NAME TYPE SIZE MODEL SERIAL ID_PATH
# nvme0n1 disk 64G VMware Virtual NVME_0000 pci-0000:0b:00.0-nvme-1
# nvme0n2 disk 35G VMware Virtual NVME_0000 pci-0000:0b:00.0-nvme-2
# nvme0n3 disk 10G VMware Virtual NVME_0000 pci-0000:0b:00.0-nvme-8
# nvme0n4 disk 25G VMware Virtual NVME_0000 pci-0000:0b:00.0-nvme-10
# nvme0n5 disk 36G VMware Virtual NVME_0000 pci-0000:0b:00.0-nvme-11
# nvme0n6 disk 15G VMware Virtual NVME_0000 pci-0000:0b:00.0-nvme-13
# sda disk 64G VMware Virtual 000000000000000 pci-0000:02:04.0-ata-1.0
# sdb disk 500G VMware Virtual 020000000000000 pci-0000:02:04.0-ata-3.0
# sdc disk 30G VMware Virtual 030000000000000 pci-0000:02:04.0-ata-4.0
# sdd disk 32G VMware Virtual 040000000000000 pci-0000:02:04.0-ata-5.0
# sde disk 32G Virtual Storage 1C5DB6ECC282435 pci-0000:02:03.0-usb-0:1:1.0-scsi-0:0:0:0
echo "==================================="
lsblk_output="$(LC_ALL=C lsblk -d -o name,type,size,model,serial -e 1,7,11 -x name -n)"
# Print header with ID_PATH added
printf "%-8s %-5s %-5s %-15s %-15s %s\n" "NAME" "TYPE" "SIZE" "MODEL" "SERIAL" "ID_PATH"
# Process each device from lsblk output
echo "$lsblk_output" | while IFS= read -r line; do
# Extract the device name (first column)
name="$(echo "$line" | awk '{print $1}')"
# Get the full device path (e.g., /dev/sda)
device="/dev/$name"
# Query udevadm for ID_PATH
id_path=$(udevadm info --query=property --name="$device" | grep '^ID_PATH=' | cut -d'=' -f2)
# If ID_PATH is empty, set it to "N/A"
id_path="${id_path:-N/A}"
# Extract all columns from the line for printf
type="$(echo "$line" | awk '{print $2}')"
size="$(echo "$line" | awk '{print $3}')"
model="$(echo "$line" | awk '{$1=$2=$3=""; print $0}' | xargs)" # Extract and trim model
serial="$(echo "$line" | awk '{print $NF}')"
# Append ID_PATH to the lsblk line
printf "%-8s %-5s %-5s %-15.15s %-15.15s %s\n" "$name" "$type" "$size" "$model" "$serial" "$id_path"
done
echo "==================================="
echo -en '\033[1;33m'
echo Updates periodically.
echo Press Ctrl-C to exit this window.
echo -en '\033[0;39m'
|