# By			: Nguyen Tu.
# Website		: https://www.aioboot.com (AIO Boot).
# Last modified	: 05.03.2018.
# Description	: Use another partition as the root partition.

echo "${scanpartmessage}"
set k="_"
set saved_root=$root
set saved_prefix=$prefix
for dev in (*); do
	regexp -s device '\((.*)\)' $dev
	if [ "$saved_root" == "$device" ]; then continue; fi
	if ! searchindevice "$device" "on"; then continue; fi
	probe -f -s fstype $device
	if [ -n "$fstype" ] -a [ "$fstype" != "procfs" ] -a [ -f ($device)/AIO/grub/grub.cfg ]; then
		probe -s vollabel -l $device
		probe -s voluuid -u $device
		if [ -z "$vollabel" ]; then set vollabel="${noname}"; fi
		GetHotkey
		menuentry "[${k}] ${device} - ${vollabel} - ${fstype} - ${voluuid}" $device --hotkey="${k}" {
			set root="${2}"
			set prefix="(${2})/AIO/grub"
			configfile $prefix/grub.cfg
		}
		unset vollabel
		unset voluuid
	fi
	unset fstype
done
set root=$saved_root
set prefix=$saved_prefix
source ${prefix}/ReturnMain.cfg