User Tools

Site Tools


informatique:logiciels:proxmox

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
informatique:logiciels:proxmox [2024/08/25 07:16] – created pteuinformatique:logiciels:proxmox [2025/02/28 06:27] (current) – Partager un stockage local entre les LXC pteu
Line 12: Line 12:
  
 src : https://forum.proxmox.com/threads/novnc-console-mouse-way-off-from-local-mouse.111559/ src : https://forum.proxmox.com/threads/novnc-console-mouse-way-off-from-local-mouse.111559/
 +
 +
 +=====Redimensionner la taille du stockage local-lvm=====
 +
 +Mon but est de redimensionner le stockage **local-lvm**, utilisé par Proxmox pour les images disque et les conteneurs ; je veux le réduire et de récupérer le téra libéré pour un usage tier.
 +
 +Par défaut Proxmox partitionne le disque ainsi:
 +<code bash>
 +lsblk
 +NAME               MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
 +nvme0n1            259:0    0  1.9T  0 disk
 +├─nvme0n1p1        259:1    0 1007K  0 part
 +├─nvme0n1p2        259:2    0    1G  0 part /boot/efi
 +└─nvme0n1p3        259:3    0  1.9T  0 part
 +  ├─pve-swap       252:   0    8G  0 lvm  [SWAP]
 +  ├─pve-root       252:   0   96G  0 lvm  /
 +  ├─pve-data_tmeta 252:2    0 15.9G  0 lvm
 +  │ └─pve-data     252:   0  1.7T  0 lvm
 +  └─pve-data_tdata 252:3    0  1.7T  0 lvm
 +    └─pve-data     252:   0  1.7T  0 lvm
 +</code>
 +Proxmox utilise LVM pour organiser les espaces de stockage de la 3e partition nvme0n1p3 : il créé un PV (physical volume), puis un VG (volume group) qui est par défaut divisé en LV (logical volume) pour la partition de swap (LV "swap"), / (LV "root"), et le **local-lvm** (LV "data"). PI le stockage **local** est quant à lui un sous-répertoire de / (''/var/lib/vz'').
 +
 +N'ayant pas réussi à réduire directement le volume "data":
 +<code bash>
 +lvresize -L -1500G /dev/pve/data
 +  Thin pool volumes pve/data_tdata cannot be reduced in size yet.
 +</code>
 +
 +... je l'ai supprimé (il faut au préalable le supprimer dans la webUI : Datacenter> Storage> local-lvm -> Remove)
 +<code bash>
 +lvremove /dev/pve/data
 +Do you really want to remove active logical volume pve/data? [y/n]: y
 +  Logical volume "data" successfully removed.
 +</code>
 +
 +J'en ai profité pour augmenter un peu le "root", tant qu'à faire:
 +<code bash>
 +lvresize -L +100G /dev/pve/root
 +  Size of logical volume pve/root changed from 96.00 GiB (24576 extents) to 196.00 GiB (50176 extents).
 +  Logical volume pve/root successfully resized.
 +
 +resize2fs /dev/pve/root
 +resize2fs 1.47.0 (5-Feb-2023)
 +Filesystem at /dev/pve/root is mounted on /; on-line resizing required
 +old_desc_blocks = 12, new_desc_blocks = 25
 +The filesystem on /dev/pve/root is now 51380224 (4k) blocks long.
 +</code>
 +
 +J'ai programmé un check au prochain reboot, la partition étant montée il n'est pas possible de le faire à chaud:
 +<code bash>
 +e2fsck -f /dev/pve/root
 +e2fsck 1.47.0 (5-Feb-2023)
 +/dev/pve/root is mounted.
 +e2fsck: Cannot continue, aborting.
 +
 +touch /forcefsck
 +</code>
 +
 +Je recréé le volume "data", je le convertis en thin-pool :
 +<code bash>
 +lvcreate -L200G -n data pve
 +
 +lvconvert --type thin-pool pve/data
 +  Thin pool volume with chunk size 128.00 KiB can address at most 31.75 TiB of data.
 +  WARNING: Converting pve/data to thin pool's data volume with metadata wiping.
 +  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
 +Do you really want to convert pve/data? [y/n]: y
 +  Converted pve/data to thin pool.
 +</code>
 +
 +NB : il faut le faire avant d'allouer tout l'espace sinon on obtient l'erreur suivante:
 +<code bash>
 +lvconvert --type thin-pool /dev/pve/data
 +  Thin pool volume with chunk size 128.00 KiB can address at most 31.75 TiB of data.
 +  WARNING: Converting pve/data to thin pool's data volume with metadata wiping.
 +  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
 +Do you really want to convert pve/data? [y/n]: y
 +  Volume group "pve" has insufficient free space (0 extents): 25 required.
 + </code>
 +
 +Et j'alloue tout le reste de l'espace à un nouveau LV "datarv", que je formate en ext4 :
 +<code bash>
 +lvcreate -l100%VG -n data2rv pve
 +  Reducing 100%VG to remaining free space <1.47 TiB in VG.
 +  Logical volume "datarv" created.
 +
 +mkfs.ext4 -m 0 /dev/pve/datarv
 +mke2fs 1.47.0 (5-Feb-2023)
 +Discarding device blocks: done
 +Creating filesystem with 393879552 4k blocks and 98476032 inodes
 +Filesystem UUID: ee159ef2-f2d0-400b-af01-a8f6bf3593a3
 +Superblock backups stored on blocks:
 + 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
 + 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
 + 102400000, 214990848
 +
 +Allocating group tables: done
 +Writing inode tables: done
 +Creating journal (262144 blocks): done
 +Writing superblocks and filesystem accounting information: done
 +
 +echo "/dev/pve/datarv /mnt/datarv ext4 defaults 0 0" >>/etc/fstab
 +
 +mkdir -p /mnt/datarv
 +
 +mount /mnt/datarv
 +</code>
 +
 +Ce qui nous donne :
 +<code bash>
 +df -Th /mnt/datarv
 +Filesystem             Type  Size  Used Avail Use% Mounted on
 +/dev/mapper/pve-datarv ext4  1.5T   28K  1.5T   1% /mnt/datarv
 +
 +lvscan
 +  ACTIVE            '/dev/pve/data' [200.00 GiB] inherit
 +  ACTIVE            '/dev/pve/swap' [8.00 GiB] inherit
 +  ACTIVE            '/dev/pve/root' [196.00 GiB] inherit
 +  ACTIVE            '/dev/pve/datarv' [<1.47 TiB] inherit
 +
 +lsblk
 +NAME               MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
 +nvme0n1            259:0    0  1.9T  0 disk
 +├─nvme0n1p1        259:1    0 1007K  0 part
 +├─nvme0n1p2        259:2    0    1G  0 part /boot/efi
 +└─nvme0n1p3        259:3    0  1.9T  0 part
 +  ├─pve-swap       252:   0    8G  0 lvm  [SWAP]
 +  ├─pve-root       252:   0  196G  0 lvm  /
 +  ├─pve-data_tmeta 252:2    0  100M  0 lvm
 +  │ └─pve-data     252:   0  200G  0 lvm
 +  ├─pve-data_tdata 252:3    0  200G  0 lvm
 +  │ └─pve-data     252:   0  200G  0 lvm
 +  └─pve-datarv     252:   0  1.5T  0 lvm
 +</code>
 +
 +
 +=====Partager un stockage local entre les LXC=====
 +
 +(Inspiré de [[https://pve.proxmox.com/wiki/Unprivileged_LXC_containers|Using local directory bind mount points]])
 +Pour partager [[informatique:logiciels:proxmox#redimensionner_la_taille_du_stockage_local-lvm|la partition précédemment créée]] entre un ou plusieurs conteneurs non privilégiés (le 100 pour cet exemple) :
 +
 +Dans la conf de chaque LXC :
 +<code bash>
 +echo "mp0: /mnt/datarv,mp=/data
 +
 +# uid map: from uid 0 map 1005 uids (in the ct) to the range starting 100000 (on the host), 
 +# so 0..1004 (ct) → 100000..101004 (host)
 +lxc.idmap = u 0 100000 1005
 +lxc.idmap = g 0 100000 1005
 +# we map 1 uid starting from uid 1005 onto 1005, so 1005 → 1005
 +lxc.idmap = u 1005 1005 1
 +lxc.idmap = g 1005 1005 1
 +# we map the rest of 65535 from 1006 upto 101006, so 1006..65535 → 101006..165535
 +lxc.idmap = u 1006 101006 64530
 +lxc.idmap = g 1006 101006 64530" >>/etc/pve/lxc/100.conf
 +</code>
 +
 +Sur le système hôte:
 +<code bash>
 +echo "root:1005:1" >>/etc/subuid
 +echo "root:1005:1" >>//etc/subgid
 +chown -R 1005:1005 /mnt/datarv
 +</code>
 +
 +Puis redémarrer le conteneur:
 +<code bash>
 +lxc-stop 100 && lxc-start 100
 +</code>
informatique/logiciels/proxmox.1724570162.txt.gz · Last modified: 2024/08/25 07:16 by pteu