Code:
pct push <VMID>
pct pull <VMID>
pct start 101
.When an LXC has been created,
pct set hostscript ...
can be used to execute a script on the LXC guest when it is started or when it is explicitly stopped from a running state but not from a stopped state.Executing the following on the host will put in a file and set it the correct permissions and ownerships (taken from within the container) into an LXC guest even when it is in stopped / unbootable state.
Bash:
#! /bin/bash
curdir=`pwd`;
node=`hostname`;
vmid="${1}"; # taken from the first argument
# vmid=101; # hardcoded
mntdir=`pct mount $vmid | cut -d"'" -f2`;
echo "$vmid $node" > $mntdir/root/vmid_node.txt;
owner=`ls -l $mntdir | tail -n+2 | head -n1 | cut -d" " -f4`;
chown ${owner}:${owner} $mntdir/root/vmid_node.txt;
pct unmount $vmid;
cd $curdir;
Usage when the above is in say send_vmid.sh, a 755 file on the host:
./send_vmid.sh 101
This should be tweaked by checking that the container is of type lxc (taken from
/etc/appliance.info
file in the LXC guest filesystem) before performing this task.Attachments
Last edited: