Skip to content

Commit

Permalink
s390x: add support for ECKD DASD devices on zVM and LPAR
Browse files Browse the repository at this point in the history
  • Loading branch information
tuan-hoang1 committed Sep 24, 2019
1 parent b1531e7 commit df40bd8
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
51 changes: 50 additions & 1 deletion coreos-installer
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,51 @@ write_bootloader() {
fi
}
#########################################################
#Handle s390x ECKD DASD devices
#########################################################
write_image_to_dasd() {
log "Extracting disk image"
mount_tmpfs $(( $($DECOMPRESSION_TOOL ${imagefile_compressed} | wc --bytes) / 1024 / 1024 + ${TMPFS_MBSIZE} ))
$DECOMPRESSION_TOOL ${imagefile_compressed} > ${imagefile}

# low-level format the ECKD DASD using dasdfmt, if needed
DEST_DEV_BUS=$(lszdev --by-node ${DEST_DEV} | tail -n 1 | awk '{print $2}')
if [ "$(< /sys/bus/ccw/devices/${DEST_DEV_BUS}/status)" = "unformatted" ]; then
dasdfmt --blocksize 4096 --disk_layout cdl --mode full -ypv "${DEST_DEV}"
fi
block_per_tracks=$(fdasd -p ${DEST_DEV} | grep blocks\ per\ track | awk '{print $5}')

# the first 2 tracks of the ECKD DASD are reserved
first_track=2
boot_partition=($(fdisk -b 4096 -o DEVICE,START,SECTORS -l ${imagefile} | grep "${imagefile}1" | awk '{print $2,$3}'))
root_partition=($(fdisk -b 4096 -o DEVICE,START,SECTORS -l ${imagefile} | grep "${imagefile}4" | awk '{print $2,$3}'))
# testing: boot_partition=(256 98305)
boot_partition+=( $first_track $(dc -e "${boot_partition[1]} $block_per_tracks 1 - + $block_per_tracks / p") )
root_partition+=($(( ${boot_partition[2]} + ${boot_partition[3]} )) "last")
cat > "/tmp/fdasd_conf" <<- EOF
[$first_track,$(( ${root_partition[2]} - 1 )),native]
[${root_partition[2]},${root_partition[3]},native]
EOF

# format the ECKD DASD using fdasd program
fdasd --silent --config /tmp/fdasd_conf "${DEST_DEV}"

# copy the content of each partition
set -- ${boot_partition[@]} ${root_partition[@]}
while [ $# -gt 0 ]; do
dd bs=4096 if="${imagefile}" iflag=fullblock of="${DEST_DEV}" \
status=progress \
skip="$1" \
count="$2" \
seek="$(( $3 * $block_per_tracks ))"
if [[ $? -ne 0 ]]; then
log "failed to write image to ECKD DASD device"
exit 1
fi
shift 4
done
}
#########################################################
#Handle s390x zFCP SCSI devices
#########################################################
write_image_to_zfcp_disk() {
Expand Down Expand Up @@ -760,7 +805,11 @@ write_image_to_disk() {
then
case $(systemd-detect-virt) in
none|zvm) # 'none' means LPAR
write_image_to_zfcp_disk
if [[ "${DEST_DEV}" =~ "dasd" ]]; then
write_image_to_dasd
else
write_image_to_zfcp_disk
fi
;;
qemu) log "Use qcow images for KVM s390x installation instead"; exit 1 ;;
esac
Expand Down
3 changes: 3 additions & 0 deletions dracut/30coreos-installer/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ install() {
inst_multiple -o /usr/sbin/zipl
inst_multiple -o /usr/sbin/chreipl
inst_multiple -o /usr/sbin/chzdev
inst_multiple -o /usr/sbin/lszdev
inst_multiple -o /usr/sbin/dasdfmt
inst_multiple -o /usr/sbin/fdasd
inst_multiple -o /usr/sbin/sfdisk
inst_multiple -o /lib/s390-tools/stage3.bin
fi
Expand Down

0 comments on commit df40bd8

Please sign in to comment.