This file is indexed.

/usr/sbin/ocs-resize-part is in clonezilla 3.27.16-2.

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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/bash
# Author: Steven Shiau <steven _at_ nchc org tw>
# License: GPL
#
# To solve the small partition image restored to larger partition problem.
#

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

# Settings
# By default we won't run ntfsfix before resizing it.
run_ntfsfix="no"

#
export LC_ALL=C

USAGE() {
   echo "Usage: [OPTION] device"
   echo "OPTION:"
   echo "-b, --batch  Run program in batch mode, i.e. without any prompt or wait to press enter."
   echo "-n, --ntfsfix  Run ntfsfix before resizing a NTFS partition."
   echo "Example: $0 /dev/sdc1"
}

# Parse command-line options
while [ $# -gt 0 ]; do
  case "$1" in
    -b|--batch)
            batch_mode="yes"
	    shift;;
    -n|--ntfsfix)
            run_ntfsfix="yes"
	    shift;;
    -*)     echo "${0}: ${1}: invalid option" >&2
            USAGE >& 2
            exit 2 ;;
    *)      break ;;
  esac
done

[ $# -ne 1 ] && USAGE && exit 1
partition="$1"

######
## main script
######
#
#
check_input_partition ${partition#/dev/*}

if [ -n "$(grep -Ew "^$partition" /proc/mounts)" ]; then
  echo "Partition $partition is already mounted! You must unmount it first! Program terminated!"
  [ -f "$part_info" ] && rm -f $part_info
  exit 1
fi
# check partition, if no such partition exist, exit, otherwise
# "parted $partition p" will hang
part_fs="$(ocs-get-part-info $partition filesystem)"
if [ -z "$part_fs" ]; then
  echo "Unknown or unsupported partition ($partition) found! Skip this partition ${partition}."
  exit 1
fi

part_start="$(ocs-get-part-info $partition start)"
part_end="$(ocs-get-part-info $partition end)"

case "$part_fs" in
   reiserfs)
              if ! which resize_reiserfs &> /dev/null; then
                 echo "resize_reiserfs: command not found! Skip resizing this partition ${partition}"
		 exit 1
	      fi
	      [ "$batch_mode" = "yes" ] && resize_reiserfs_opt="-f"
              echo "resize_reiserfs $resize_reiserfs_opt ${partition}"
              resize_reiserfs $resize_reiserfs_opt ${partition}
              ;;
   vfat|fat16|fat32)
              if ! which fatresize&> /dev/null; then
                 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
                 echo "Program fatresize not found! Skip this partition ${partition}"
                 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
		 exit 1
	      fi
	      fat_fs_size="$(LC_ALL=C lsblk -b -n -d -o size ${partition})"
	      fatresize -p --verbose -i -s $fat_fs_size ${partition}
              ;;
   ext2|ext3|ext4)
              if ! which e2fsck &> /dev/null || ! which resize2fs &> /dev/null ; then
                 echo "e2fsck: command not found! Skip resizing this partition ${partition}"
		 exit 1
	      fi
	      [ "$batch_mode" = "yes" ] && resize2fs_opt="-f"
              echo "e2fsck -f -y ${partition}; resize2fs -p $resize2fs_opt ${partition}"
              e2fsck -f -y ${partition}
              resize2fs -p $resize2fs_opt ${partition}
              ;;
        ntfs)
              if ! which ntfsresize &> /dev/null; then
                 echo "ntfsresize: command not found! Skip resizing this partition ${partition}"
		 exit 1
	      fi
	      [ "$batch_mode" = "yes" ] && ntfsresize_opt="-f -f"
              if [ "$run_ntfsfix" = "yes" ]; then
                ntfsfix ${partition}
	      fi
              echo "ntfsresize $ntfsresize_opt ${partition}"
              ntfsresize $ntfsresize_opt ${partition}
              ;;
        xfs)
              if ! type xfs_growfs &> /dev/null; then
                 echo "xfs_growfs: command not found! Skip growing this partition ${partition}"
		 exit 1
	      fi
	      XFS_TMP="$(mktemp -d /tmp/xfsmnt.XXXXXX)"
	      mount -t xfs ${partition} $XFS_TMP
	      rc=$?
	      if [ "$rc" -eq 0 ]; then
                echo "Runninig \"xfs_growfs ${partition}\"..."
                xfs_growfs ${partition}
		umount ${partition}
		rcm=$?
	        if [ "$rcm" -eq 0 ]; then
		  [ -d "$XFS_TMP" ] && rmdir $XFS_TMP
	        fi
	      else
	        echo "Failed to mount xfs partition ${partition}! Without mounting xfs partition, we can not increase the filesystem size to fit partition size!"
		echo "Program terminated!"
		exit 1
              fi
              ;;
        jfs)
	      # Ref: http://jfs.sourceforge.net/project/pub/faq.txt
	      # Q2. Can the size of the file system be increased?
	      # A2. Yes, you need release 1.0.21 or above for the file system. The FS must be mounted and you need to  use the -o remount option.
              # example: mount -o remount,resize /mount point
	      JFS_TMP="$(mktemp -d /tmp/jfsmnt.XXXXXX)"
	      mount -t jfs ${partition} $JFS_TMP
	      rc=$?
	      if [ "$rc" -eq 0 ]; then
                echo -n "Resizing jfs ${partition}\"... "
		mount -o remount,resize ${partition}
		echo "done!"
		umount ${partition}
		rcm=$?
	        if [ "$rcm" -eq 0 ]; then
		  [ -d "$JFS_TMP" ] && rmdir $JFS_TMP
	        fi
	      else
	        echo "Failed to mount jfs partition ${partition}! Without mounting jfs partition, we can not increase the filesystem size to fit partition size!"
		echo "Program terminated!"
		exit 1
              fi
              ;;
        btrfs)
              if ! type btrfs &> /dev/null; then
                 echo "btrfs: command not found! Skip growing this partition ${partition}"
		 exit 1
	      fi
	      BTRFS_TMP="$(mktemp -d /tmp/btrfsmnt.XXXXXX)"
	      mount -t btrfs ${partition} $BTRFS_TMP
	      rc=$?
	      if [ "$rc" -eq 0 ]; then
                # Was: echo "Runninig \"btrfsctl -r max ${BTRFS_TMP}\"..."
                # Was: btrfsctl -r max ${BTRFS_TMP}
		echo "Running \"btrfs filesystem resize max ${BTRFS_TMP}\"..."
		btrfs filesystem resize max ${BTRFS_TMP}
		umount ${partition}
		rcm=$?
	        if [ "$rcm" -eq 0 ]; then
		  [ -d "$BTRFS_TMP" ] && rmdir $BTRFS_TMP
	        fi
	      else
	        echo "Failed to mount btrfs partition ${partition}! Without mounting btrfs partition, we can not increase the filesystem size to fit partition size!"
		echo "Program terminated!"
		exit 1
              fi
              ;;
        nilfs2)
              if ! type nilfs-resize &> /dev/null; then
                 echo "nilfs-resize: command not found! Skip growing this partition ${partition}"
		 exit 1
	      fi
	      NILFS_TMP="$(mktemp -d /tmp/nilfsmnt.XXXXXX)"
	      mount -t nilfs2 ${partition} $NILFS_TMP
	      rc=$?
	      if [ "$rc" -eq 0 ]; then
		echo "Running \"nilfs-resize -y ${partition}\"..."
		nilfs-resize -y ${partition}
		umount ${partition}
		rcm=$?
	        if [ "$rcm" -eq 0 ]; then
		  [ -d "$NILFS_TMP" ] && rmdir $NILFS_TMP
	        fi
	      else
	        echo "Failed to mount nilfs2 partition ${partition}! Without mounting nilfs2 partition, we can not increase the filesystem size to fit partition size!"
		echo "Program terminated!"
		exit 1
              fi
              ;;
        *)
	      echo "\"$part_fs\" is an unknown or unsupported filesystem... Skip resizing that."
	      exit 1
esac

[ -f "$part_info" ] && rm -f $part_info