/usr/sbin/ocs-label-dev is in clonezilla 3.21.13-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | #!/bin/bash
# License: GPL
# Author: Steven Shiau <steven _at_ stevenshiau org>
# Description: Program to label a file system partition
# Support file systems: ext2/3/4, xfs, jfs, reiserfs, fat, ntfs,
#
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
#
USAGE() {
echo "$ocs - To label a file system partition"
echo "Usage:"
echo "To run $ocs:"
echo "$ocs DEVICE LABEL"
echo "Options:"
echo "DEVICE is the device name, e.g. /dev/sda1, /dev/sda2..."
echo "LABEL is the label name, e.g. Clonezilla-USB"
echo "Ex:"
echo "To label a file system partition /dev/sdc1 as \"Clonezilla-USB\", run"
echo " $ocs /dev/sdc1 Clonezilla-USB"
echo
} # end of USAGE
#
####################
### Main program ###
####################
ocs_file="$0"
ocs=`basename $ocs_file`
#
while [ $# -gt 0 ]; do
case "$1" in
-*) echo "${0}: ${1}: invalid option" >&2
USAGE >& 2
exit 2 ;;
*) break ;;
esac
done
ocs_dev="$1"
ocs_label="$2"
#
check_if_root
ask_and_load_lang_set
#
if [ -z "$ocs_dev" ]; then
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
echo "No destination device is assigned!"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
echo "$msg_program_stop!"
exit 1
fi
if [ -z "$ocs_label" ]; then
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
echo "No label is assigned!"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
echo "$msg_program_stop!"
exit 1
fi
if [ ! -b "$ocs_dev" ]; then
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
echo "This block device was not found: $ocs_dev"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
echo "$msg_program_stop!"
exit 1
fi
#
fs="$(ocs-get-part-info $ocs_dev filesystem)"
case "$fs" in
ext[234]) e2label $ocs_dev $ocs_label;;
vfat|fat*) # FAT only allows 11 characters.
if [ "$(echo -n "$ocs_label" | wc -c)" -gt 11 ]; then
# Truncate it to 11, must keep the last 4 characters,
# e.g. GGTrailer_DCP_01p1 -> GGTrail01p1
ocs_label="${ocs_label:0:7}${ocs_label: -4}"
[ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
echo "Warning! Too long for FAT! Truncate label as: $ocs_label"
sleep 1
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
fi
fatlabel $ocs_dev $ocs_label;;
ntfs) ntfslabel $ocs_dev $ocs_label;;
reiserfs) reiserfstune --label $ocs_label $ocs_dev;;
xfs) xfs_admin -L $ocs_label $ocs_dev;;
jfs) jfs_tune -L $ocs_label $ocs_dev;;
*) echo "File system of $ocs_dev is: $fs"
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
echo "Unknown or not supported file system!"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
echo "$msg_program_stop!"
my_ocs_exit 1
esac
rc=$?
my_ocs_exit $rc
|