-sed -i -e "s#root=[^ ]*#root=UUID=$ROOT_UUID#" ${prefix}/boot/grub/menu.lst
-sed -i -e "s#${ROOT_DEV}#${ROOT_UUID}#" ${prefix}/etc/fstab
-sed -i -e "s#${SWAP_DEV}#${SWAP_UUID}#" ${prefix}/etc/fstab
+for i in $(seq 1 "$NUMPARTITIONS"); do
+ var="PARTITION${i}"
+ case "$(echo ${!var} | cut -f1 -d:)" in
+ disk) ROOT_GUEST="$(echo ${!var} | cut -f8 -d:)";;
+ swap) SWAP_GUEST="$(echo ${!var} | cut -f8 -d:)";;
+ esac
+done
+sed -i -re "s%^(# *kopt=.*root=)[^ ]*%\1UUID=$ROOT_UUID%" ${prefix}/boot/grub/menu.lst
+sed -i -e "s%${ROOT_GUEST}%UUID=${ROOT_UUID}%" ${prefix}/etc/fstab
+sed -i -e "s%${SWAP_GUEST}%UUID=${SWAP_UUID}%" ${prefix}/etc/fstab