Several information message improvements.

This commit is contained in:
Ivan Davidov 2016-04-30 21:50:26 +03:00
parent b739102a20
commit 3fd9ada9a9
4 changed files with 29 additions and 13 deletions

View File

@ -30,11 +30,11 @@
mount -t tmpfs none /mnt mount -t tmpfs none /mnt
# Create folders for all critical file systems. # Create folders for all critical file systems.
echo "Create folders for all critical file systems..."
mkdir /mnt/dev mkdir /mnt/dev
mkdir /mnt/sys mkdir /mnt/sys
mkdir /mnt/proc mkdir /mnt/proc
mkdir /mnt/tmp mkdir /mnt/tmp
echo "Created folders for all critical file systems."
# Copy root folders in the new mountpoint. # Copy root folders in the new mountpoint.
echo "Copying the root file system to /mnt..." echo "Copying the root file system to /mnt..."
@ -144,7 +144,6 @@ for DEVICE in /dev/* ; do
rmdir $DEFAULT_OVERLAY_DIR 2>/dev/null rmdir $DEFAULT_OVERLAY_DIR 2>/dev/null
rmdir $DEFAULT_UPPER_DIR 2>/dev/null rmdir $DEFAULT_UPPER_DIR 2>/dev/null
rmdir $DEFAULT_WORK_DIR 2>/dev/null rmdir $DEFAULT_WORK_DIR 2>/dev/null
else else
# All done, time to go. # All done, time to go.
echo " Overlay data from device '$DEVICE' has been merged." echo " Overlay data from device '$DEVICE' has been merged."
@ -159,16 +158,16 @@ for DEVICE in /dev/* ; do
done done
# Move critical file systems to the new mountpoint. # Move critical file systems to the new mountpoint.
echo "Remounting /dev, /sys, /tmp and /proc in /mnt."
mount --move /dev /mnt/dev mount --move /dev /mnt/dev
mount --move /sys /mnt/sys mount --move /sys /mnt/sys
mount --move /proc /mnt/proc mount --move /proc /mnt/proc
mount --move /tmp /mnt/tmp mount --move /tmp /mnt/tmp
echo "Mount locations /dev, /sys, /tmp and /proc have been moved to /mnt."
# The new mountpoint becomes file system root. All original root folders are # The new mountpoint becomes file system root. All original root folders are
# deleted automatically as part of the command execution. The '/sbin/init' # deleted automatically as part of the command execution. The '/sbin/init'
# process is invoked and it becomes the new PID 1 parent process. # process is invoked and it becomes the new PID 1 parent process.
echo "Moving from initramfs root area to overlayfs root area." echo "Switching from initramfs root area to overlayfs root area."
exec switch_root /mnt /etc/03_init.sh exec switch_root /mnt /etc/03_init.sh
echo "(/etc/02_overlay.sh) - there is a serious bug..." echo "(/etc/02_overlay.sh) - there is a serious bug..."

View File

@ -2,14 +2,14 @@
# Create sparse file of 20MB which can be used by QEMU. # Create sparse file of 20MB which can be used by QEMU.
if [ "$1" = "" ] ; then if [ "$1" = "-e" -o "$1" = "--empty" ] ; then
# Create new hard disk image file. # Create new hard disk image file.
rm -f hdd.img rm -f hdd.img
truncate -s 20M hdd.img truncate -s 20M hdd.img
echo "Created new hard disk image file 'hdd.img' with 20MB size." echo "Created new hard disk image file 'hdd.img' with 20MB size."
elif [ "$1" = "-f" -o "$1" = "-folder" ] ; then elif [ "$1" = "-f" -o "$1" = "--folder" ] ; then
if [ ! "$(id -u)" = "0" ] ; then if [ ! "$(id -u)" = "0" ] ; then
echo "Using option '-f' (or '-folder') requires root permissions." echo "Using option '-f' (or '--folder') requires root permissions."
exit 1 exit 1
fi fi
@ -44,9 +44,9 @@ elif [ "$1" = "-f" -o "$1" = "-folder" ] ; then
chown $(logname) hdd.img chown $(logname) hdd.img
echo "Applied original ownership to hard disk image file." echo "Applied original ownership to hard disk image file."
elif [ "$1" = "-s" -o "$1" = "-sparse" ] ; then elif [ "$1" = "-s" -o "$1" = "--sparse" ] ; then
if [ ! "$(id -u)" = "0" ] ; then if [ ! "$(id -u)" = "0" ] ; then
echo "Using option '-s' (or '-sparse') requires root permissions." echo "Using option '-s' (or '--sparse') requires root permissions."
exit 1 exit 1
fi fi
@ -110,7 +110,24 @@ elif [ "$1" = "-s" -o "$1" = "-sparse" ] ; then
chown $(logname) hdd.img chown $(logname) hdd.img
echo "Applied original ownership to hard disk image file." echo "Applied original ownership to hard disk image file."
elif [ "$1" = "-h" -o "$1" = "--help" ] ; then
cat << CEOF
Usage: $0 [OPTION]
This utility generates 20MB sparse file 'hdd.img' which can be used as QEMU
disk image where all filesystem changes from the live session are persisted.
-e, --empty Create empty sparse image file which is not formatted.
-f, --folder Create sparse image file formatted with Ext2 filesystem which
contains compatible overlay folder structure.
-h, --help Prints this help information.
-s, --sparse Create sparse image file formatted with FAT filesystem which
contains sparse image file 'minimal.img' (1MB) formatted with
Ext2 filesystem which contains the actual overlay structure.
CEOF
elif [ "$1" = "" ] ; then
echo "No option specified. Use '-h' or '--help' for more info."
else else
echo "Option '$1' is not recognized. Valid options are '-f' and '-s'." echo "Option '$1' is not recognized. Use '-h' or '--help' for more info."
fi fi

View File

@ -9,9 +9,9 @@
if [ "$1" = "-hdd" -o "$1" = "-h" ] ; then if [ "$1" = "-hdd" -o "$1" = "-h" ] ; then
echo "Starting QEMU with attached ISO image and hard disk." echo "Starting QEMU with attached ISO image and hard disk."
qemu-system-i386 -m 64M -hda hdd.img -cdrom minimal_linux_live.iso -boot d qemu-system-i386 -m 64M -cdrom minimal_linux_live.iso -hda hdd.img -boot d
else else
echo "Starting QEMU with attached ISO image." echo "Starting QEMU with attached ISO image and no hard disk."
qemu-system-i386 -m 64M -cdrom minimal_linux_live.iso -boot d qemu-system-i386 -m 64M -cdrom minimal_linux_live.iso -boot d
fi fi

View File

@ -9,7 +9,7 @@
if [ "$1" = "-hdd" -o "$1" = "-h" ] ; then if [ "$1" = "-hdd" -o "$1" = "-h" ] ; then
echo "Starting QEMU with attached ISO image and hard disk." echo "Starting QEMU with attached ISO image and hard disk."
qemu-system-x86_64 -m 64M -hda hdd.img -cdrom minimal_linux_live.iso -boot d qemu-system-x86_64 -m 64M -cdrom minimal_linux_live.iso -hda hdd.img -boot d
else else
echo "Starting QEMU with attached ISO image." echo "Starting QEMU with attached ISO image."
qemu-system-x86_64 -m 64M -cdrom minimal_linux_live.iso -boot d qemu-system-x86_64 -m 64M -cdrom minimal_linux_live.iso -boot d