Lines Matching full:disk
25 # Returns SCSI host number for the given disk
27 function get_scsi_host #disk
29 typeset disk=$1
30 ls /sys/block/${disk}/device/scsi_device | cut -d : -f 1
134 function is_real_device #disk
136 typeset disk=$1
137 [[ -z $disk ]] && log_fail "No argument for disk given."
140 lsblk $DEV_RDSKDIR/$disk -o TYPE 2>/dev/null | \
141 grep -q disk
148 function is_loop_device #disk
150 typeset disk=$1
151 [[ -z $disk ]] && log_fail "No argument for disk given."
154 lsblk $DEV_RDSKDIR/$disk -o TYPE 2>/dev/null | \
162 # link to a device mapper and to a disk
171 function is_mpath_device #disk
173 typeset disk=$1
174 [[ -z $disk ]] && log_fail "No argument for disk given."
177 if lsblk $DEV_MPATHDIR/$disk -o TYPE 2>/dev/null | \
179 readlink $DEV_MPATHDIR/$disk > /dev/null 2>&1
184 is_disk_device $DEV_MPATHDIR/$disk
205 # Set the slice prefix for disk partitioning depending
208 # checks first disk to determine slice prefix.
212 typeset disk
217 disk="$(echo $DISKS | awk '{print $(i + 1)}')"
218 if is_mpath_device $disk && ! echo $disk | awk 'substr($1,18,1) ~ /^[[:digit:]]+$/ {exit 1}' || is_real_device $disk; then
221 elif is_mpath_device $disk || is_loop_device $disk; then
225 log_fail "$disk not supported for partitioning."
235 # checks first disk to determine device directory
237 # real disk = /dev (linux)
242 typeset disk
247 disk="$(echo $DISKS | awk '{print $(i + 1)}')"
248 if is_mpath_device $disk; then
283 # Get persistent name for given disk
292 | awk '/disk\/by-id/ {print $2; exit}' | cut -d/ -f3-
295 | awk '/disk\/by-id\/dm-uuid/ {print $2; exit}' \
306 # Online or offline a disk on the system
308 # First checks state of disk. Test will fail if disk is not properly onlined
312 function on_off_disk # disk state{online,offline} host
314 typeset disk=$1
318 [[ -z $disk ]] || [[ -z $state ]] && \
322 if [[ $state == "offline" ]] && ( is_mpath_device $disk ); then
323 dm_name="$(readlink $DEV_DSKDIR/$disk | cut -d/ -f2)"
326 #check if disk is online
335 log_fail "Offlining $disk failed"
340 elif [[ $state == "offline" ]] && ( is_real_device $disk ); then
341 #check if disk is online
342 if lsscsi | grep -qF $disk; then
343 dev_state="/sys/block/$disk/device/state"
344 dev_delete="/sys/block/$disk/device/delete"
347 if lsscsi | grep -qF $disk; then
348 log_fail "Offlining $disk failed"
351 log_note "$disk is already offline"
357 if is_mpath_device $disk; then
358 dm_name="$(readlink $DEV_DSKDIR/$disk | cut -d/ -f2)"
361 log_fail "Onlining $disk failed"
363 elif is_real_device $disk; then
366 while ! lsscsi | grep -qF $disk; do
368 log_fail "Onlining $disk failed"
375 log_fail "$disk is not a real dev"
378 log_fail "$disk failed to $state"
384 # Simulate disk removal
386 function remove_disk #disk
388 typeset disk=$1
389 on_off_disk $disk "offline"
394 # Simulate disk insertion for the given SCSI host
396 function insert_disk #disk scsi_host
398 typeset disk=$1
400 on_off_disk $disk "online" $scsi_host