Skip to content

Latest commit

 

History

History
137 lines (104 loc) · 4.13 KB

Proxmox.md

File metadata and controls

137 lines (104 loc) · 4.13 KB

Proxmox

Source links:

Useful nano commands:

Ctrl + o --> save changes
Ctrl + x --> exit nano
Ctrl + k --> delete line

How to setup shared directory on Proxmox host to be used in multiple LXC containers (mount)

  1. On Proxmox create new user group (like homegroup) in Datacenter
  2. Create new user (like homeuser)

Proxmox user

  1. Create new user on node through command line
groupadd homegroup &&
useradd  -g homegroup -m homeuser
  • to find out what ids created user has, do id homeuser
  1. Create new zfs pool
  • execute for example zfs create DATA3TB/homeshare/share
  1. Give to the new created user ownership of this folder
chgrp -R homegroup /DATA3TB/homeshare/share
chown -R homeuser /DATA3TB/homeshare/share
  1. Then create new lxc container with ubuntu (for example with id: 203).

  2. Now we need to edit 203.conf

    Location of every conf file is in /etc/pve/lxc/*.conf To edit 203.conf we execute

nano /etc/pve/lxc/203.conf
  • We need to add following lines
mp0: /DATA3TB/homeshare/share/,mp=/mnt/share
lxc.idmap: u 0 100000 1607
lxc.idmap: g 0 100000 1000
lxc.idmap: u 1607 1607 1
lxc.idmap: g 1000 1000 1
lxc.idmap: u 1608 101608 63928
lxc.idmap: g 1001 101001 64535
  • First line mp0...defines the new share
  • other lines assume that the user homeuser and his group homegrouphave id´s of user = 1607 and group = 1000
  1. Only once per node (proxmox server) following files have also to be edited:
/etc/subuid
/etc/subgid
  • In both files we add lines:
    • in subuid root:1607:1
    • in subgid root:1000:1
  1. To test if the mount and rights has worked, we test it when we login into lcs container and execute df -h.

    We must see our share /mnt/share/

  2. Then we can try to create new file or folder in that location mkdir /mnt/share/testfolder

    If we don´t receive any error, then everything is fine.

  3. In lcx container install samba for sharing with apt update && apt install samba -Y

  4. After that we modify samba config file

mv /etc/samba/smb.conf /etc/samba/smb.bak
nano /etc/samba/smb.conf
  1. The configration looks like this
[global]
workgroup = WORKGROUP

[data]
path = /mnt/share
writeable = yes
browseable = yes
valid user = homeuser
  1. After every change of smb.conf file, we need to restart samba service with systemctl restart smbd.service

  2. We create new samba user and linux user with same password.

smbpasswd -a homeuser
groupadd -g 1000 homegroup &&
useradd -u 1607 -g homegroup -m homeuser
passwd homeuser
  1. Docker on Proxmox with portainer
apt update
 
apt install docker.io
systemctl start docker
systemctl enable docker
 
### install docker-compose ###
 
apt install curl
 
curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
 
chmod +x /usr/local/bin/docker-compose
 
docker-compose --version
 
## install portainer ##
 
docker volume create portainer_data
 
docker run -d -p 9100:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /data/configs/dockerconfig/portainer:/data -e TZ=Europe/Berlin  portainer/portainer:latest
  1. Create cifs (samba share) in ubuntu VM (not LXC!)

Important Add in /etc/fstab file "argument" nolock!

Ubuntu CIFC share in VM

  1. Create nfs (synology share) in ubuntu VM.

Ubuntu NFS share in VM

  1. If the current user in Ubuntu has only $ in shell, then follwoing command has to be executed to repair it:

chsh -s /bin/bash john