I was used to create a LVM thin volume, formatted it with ext4 and added the storage as extension to a lxc vm like:
extended:
path: /var/lib/extended
source: /dev/vg0/extended
type: disk
What i needed to do is to chown the mount point before to /etc/setuid’s value to allow root within container.
After an upgrade to Ubuntu’s snap 4.16 i do not find the mount point to change the owner of the directory, instead it remains at nobody:nogroup
How can I find the ns or mount point to change the ownership to otheruser:root?
It’d be helpful to have something like lxc admin container chown x:x /var/lib/extended
#!/bin/bash
# Script: lxc-admin-owner
# Purpose: Change ownership and rights from host a container object based on a a referenced file
# Origin: Markus Neubauer/STD ~ GPL
# Description: 3 Parameters used: <LCX Name> <Obj> <RefObj>
# If the REFOBJ does not exist you could create one within the container and
# modify it to the required owner + rights. then use it as reference on the host.
LXC="${1:?Which LXC is affected}"
CONTAINER_PID=$(ps fax | grep -A1 "/var/snap/lxd/common/lxd/container[s] ${LXC}" | awk 'END{print $1}')
if [ -z "$CONTAINER_PID" ]; then
echo "no container active by this name ${LXC}" >&2
exit 1
fi
OBJ="${2:?Which object should be set}"
if [ '/' == "${OBJ:0:1}" ]; then
OBJ="${OBJ:1}"
fi
REFOBJ="${3:?Give name of a reference object}"
if [ '/' == "${REFOBJ:0:1}" ]; then
REFOBJ="${REFOBJ:1}"
fi
cd /proc/$CONTAINER_PID/root || exit 4
if [ ! -e "${OBJ}" ]; then
echo "Object /${OBJ} does not exist within container ${LXC}" >&2
exit 2
fi
if [ ! -e "${REFOBJ}" ]; then
echo "Reference object /${REFOBJ} does not exist within container ${LXC}" >&2
exit 3
fi
echo "using ${LXC} on /proc/$CONTAINER_PID/root"
chown --reference="${REFOBJ}" "${OBJ}"
chmod --reference="${REFOBJ}" "${OBJ}"
## eof