#!/bin/sh
# anaconda-diskroot: find our root image on the given disk device
# usage: anaconda-diskroot DEVICE [PATH]

. /lib/anaconda-lib.sh
command -v getarg >/dev/null || . /lib/dracut-lib.sh


dev="$1"
path="$2" # optional, could be empty

[ -e "/dev/root" ] && exit 1 # we already have a root device!

info "anaconda using disk root at $dev"
mount $dev $repodir || warn "Couldn't mount $dev"
# HACK: umount $dev on upgrades so anaconda doesn't crash.
# FIXME: make anaconda handle this cleanly (mount --rbind/--move)
if getargbool 0 preupgrade upgrade inst.upgrade; then
    anaconda_live_root_dir $repodir $path --copy-to-ram
else
    anaconda_live_root_dir $repodir $path
fi
