aboutsummaryrefslogtreecommitdiffstats
path: root/dasd-functions.sh.in
diff options
context:
space:
mode:
authorTuan M. Hoang <tmhoang@flatglobe.org>2018-05-31 10:49:45 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2018-06-12 13:44:08 +0000
commit50c34a98b9f9b3979a3d1a7be89fa9ec78534eb5 (patch)
tree01f5f251a66dd3ac72d993cbb494534d75297bb4 /dasd-functions.sh.in
parent647718ddf6d355e5c2b53cd3d5317df540996314 (diff)
downloadalpine-conf-50c34a98b9f9b3979a3d1a7be89fa9ec78534eb5.tar.bz2
alpine-conf-50c34a98b9f9b3979a3d1a7be89fa9ec78534eb5.tar.xz
setup-disk: install on disk on s390x
In z/VM environment ECKD DASDs need to be low-level formatted with dasdfmt and fdasd before use. These devices don't have partition ids. FBA DASDs are like normal disks - usable with sfdisk/fdisk - and have partition ids. Software raid and LVM on multiple devices are not supported at the moment. Users could install with LVM on single disk and extend logical volume to second disk. In KVM environment Virtual SCSI disks (virtio) are used which are like normal disks. Bootloader is zipl from s390-tools package. This commit introduces setup-dasd.in for DASD functions.
Diffstat (limited to 'dasd-functions.sh.in')
-rw-r--r--dasd-functions.sh.in133
1 files changed, 133 insertions, 0 deletions
diff --git a/dasd-functions.sh.in b/dasd-functions.sh.in
new file mode 100644
index 0000000..ae25a79
--- /dev/null
+++ b/dasd-functions.sh.in
@@ -0,0 +1,133 @@
+#!/bin/sh
+
+eckd_dasd=
+fba_dasd=
+
+_dasdfmt() {
+ local block="$(ls /sys/bus/ccw/devices/"$1"/block 2>/dev/null)" answer=
+ if ! [ -b "/dev/$block" ]; then
+ echo "/dev/$block is not a block device" >&2
+ else
+ echo -n "WARNING: Erase ECKD DASD $1? [y/N]: "
+ read answer
+ case "$answer" in
+ y*|Y*) dasdfmt -b 4096 -d cdl -yp "/dev/$block" ;;
+ esac
+ fi
+}
+
+eckdselect_help() {
+ cat <<-__EOF__
+
+ Enter each available DASD's address (e.g. 0.0.02d0) to format that DASD.
+ Enter multiple addresses separated by a space to format multiple DASDs.
+ Enter 'all' to format all available DASDs.
+
+ WARNING: Data will be lost after formatted!
+
+ Enter 'done' or 'none' to finish formatting.
+ Enter 'abort' to quit the installer.
+
+ __EOF__
+}
+
+show_dasd_info() {
+ local busid= vendor= block= devtype= cutype=
+ for busid in $@; do
+ vendor=$(cat /sys/bus/ccw/devices/$busid/vendor 2>/dev/null)
+ devtype=$(cat /sys/bus/ccw/devices/$busid/devtype 2>/dev/null)
+ cutype=$(cat /sys/bus/ccw/devices/$busid/cutype 2>/dev/null)
+ block="$(ls /sys/bus/ccw/devices/$busid/block 2>/dev/null)"
+ echo " $busid ($devtype $cutype $vendor)"
+ done
+}
+
+ask_eckd(){
+ local prompt="$1"
+ local help_func="$2"
+ shift 2
+ local answer=
+ local default_dasd="all"
+ apk add --quiet s390-tools
+
+ while ! all_in_list "$answer" $@ "$default_dasd" "abort" "done" "none"; do
+ echo "Available ECKD DASD(s) are:"
+ show_dasd_info "$@"
+ echon "$prompt [$default_dasd] "
+ default_read answer $default_dasd
+ case "$answer" in
+ 'abort') exit 0;;
+ 'done'|'none') return 0;;
+ '?') $help_func;;
+ 'all') for busid in $@; do _dasdfmt $busid; done;;
+ *) for busid in $answer; do _dasdfmt $busid; done;;
+ esac
+ done
+}
+
+check_dasd() {
+ eckd_dasd= fba_dasd=
+ local dasd="$(get_bootopt dasd)"
+ for _dasd in $( echo $dasd | tr ',' ' '); do
+ [ -e /sys/bus/ccw/drivers/dasd-eckd/$_dasd ] && eckd_dasd="$eckd_dasd $_dasd"
+ [ -e /sys/bus/ccw/drivers/dasd-fba/$_dasd ] && fba_dasd="$fba_dasd $_dasd"
+ done
+ if [ -n "$eckd_dasd" ]; then
+ ask_eckd \
+ "Which ECKD DASD(s) would you like to be formatted using dasdfmt? (enter '?' for help)" \
+ eckdselect_help "$eckd_dasd"
+ fi
+}
+
+is_dasd() {
+ local disk="${1#*\/dev\/}" dasd_type="$2"
+ for _dasd in $(eval "echo \$${dasd_type}_dasd"); do
+ [ -e /sys/bus/ccw/drivers/dasd-$dasd_type/$_dasd/block/$disk ] && return 0
+ done
+ return 1
+}
+
+setup_zipl() {
+ local mnt="$1" root="$2" modules="$3" kernel_opts="$4"
+ local parameters="root=$root modules=$modules $kernel_opts"
+ local dasd=$(echo $eckd_dasd $fba_dasd | tr ' ' ',')
+ local s390x_net="$(get_bootopt s390x_net)"
+ [ -n "$dasd" ] && parameters="$parameters dasd=$dasd"
+ [ -n "$s390x_net" ] && parameters="$parameters s390x_net=$s390x_net"
+
+ cat > "$mnt"/etc/zipl.conf <<- EOF
+ [defaultboot]
+ defaultauto
+ prompt=1
+ timeout=5
+ default=linux
+ target=/boot
+ [linux]
+ image=/boot/vmlinuz-$KERNEL_FLAVOR
+ ramdisk=/boot/initramfs-$KERNEL_FLAVOR
+ parameters="$parameters"
+ EOF
+}
+
+setup_partitions_eckd() {
+ local blocks_per_track=12 tracks_per_cylinder=15 boot_track= swap_track=
+ local diskdev=$1 boot_size=$2 swap_size=$3 sys_type=$4
+ boot_track=$(($boot_size * 1024 / 4 / blocks_per_track))
+ [ "$swap_size" != 0 ] && swap_track=$(($swap_size * 1024 / 4 / blocks_per_track + boot_track + 1))
+ local conf="$(mktemp)"
+
+ if [ -n "$swap_track" ]; then
+ cat > "$conf" <<- EOF
+ [first,$boot_track,native]
+ [$((boot_track + 1)),$swap_track,swap]
+ [$((swap_track + 1)),last,$sys_type]
+ EOF
+ else
+ cat > "$conf" <<- EOF
+ [first,$boot_track,native]
+ [$((boot_track + 1)),last,$sys_type]
+ EOF
+ fi
+ fdasd -s -c "$conf" $diskdev
+ rm $conf
+}