Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Commit

Permalink
Absolutely awful hack to sync data before reboot
Browse files Browse the repository at this point in the history
I really don't want to talk about it, OK? Just read the patch and leave
me alone so I can drink until I forget about this.
  • Loading branch information
wgwoods committed Nov 14, 2012
1 parent 0817d2c commit 3da014f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions 90system-upgrade/upgrade-post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,20 @@ getarg 'rd.upgrade.break=post' 'rd.break=upgrade-post' && \
emergency_shell -n upgrade-post "Break before upgrade-post hook"
source_hook upgrade-post

# absolutely godawful hack workaround garbage that I am ashamed of:
# Since we can't figure out how to unmount the root device properly
# (it's inaccessable because we moved system-upgrade-root on top of it)
# we need some other way to make sure all the data that might be pending
# actually gets written to disk. So...

startmsg="upgrade-post pid $$ doing emergency sync"
echo 1 > /proc/sys/kernel/sysrq # enable sysrq
echo "$startmsg" > /dev/kmsg # add marker to dmesg
echo s > /proc/sysrq-trigger # start sync
for ((i=0; i<20; i++)); do # wait up to 20s for sync to finish
dmesg | sed "1,/$startmsg/d" | grep -q 'Emergency Sync complete' && break
sleep 1
done
sleep 2 # sleep a little more just to be sure

exit 0

0 comments on commit 3da014f

Please sign in to comment.