Ah, I see. So is raw.lxc completely unsupported, or is it only the
upgrade that is unsupported? If the latter, no problem, I can trash and
recreate the containers. Or is there some better way of achieving what
I'm doing?

I'm using lxc for testing i386 target from my x86-64 host without having
to deal with setting up a complete cross toolchain. The critical thing
is that I want to be able to access my homedir from the container. The
container(s) are set up with something like:

#!/bin/bash
set -eu
_UID=$(id -u)
GID=$(id -g)
GROUP=$(id -gn)
SUBUID=root:$_UID:1
SUBGID=root:$GID:1

# give lxd permission to map your user/group id through
grep $SUBUID /etc/subuid -qs || sudo usermod --add-subuids ${_UID}-${_UID} 
--add-subgids ${GID}-${GID} root
UID_OFFSET=$(grep 'root:.*:65536' /etc/subuid | head -1 | awk -F: '{ print $2 
}')
GID_OFFSET=$(grep 'root:.*:65536' /etc/subgid | head -1 | awk -F: '{ print $2 
}')

# set up a separate key to make sure we can log in automatically via ssh
# with $HOME mounted
KEY=$HOME/.ssh/id_lxd_$USER
PUBKEY=$KEY.pub
AUTHORIZED_KEYS=$HOME/.ssh/authorized_keys
[ -f $PUBKEY ] || ssh-keygen -f $KEY -N '' -C "key for local lxds"
grep "$(cat $PUBKEY)" $AUTHORIZED_KEYS -qs || cat $PUBKEY >> $AUTHORIZED_KEYS

# create a profile to control this, name it after $USER
lxc profile create $USER &> /dev/null || true

# configure profile
# this will rewrite the whole profile
cat << EOF | lxc profile edit $USER
name: $USER
description: allow home dir mounting for $USER
config:
  # this part maps the special uid/gid in the container to the correct host 
uid/gid
  raw.lxc: |
    lxc.id_map =
    lxc.id_map = u 0 $UID_OFFSET $(($_UID - 1))
    lxc.id_map = g 0 $GID_OFFSET $(($GID - 1))
    lxc.id_map = u $_UID 1000 1
    lxc.id_map = g $GID 1000 1
    lxc.id_map = u $(($_UID + 1)) $(($UID_OFFSET + $_UID + 1)) $((65536 - $_UID 
- 1))
    lxc.id_map = g $(($GID + 1)) $(($GID_OFFSET + $GID + 1)) $((65536 - $GID - 
1))
  user.vendor-data: |
    #cloud-config
    users:
      - name: $USER
        groups: sudo
        shell: $SHELL
        sudo: ['ALL=(ALL) NOPASSWD:ALL']
    # ensure users shell is installed
    packages:
      - $(dpkg -S $(readlink -m $SHELL) | cut -d: -f1)
    # The dhclient is a workaround for dns, see lp:1600766
    runcmd:
      - "dhclient eth0"
# this section adds your \$HOME directory into the container. This is useful 
for vim, bash and ssh config, and such like.
devices:
  home:
    type: disk
    source: $HOME
    path: $HOME
EOF


Or is there some saner way to achieve what I'm trying to do?

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1784846

Title:
  package lxd 3.0.1-0ubuntu1~18.04.1 failed to install/upgrade:
  installed lxd package post-installation script subprocess returned
  error exit status 1

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/lxd/+bug/1784846/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to