Skip to content

Commit

Permalink
Merge pull request #199 from vyos/T5136-backport
Browse files Browse the repository at this point in the history
T5136: properly unmount filesystems after installation
  • Loading branch information
dmbaturin authored Apr 3, 2023
2 parents e060789 + 36f08f7 commit 2ec876b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
24 changes: 22 additions & 2 deletions scripts/install/install-functions
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ tolower () {
}

# Validates a user response. Returns the response if valid.
# Returns the default is the user just hits enter.
# Returns the default is the user just hits enter.
# Returns nothing if not valid. Default parameter is $1.
# Options are in $2. If options are defined return must be a member
# of the enum.
# of the enum.
get_response () {
local ldefault=$(tolower "$1")
local loptions=$(tolower "$2")
Expand Down Expand Up @@ -370,6 +370,26 @@ EOF
return 1
}

# try to unmount. log any errors and return the appropriate status.
# $1: arguments for umount
try_unmount ()
{
args="$*"
output=$(eval "umount $args 2>&1")
status=$?
if [ $status == 0 ]; then
return 0
fi
# error
cat <<EOF
Error trying to unmount a partition/directory.
Please see $INSTALL_LOG for details.
EOF
lecho 'Error trying to unmount a partition/directory.'
lecho "umount $args\n$output"
return 1
}

# Find 2 drives of the same size.
get_size_raid ()
{
Expand Down
8 changes: 8 additions & 0 deletions scripts/install/install-image-existing
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,14 @@ if [ -e "$DEF_GRUB" ]; then
fi
fi

# unmount filesystems
if ! try_unmount "--read-only $INST_ROOT $READ_ROOT"; then
failure_exit 'Failed to unmount new squashfs image.'
fi

# sync underlaying filesystems
sync

logger -p local3.warning -t "SystemImage" "System Image $NEWNAME has been added and made the default boot image"

echo 'Done.'
Expand Down

0 comments on commit 2ec876b

Please sign in to comment.