• news
  • pics
  • linux
  • windows
  • proxmox
  • game
  • news
  • pics
  • linux
  • windows
  • proxmox
  • game
Home
proxmox

Proxmox中Lxc容器挂载远程目录

我们有一台PVE,PVE上有个LXC容器(我的是Archlinux),现在我需要把远程目录挂载到Archlinux中。

思路

  1. LXC是特权容器:按Linux常规挂载即可
  2. LXC不是特权容器:远程目录挂载到PVE,通过PVE和LXC目录映射

方案(仅思路2)

  1. 获取Archllinux中用户的uid、gid(一般为1000,1000)
  2. 获取PVE与LXC中uid、gid映射起始值
>>> cat /var/lib/lxc/your_lxc_id/config | grep idmap                                                                                   17:41.49 Wed Jan 26 2022 >>> 
lxc.idmap = u 0 100000 65536
lxc.idmap = g 0 100000 65536

3. mount命令中的uid、gid 等于 lxc 容器中uid、gid (即1000,1000)加上 pve与lxc映射值(即100000,100000)等于 101000,101000

4. 在pve中mount好远程目录

sudo mount.cifs -o "rw,dir_mode=0777,file_mode=0777,username=yoursmbusername,password=yoursmbpassword,uid=101000,gid=101000" //remote_ip //mount_point

5. 在LXC容器中创建好映射目录

6. 修改LXC容器的配置文件 `nano /etc/pve/lxc/yourlxcid.conf` ,新增一行

lxc.mount.entry: /pve_mount_point  lxc_mount_point none rw,bind 0 0

注意,lxc_mount_point 是相对根目录路径

Previous article livego流媒体服务实现无插件播放视频(支持hls,flv)
Next article Using local directory bind mount points

therock

1 Comment

  1. gralion torile
    March 7, 2022 at 11:23 am

    This web page can be a walk-by means of for the entire data you needed about this and didn’t know who to ask. Glimpse right here, and also you’ll definitely discover it.

Meta
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Categories
  • game
  • linux
  • news
  • pics
  • proxmox
  • windows
Recent Posts
  • proxmox7.3直通显卡
  • Proxmox VE 直通显卡方案及解决N卡Code43
  • Linux系统出现:You have new mail in /var/spool/mail/root 的原因及解决办法
  • debian系统解决中文乱码
  • pve添加git和pvetools
Recent Comments
  • EdgarTot on proxmox7.3直通显卡
  • Ashvem on proxmox7.3直通显卡
  • Tedvem on proxmox7.3直通显卡
  • Jackvem on proxmox7.3直通显卡
  • Miavem on proxmox7.3直通显卡
Archives
  • March 2023 (1)
  • December 2022 (4)
  • November 2022 (6)
  • April 2022 (1)
  • February 2022 (5)
  • January 2022 (2)
  • December 2021 (3)
  • November 2021 (1)
  • October 2021 (2)
  • September 2021 (1)
  • August 2021 (1)
  • July 2021 (8)
  • June 2021 (14)
  • May 2021 (2)
  • April 2021 (2)
  • March 2021 (10)
  • January 2021 (4)
  • December 2020 (4)
  • November 2020 (13)
  • April 2020 (276)
  • March 2020 (1)
  • June 2019 (5)
  • May 2019 (10)
  • December 2015 (1)