Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'lxc' - could not get working... #12

Open
darekhome opened this issue Dec 15, 2019 · 32 comments
Open

'lxc' - could not get working... #12

darekhome opened this issue Dec 15, 2019 · 32 comments

Comments

@darekhome
Copy link

Tryied few times - result the same...

P.S. What add-on's can not be installed...?

root@proxmox:~# ash -c "$(wget -qLO - https://github.com/whiskerz007/proxmox_hassio_lxc/raw/master/create_container.sh)" -bash: ash: command not found root@proxmox:~# bash -c "$(wget -qLO - https://github.com/whiskerz007/proxmox_hassio_lxc/raw/master/create_container.sh)" [INFO] Using 'local-zfs' for storage location. [INFO] Container ID is 105. Updating LXC template list... Downloading LXC template... Creating LXC container... [WARNING] Some addons may not work due to ZFS not supporting 'fallocate'. Starting LXC container... Setting up container OS... Updating container OS... Installing prerequisites... [ERROR:LXC] 100@34 Unknown failure occured. [ERROR] 100@155 Unknown failure occured. root@proxmox:~#

@darekhome
Copy link
Author

darekhome commented Dec 16, 2019

Tried today again to install - result the same...

lxc

@whiskerz007
Copy link
Owner

The addons that are known to not work with ZFS storage are ones that setup mySQL/MariaDB. It has to do with the way the software creates files and the lack of support in ZFS.

The error you are getting while installing the script looks like it is having a problem installing new packages. Can you tell me the specs of your Proxmox machine?

@darekhome
Copy link
Author

darekhome commented Dec 25, 2019

It is newest version...

root@proxmox:~# pveversion pve-manager/6.1-5/9bf06119 (running kernel: 5.0.15-1-pve)

pve

@whiskerz007
Copy link
Owner

I was interested in the hardware specs that Proxmox is installed on.

@darekhome
Copy link
Author

It is IntelNUC 5PPYH, Pentium N3700, 8GB RAM, SSD 256GB.

@whiskerz007
Copy link
Owner

Are you still having this problem with installing the Hass.io LXC?

@darekhome
Copy link
Author

Yes, still the same...

@whiskerz007
Copy link
Owner

Please run the following and report your results.

bash -c "$(wget -qLO - https://github.com/whiskerz007/proxmox_hassio_lxc/raw/master/create_container.sh | sed 's/master/wait-network/')"

@darekhome
Copy link
Author

darekhome commented Jan 7, 2020

Yes, but I'm just wondering if this should be continued...
Have you looked on that?

`
_1.
We want to emphasize that running Hass.io as a virtual machine is the only supported method to run Hass.io on a virtualized system. We’ve lately seen some funky tutorials on how to run Hass.io inside a container like Docker or LXC, which we DO NOT recommend, you will end up having issues.
2.
We DO NOT support any kind of LXC hacks like listed here: https://github.com/whiskerz007/proxmox_hassio_lxc. These setups try to put everything inside a single container, which will cause you issues. Hass.io is not designed to run fully inside a containerized system, like LXC.

We hope this clarifies our earlier statement._

`

More here: https://www.home-assistant.io/blog/

@Tollbringer
Copy link

Tollbringer commented Jan 7, 2020

The HA Dev team has done a Stellar job releasing and updating this awesome software. Whiskerz007 has created an interesting approach to installing Hassio in an LXC environment, and I see he continues to address users concerns; as do I as one of the first to run & test this method. While I certainly respect the HA Teams' personal positions, each user has a choice to how they want to do things. The main question I ask is -- WHY NOT? Just because they (HA Dev. Team) don't support or recommend it, doesn't mean it's not a functional example. I am totally confused why the stance has been so direct on not supporting the LXC container, other than to clearly push users back to the source of development - Whiskerz007. At any time a snapshot can be taken ad restored to any virtual, or PI or Debian or Ubuntu installation -- So where is the Danger?

Perhaps the (un-planned) or (secret) future will see this project fail? Ok. I'll make a new choice then!

I am very new to many of these topics, I am new to HA - I do not contribute to HA in any way, other than to boast about my home, and the crazy (amazing) and simple things I have done because of the hard-work many people are putting in behind this project - FREE. So at this point, I respect their warnings and decisions, and I choose to keep pushing the envelope and follow this LXC container example. We don't have to be enemies / dissolve friendships because of my choice -- Perhaps we can even help eachother (indirectly)? through communication. ALL HASSIO LXC concerns should be addressed to Whiskerz007.

AS SUCH- Don't bring LXC issues to the HA-DEV Team. They belong here.

Don't be afraid to try something new -- or stick with mainstream. Both are great choices. The point is; you now have another choice!

Thanks Whiskerz007 for coming up with this neat approach and Thanks HA DEV. team for doing what you do. This is what Open-source is all about, and 'FORKING' a project. Welcome to a Left-turn!

Happy 2020 to everyone!

-Tollbringer

@darekhome
Copy link
Author

darekhome commented Jan 7, 2020

Anyway... I've checked this proposal...
Result - with some error...
I'm still open to try other solutions.

error

root@proxmox:~# bash -c "$(wget -qLO - https://github.com/whiskerz007/proxmox_hassio_lxc/raw/master/create_container.sh | sed 's/master/wait-network/')" [INFO] Using 'local-zfs' for storage location. [INFO] Container ID is 104. Updating LXC template list... Downloading LXC template... Creating LXC container... [WARNING] Some addons may not work due to ZFS not supporting 'fallocate'. Starting LXC container... Setting up container OS... Updating container OS... Installing prerequisites... [ERROR:LXC] 100@49 Unknown failure occured. [ERROR] 100@155 Unknown failure occured. root@proxmox:~#

@whiskerz007
Copy link
Owner

LXC is a native Linux implementation of containers to isolate software, security, and permissions from the host system. This is accomplished by the Linux kernel, of the host OS, filtering all syscalls according to configured profiles on a per container basis. Since there is no emulation layer between the container and host, there is practically no performance degradation when compared to virtualization.

Docker leverages LXC functionality to build it's predictable ecosystem. Their application of this technology is to share compiled images of containers and to start a single program within the container. By default, when the program exits, any data that may have been changed is discarded and the container is destroyed. Docker also adds the ability mount non-volatile storage to the container to allow for some of the data to persist between runs of the containers. Again, permission and security models are applied on a per container basis.

The way this Hass.io LXC container has been setup for use is to remove any security limitations applied to the container, which in effect allows the applications inside of the container to run as if it is on the host OS. Specific devices are also passed into the container that Hass.io, and it's addons, has an interest in. Docker is installed using their installation script. Hass.io is installed using their installation script. In effect, the LXC is configured just like you would if you were going to install Hass.io onto a Debian OS on bare metal.

Some benefits of running Hass.io in a LXC versus a VM are: ability to pass the same device to multiple LXC (VM needs solitary access), increased performance, quicker access to Hass.io UI from cold boot, access and control to underlying OS running Hass.io, isolation from host OS (in this case Proxmox) and other containers, ability to manage resources (CPU cores, RAM size, HDD size, network settings) from a UI without the need to reboot the container.

@whiskerz007
Copy link
Owner

Please run the follow and upload debug.log. You can use your favorite scp program to download the file from the Proxmox server using the same credentials you use to login to the UI.

bash -xc "$(wget -qLO - https://github.com/whiskerz007/proxmox_hassio_lxc/raw/master/create_container.sh | sed -e 's/master/wait-network/' -e 's/-- bash -c/-- bash -x/')" | tee debug.log

@darekhome
Copy link
Author

O.K. I can do that on Sunday, when I’m back from trip...

@darekhome
Copy link
Author

darekhome commented Jan 13, 2020

See the 'debug.log' file attached...
debug.log
Are you sure it will help? The log file is very poor...

See also attached all 'console' messages displayed during 'script' run...

console.txt

@whiskerz007
Copy link
Owner

What are Proxmox's configured DNS servers? Please send a screenshot.

You can get this information by going to the node (the icon directly under Datacenter) -> System -> DNS.

@darekhome
Copy link
Author

8.8.8.8, 8.8.4.4, 192.168.1.1 -> see 'png'.

dns

@whiskerz007
Copy link
Owner

Try changing the DNS servers to point to only 1.1.1.1 and 9.9.9.9 and run the script again. Please report findings.

@darekhome
Copy link
Author

I can do that in few days - as I have some test running on this machine and do not want to disturb it...

@Tollbringer
Copy link

@darekhome Any update on this issue? Thanks!

-Tollbringer

@liemrich
Copy link

liemrich commented Mar 22, 2020

Hi, I also has the same error.
Tried changing the DNS to 1.1.1.1, still had the same error.

hassio_lxc_error

@liemrich
Copy link

it seems the newly created lxc container can't connect to ftp.debian.org.
If I ping ftp.debian.org from proxmox shell, it's working though.

@liemrich
Copy link

liemrich commented Mar 23, 2020

Found my problem, apparently the lxc container can't get IP address from my DHCP server.

So, what i did are:

  1. Download create_container.sh script into proxmox host using host console/ssh.
  2. Comment out setup.sh command in the create_container.sh script and run it from proxmox host console.
  3. Change the container ip address from proxmox web gui.
  4. Reboot container from proxmox web gui.
  5. Run the "pct exec 100 /setup.sh" command again from proxmox host console.

Update:
Apparently still not working. It's more on bridging issue. Will update further

@Tollbringer
Copy link

Thanks very much for sharing the solution. Much appreciated.

Tollbringer

@liemrich
Copy link

liemrich commented Mar 23, 2020

Ok apparently mac address issue on hyper-v vm that host proxmox. I set mac address spoofing on on the hyper-v vm with proxmox, voila... now container can get IP and access network.

@det-peralta
Copy link

det-peralta commented Mar 31, 2020

Ok apparently mac address issue on hyper-v vm that host proxmox. I set mac address spoofing on on the hyper-v vm with proxmox, voila... now container can get IP and access network.

@liemrich How can we do this? Can you explain?

Thank you

@pi642s
Copy link

pi642s commented May 13, 2020

hello

can you guys help me install ? i can't seem to get past this error

root@proxmox:~# bash -c "$(wget -qLO - https://github.com/whiskerz007/proxmox_hassio_lxc/raw/master/create_container.sh)"
[INFO] Using 'local-lvm' for storage location.
[INFO] Container ID is 101.
Updating LXC template list...
Downloading LXC template...
Creating LXC container...
Starting LXC container...
Setting up container OS...
Updating container OS...
Installing prerequisites...
Customizing Docker...
Installing Docker...
Installing Home Assistant...

[ERROR:LXC] 1@58 Unknown failure occured.
[ERROR] 1@165 Unknown failure occured.
Logical volume "vm-101-disk-0" successfully removed

@waltner
Copy link

waltner commented May 13, 2020

Same here on a fresh install. After some progress the setup hung and on any key press (Enter in my case) it would abort.
So I looked into the code for installing Home Assistant and found one line prompting for confirmation. As I entered the expected string not supported, the installer went through:

[...]
Installing Home Assistant...
not supported
Enabling autorun Home Assistant cli...
Customizing container...
Cleanup...
[INFO] Successfully created Home Assistant LXC to 100.


Home Assistant is reachable by going to the following URLs.
[...]

After that installation can start on the provided url. 👍

@pi642s
Copy link

pi642s commented May 13, 2020

Same here on a fresh install. After some progress the setup hung and on any key press (Enter in my case) it would abort.
So I looked into the code for installing Home Assistant and found one line prompting for confirmation. As I entered the expected string not supported, the installer went through:

[...]
Installing Home Assistant...
not supported
Enabling autorun Home Assistant cli...
Customizing container...
Cleanup...
[INFO] Successfully created Home Assistant LXC to 100.


Home Assistant is reachable by going to the following URLs.
[...]

After that installation can start on the provided url. 👍

you are correct! thank you! it did install.

@whiskerz007
Copy link
Owner

The script has been updated and should now work for further installations.

@Tollbringer
Copy link

Tollbringer commented May 14, 2020

I used it this morning - worked great! BTW: The added BONUS of being able to use a 1-liner script to duplicate the old LXC container, pick your options in a menu driven format (copy Disk Size, Mac Address, IP address etc...) it virtually clones the old container but gives you access to the latest device hooks/compatibility fixes without "redoing" or "starting over"-- SUPER SLICK!

A job that continues to be well done. Top NOTCH support on this variant.

You've taken an AMAZING program (Home Assistant) that continues to improve - to a whole new level of flexibility. Thank you for your efforts!

-Tollbringer

@richmondsimao
Copy link

Install problem....

root@proxmox:~# bash -xc "$(wget -qLO - https://github.com/whiskerz007/proxmox_hassio_lxc/raw/master/create_container.sh | sed -e 's/master/wait-network/' -e 's/-- bash -c/-- bash -x/')" | tee debug.log

  • '[' -z '' ']'
  • return
  • set -o errexit
  • set -o errtrace
  • set -o nounset
  • set -o pipefail
  • shopt -s expand_aliases
  • alias 'die=EXIT=$? LINE=$LINENO error_exit'
  • trap die ERR
  • trap cleanup EXIT
    ++ mktemp -d
  • TEMP_DIR=/tmp/tmp.jdaZOENFYI
  • pushd /tmp/tmp.jdaZOENFYI
    ++ pvesh get /cluster/nextid
  • export CTID=102
  • CTID=102
  • export PCT_OSTYPE=debian
  • PCT_OSTYPE=debian
  • export PCT_OSVERSION=10
  • PCT_OSVERSION=10
  • export PCT_DISK_SIZE=4
  • PCT_DISK_SIZE=4
  • export 'PCT_OPTIONS=
    -cmode shell
    -features nesting=1
    -hostname homeassistant
    -net0 name=eth0,bridge=vmbr0
    -onboot 1
    -tags homeassistant
    '
  • PCT_OPTIONS='
    -cmode shell
    -features nesting=1
    -hostname homeassistant
    -net0 name=eth0,bridge=vmbr0
    -onboot 1
    -tags homeassistant
    '
    ++ wget -qLO - https://github.com/whiskerz007/proxmox_lxc_create/raw/main/lxc_create.sh
  • bash -c '#!/usr/bin/env bash

Setup script environment

set -o errexit #Exit immediately if a pipeline returns a non-zero status
set -o errtrace #Trap ERR from shell functions, command substitutions, and commands from subshell
set -o nounset #Treat unset variables as an error
set -o pipefail #Pipe will exit with last non-zero status if applicable
shopt -s expand_aliases
alias die='''EXIT=$? LINE=$LINENO error_exit'''
trap die ERR

function error_exit() {
trap - ERR
local DEFAULT='''Unknown failure occured.'''
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
msg "$FLAG $REASON" 1>&2
exit $EXIT
}
function warn() {
local REASON="\e[97m$1\e[39m"
local FLAG="\e[93m[WARNING]\e[39m"
msg "$FLAG $REASON"
}
function info() {
local REASON="$1"
local FLAG="\e[36m[INFO]\e[39m"
msg "$FLAG $REASON"
}
function msg() {
local TEXT="$1"
echo -e "$TEXT"
}
function select_storage() {
local CLASS=$1
local CONTENT
local CONTENT_LABEL
case $CLASS in
container) CONTENT='''rootdir'''; CONTENT_LABEL='''Container''';;
template) CONTENT='''vztmpl'''; CONTENT_LABEL='''Container template''';;
*) false || die "Invalid storage class.";;
esac

Query all storage locations

local -a MENU
while read -r line; do
local TAG=$(echo $line | awk '''{print $1}''')
local TYPE=$(echo $line | awk '''{printf "%-10s", $2}''')
local FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '''{printf( "%9sB", $6)}''')
local ITEM=" Type: $TYPE Free: $FREE "
local OFFSET=2
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
fi
MENU+=( "$TAG" "$ITEM" "OFF" )
done < <(pvesm status -content $CONTENT | awk '''NR>1''')

Select storage location

if [ $((${#MENU[@]}/3)) -eq 0 ]; then # No storage locations are detected
warn "'''$CONTENT_LABEL''' needs to be selected for at least one storage location."
die "Unable to detect valid storage location."
elif [ $((${#MENU[@]}/3)) -eq 1 ]; then # Only one storage location is detected
printf ${MENU[0]}
else # More than one storage location is detected
local STORAGE
while [ -z "${STORAGE:+x}" ]; do # Generate graphical menu
STORAGE=$(whiptail --title "Storage Pools" --radiolist
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n"
16 $(($MSG_MAX_LENGTH + 23)) 6
"${MENU[@]}" 3>&1 1>&2 2>&3) || die "Menu aborted."
done
printf $STORAGE
fi
}

Test if required variables are set

[[ "${CTID:-}" ]] || die "You need to set '''CTID''' variable."
[[ "${PCT_OSTYPE:-}" ]] || die "You need to set '''PCT_OSTYPE''' variable."

Test if ID is valid

[ "$CTID" -ge "100" ] || die "ID cannot be less than 100."

Test if ID is in use

if pct status $CTID &>/dev/null; then
warn "ID '''$CTID''' is already in use."
unset CTID
die "Cannot use ID that is already in use."
fi

Get template storage

TEMPLATE_STORAGE=$(select_storage template) || exit
info "Using '''$TEMPLATE_STORAGE''' for template storage."

Get container storage

CONTAINER_STORAGE=$(select_storage container) || exit
info "Using '''$CONTAINER_STORAGE''' for container storage."

Update LXC template list

msg "Updating LXC template list..."
pveam update >/dev/null

Get LXC template string

TEMPLATE_SEARCH=${PCT_OSTYPE}-${PCT_OSVERSION:-}
mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.($TEMPLATE_SEARCH.)/\1/p" | sort -t - -k 2 -V)
[ ${#TEMPLATES[@]} -gt 0 ] || die "Unable to find a template when searching for '''$TEMPLATE_SEARCH'''."
TEMPLATE="${TEMPLATES[-1]}"

Download LXC template

if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then
msg "Downloading LXC template..."
pveam download $TEMPLATE_STORAGE $TEMPLATE >/dev/null ||
die "A problem occured while downloading the LXC template."
fi

Create variable for '''pct''' options

DEFAULT_PCT_OPTIONS=(
-arch $(dpkg --print-architecture)
-net0 name=eth0,bridge=vmbr0,ip=dhcp
-unprivileged 1
)
PCT_OPTIONS=( ${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}} )
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=( -rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8} )

Create LXC

msg "Creating LXC container..."
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
die "A problem occured while trying to create container."

Success message

info "LXC container '''$CTID''' was successfully created."'
[INFO] Using 'local' for template storage.
[INFO] Using 'local-lvm' for container storage.
Updating LXC template list...
Creating LXC container...
[INFO] LXC container '102' was successfully created.
++ awk 'NR>1 {print $2}'
+++ pct config 102
+++ awk -F : '{print $2}'
+++ grep rootfs
++ pvesm status -storage local-lvm

  • STORAGE_TYPE=lvmthin
  • '[' lvmthin == zfspool ']'
  • REPO=https://github.com/whiskerz007/proxmox_hassio_lxc
  • wget -qO - https://github.com/whiskerz007/proxmox_hassio_lxc/tarball/wait-network
  • tar -xz --strip-components=1
  • LXC_CONFIG=/etc/pve/lxc/102.conf
  • cat
  • cat
  • bash ./set_autodev_hook.sh 102
    bash: ./set_autodev_hook.sh: No such file or directory
    ++ EXIT=127
    ++ LINE=90
    ++ error_exit
    ++ trap - ERR
    ++ local 'DEFAULT=Unknown failure occured.'
    ++ local 'REASON=\e[97mUnknown failure occured.\e[39m'
    ++ local 'FLAG=\e[91m[ERROR] \e[93m127@90'
    ++ msg '\e[91m[ERROR] \e[93m127@90 \e[97mUnknown failure occured.\e[39m'
    ++ local 'TEXT=\e[91m[ERROR] \e[93m127@90 \e[97mUnknown failure occured.\e[39m'
    ++ echo -e '\e[91m[ERROR] \e[93m127@90 \e[97mUnknown failure occured.\e[39m'
    [ERROR] 127@90 Unknown failure occured.
    ++ '[' '!' -z 102 ']'
    ++ cleanup_ctid
    +++ pct status 102
    +++ pct status 102
    +++ awk '{print $2}'
    ++ '[' stopped == running ']'
    ++ pct destroy 102
    Logical volume "vm-102-disk-0" successfully removed
    ++ exit 127
  • cleanup
  • popd
  • rm -rf /tmp/tmp.jdaZOENFYI

root@proxmox:# cat debug.log
[INFO] Using 'local' for template storage.
[INFO] Using 'local-lvm' for container storage.
Updating LXC template list...
Creating LXC container...
[INFO] LXC container '102' was successfully created.
[ERROR] 127@90 Unknown failure occured.
Logical volume "vm-102-disk-0" successfully removed
root@proxmox:
#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants