问题
i am trying to run a script on remote machine (client) from a server with the command.
ssh -v -t root@10.68.xxx.xxx "sh /tmp/flash.sh 'root@server:/bamboo-agent-home/xml-data/latest/eng_20190124040906.sdcard' 1>&2"
The "flash.sh" has the following (to keep it short im just showing the commands and not the error handlings.)
ISSUE: the script starts of correctly untill it reaches the command after pivot_root. It print echo "moving to new root directory" and just hangs. Sometimes goes ahead to moving the mounts and hangs again.
I have no way to debug because the remote machine is already in mounted state. and -v for ssh does not give any output after the command is stuck.
Any help or suggestions are appreciated.
MOUNT_DIR="/mnt/net"
BLOCK_MOUNT="/run/media/mmcblk1p1/"
OLDROOT="oldroot"
NOT_MOUNTED_ERROR=32
echo "unmounting $MOUNT_DIR and recreating this directory"
umount $MOUNT_DIR
rm -rf $MOUNT_DIR
mkdir $MOUNT_DIR
cd /
echo "stopping services"
sh /tst/test/testservice.sh stop
echo "mounting remote rootfs from $REMOTE_MOUNT_PATH at $MOUNT_DIR"
sshfs -o ssh_command="ssh -i /home/root/.ssh/id_test_cpib" $REMOTE_MOUNT_PATH $MOUNT_DIR
sync
echo "waiting for 120 seconds for the system to be ready for rootfs change in case it is not"
sleep 120
cd $MOUNT_DIR/
mkdir -p $MOUNT_DIR/$OLDROOT
echo "changing rootfs to .$MOUNT_DIR/$OLDROOT"
/sbin/pivot_root . $OLDROOT/
echo "moving to new root directory"
ls -la /
cd /
echo "moving the mounts"
mount --move $OLDROOT/dev/ /dev
mount --move $OLDROOT/proc/ /proc
mount --move $OLDROOT/sys/ /sys
mount --move $OLDROOT/run/ /run
mount --move $OLDROOT/var/volatile /var/volatile/
来源:https://stackoverflow.com/questions/54364557/moving-to-new-root-directory-after-pivot-root-hangs