Initial v1
This commit is contained in:
parent
c649a33837
commit
6173fa8b21
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) <year> <copyright holders>
|
Copyright (c) 2023 | Patrick Asmus - ScriptOS
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
21
Linux_Containers_logo.svg
Normal file
21
Linux_Containers_logo.svg
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg version="1.1" baseProfile="full" width="340" height="310" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g stroke="white" stroke-width="1.5">
|
||||||
|
<g transform="rotate(30) skewX(30)">
|
||||||
|
<rect x="110" y="-72" width="175" height="75" fill="#333333" transform="skewX(-50)"/>
|
||||||
|
<rect x="110" y="3" width="87.5" height="75" fill="#CDCDCD" transform="skewX(-50)"/>
|
||||||
|
<rect x="16.5" y="78.9" width="87.5" height="25" fill="#CDCDCD" />
|
||||||
|
<rect x="16.5" y="104.5" width="175" height="25" fill="#888888" />
|
||||||
|
<rect x="16.5" y="130" width="175" height="50" fill="#DD4814" />
|
||||||
|
<rect x="104" y="166" width="89.5" height="25" fill="#CDCDCD" transform="skewY(-40)"/>
|
||||||
|
<rect x="228.3" y="29.5" width="87.5" height="75" fill="#888888" transform="skewX(-50)"/>
|
||||||
|
<rect x="191.8" y="266" width="89.5" height="25" fill="#888888" transform="skewY(-40)"/>
|
||||||
|
<rect x="192" y="291" width="179.5" height="50" fill="#DD4814" transform="skewY(-40)"/>
|
||||||
|
<rect x="282.3" y="240" width="89.1" height="50" fill="#333333" transform="skewY(-40)"/>
|
||||||
|
<rect x="194" y="3.7" width="87.5" height="25" fill="#333333" />
|
||||||
|
</g>
|
||||||
|
<line x1="93" y1="57" x2="93" y2="88" />
|
||||||
|
<line x1="169" y1="131" x2="92" y2="88" />
|
||||||
|
<line x1="92" y1="88" x2="14" y2="128" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
76
README.md
76
README.md
@ -1,3 +1,75 @@
|
|||||||
# proxmox-lxc-size-changer
|
# Größe der LXC Container mit einem Script ändern
|
||||||
|
|
||||||
|
![Linux_Containers_logo.svg](Linux_Containers_logo.svg?raw=true "Linux_Containers_logo.svg")
|
||||||
|
|
||||||
|
Das Skript `proxmox-lxc-size-changer.v1.sh` ermöglicht die Änderung der Größe eines LXC-Containers auf die gewünschte Gesamtgröße der Container-Disk. Das Skript kann verwendet werden, um die Größe der Disk eines LXC-Containers anzupassen.
|
||||||
|
|
||||||
|
## Anwendungsbeschreibung
|
||||||
|
Um das Skript zu verwenden, folgen Sie den nachstehenden Schritten:
|
||||||
|
|
||||||
|
1. Laden Sie das Skript `proxmox-lxc-size-changer.v1.sh` auf dem Proxmox-Server herunter.
|
||||||
|
2. Öffnen Sie die Bash-Shell auf dem Proxmox-Server und navigieren Sie zum Speicherort des Skripts.
|
||||||
|
3. Stellen Sie sicher, dass das Skript ausführbar ist, indem Sie den Befehl `chmod +x proxmox-lxc-size-changer.v1.sh` ausführen.
|
||||||
|
4. Öffnen Sie das Skript in einem Texteditor und passen Sie die Konfigurationsvariablen an:
|
||||||
|
- `lxcPath`: Der Storage, in dem der Container gemountet ist (Proxmox-Webinterface -> Rechenzentrum -> Storage)
|
||||||
|
- `fullLxcPath`: Der Pfad zum LXC-Container im Proxmox-Dateisystem
|
||||||
|
- `containerID`: Die ID des LXC-Containers, dessen Größe geändert werden soll.
|
||||||
|
- `diskFilename`: Der Dateiname der Disk des Containers.
|
||||||
|
- `newSize`: Die gewünschte neue Größe für die Container-Disk.
|
||||||
|
- `storage`: Der Name des Proxmox-Speichers, in dem das Backup gespeichert wird.
|
||||||
|
5. Speichern Sie das Skript und schließen Sie den Texteditor.
|
||||||
|
6. Öffnen Sie eine Bash-Shell und navigieren Sie zum Speicherort des Skripts.
|
||||||
|
7. Führen Sie den Befehl `bash ./proxmox-lxc-size-changer.v1.sh` aus, um das Skript auszuführen.
|
||||||
|
8. Das Skript stoppt den Container, erstellt ein Backup, führt eine Dateisystemprüfung durch, passt die Größe der Disk an, passt die Konfiguration an und startet den Container wieder.
|
||||||
|
|
||||||
|
Hinweis: Stellen Sie sicher, dass Sie über die erforderlichen Berechtigungen und Kenntnisse verfügen, um die Größe eines LXC-Containers zu ändern. Ausserdem muss im Vorfeld geprüft werden, inwiefern der Container vergrößert oder verkleinert werden kann. (!)
|
||||||
|
|
||||||
|
## Ich übernehme keine Verantwortung für Schäden an Ihrem System!
|
||||||
|
|
||||||
|
So könnte das ganze dann aussehen, wenn das Script erfolgreich gelaufen ist:
|
||||||
|
```bash
|
||||||
|
➜ root: bash proxmox-lxc-size-changer.v1.sh
|
||||||
|
INFO: starting new backup job: vzdump 9100 --notes-template 'Backup vor Größenänderung durch Script' --remove 0 --storage nas02 --mode stop
|
||||||
|
INFO: Starting Backup of VM 9100 (lxc)
|
||||||
|
INFO: Backup started at 2023-07-16 17:57:17
|
||||||
|
INFO: status = stopped
|
||||||
|
INFO: backup mode: stop
|
||||||
|
INFO: ionice priority: 7
|
||||||
|
INFO: CT Name: dev-sv01-ubuntu
|
||||||
|
INFO: including mount point rootfs ('/') in backup
|
||||||
|
INFO: creating Proxmox Backup Server archive 'ct/9100/2023-07-16T15:57:17Z'
|
||||||
|
INFO: run: lxc-usernsexec -m u:0:100000:65536 -m g:0:100000:65536 -- /usr/bin/proxmox-backup-client backup --crypt-mode=none pct.conf:/nas/nas02/backup-pool/vhost01/proxmox-backup/tmp_backup/vzdumptmp1248981_9100//etc/vzdump/pct.conf root.pxar:/mnt/vzsnap0 --include-dev /mnt/vzsnap0/./ --skip-lost-and-found --exclude=/tmp/?* --exclude=/var/tmp/?* --exclude=/var/run/?*.pid --backup-type ct --backup-id 9100 --backup-time 1689523037 --repository root@pam!vhost01@192.168.20.122:nas02
|
||||||
|
INFO: Starting backup: ct/9100/2023-07-16T15:57:17Z
|
||||||
|
INFO: Client name: vhost01
|
||||||
|
INFO: Starting backup protocol: Sun Jul 16 17:57:18 2023
|
||||||
|
INFO: Downloading previous manifest (Sun Jul 16 17:10:15 2023)
|
||||||
|
INFO: Upload config file '/nas/nas02/tmp_backup/vzdumptmp1248981_9100//etc/vzdump/pct.conf' to 'root@pam!vhost01@192.168.20.122:8007:nas02' as pct.conf.blob
|
||||||
|
INFO: Upload directory '/mnt/vzsnap0' to 'root@pam!vhost01@192.168.20.122:8007:nas02' as root.pxar.didx
|
||||||
|
INFO: root.pxar: had to backup 119.804 MiB of 2.704 GiB (compressed 26.377 MiB) in 5.13s
|
||||||
|
INFO: root.pxar: average backup speed: 23.34 MiB/s
|
||||||
|
INFO: root.pxar: backup was done incrementally, reused 2.587 GiB (95.7%)
|
||||||
|
INFO: Uploaded backup catalog (1.726 MiB)
|
||||||
|
INFO: Duration: 5.25s
|
||||||
|
INFO: End Time: Sun Jul 16 17:57:23 2023
|
||||||
|
INFO: adding notes to backup
|
||||||
|
INFO: Finished Backup of VM 9100 (00:00:06)
|
||||||
|
INFO: Backup finished at 2023-07-16 17:57:23
|
||||||
|
INFO: Backup job finished successfully
|
||||||
|
e2fsck 1.46.5 (30-Dec-2021)
|
||||||
|
Pass 1: Checking inodes, blocks, and sizes
|
||||||
|
Pass 2: Checking directory structure
|
||||||
|
Pass 3: Checking directory connectivity
|
||||||
|
Pass 4: Checking reference counts
|
||||||
|
Pass 5: Checking group summary information
|
||||||
|
/volumes/appdata2/images/9100/vm-9100-disk-0.raw: 84327/786432 files (0.5% non-contiguous), 829602/3145728 blocks
|
||||||
|
resize2fs 1.46.5 (30-Dec-2021)
|
||||||
|
Resizing the filesystem on /volumes/appdata2/images/9100/vm-9100-disk-0.raw to 3670016 (4k) blocks.
|
||||||
|
The filesystem on /volumes/appdata2/images/9100/vm-9100-disk-0.raw is now 3670016 (4k) blocks long.
|
||||||
|
|
||||||
|
➜ root: pct enter 9100
|
||||||
|
➜ / df -h
|
||||||
|
Filesystem Size Used Avail Use% Mounted on
|
||||||
|
/dev/loop28 14G 2.9G 11G 23% /
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
Ändert bei Bedarf die Größe des LXC Containers.
|
|
39
proxmox-lxc-size-changer.v1.sh
Normal file
39
proxmox-lxc-size-changer.v1.sh
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Script Name: proxmox-lxc-size-changer.v1.sh
|
||||||
|
# Beschreibung: Ändert die Größe des LXC Containers auf die gewünschte Gesamtgröße der Disk des Containers
|
||||||
|
# Dies gilt primär erstmal nur für die Disk mit der ID 0
|
||||||
|
# Aufruf: bash ./proxmox-lxc-size-changer.v1.sh
|
||||||
|
# Autor: Patrick Asmus
|
||||||
|
# Web: https://www.media-techport.de
|
||||||
|
# Git-Reposit.: https://git.media-techport.de/scriptos/proxmox-lxc-size-changer
|
||||||
|
# Version: 1.0
|
||||||
|
# Datum: 16.07.2023
|
||||||
|
# Modifikation: Ersterstellung
|
||||||
|
#####################################################
|
||||||
|
|
||||||
|
# Variablen
|
||||||
|
lxcPath="appdata2"
|
||||||
|
fullLxcPath="/volumes/${lxcPath}"
|
||||||
|
containerID="9100"
|
||||||
|
diskFilename="vm-${containerID}-disk-0.raw"
|
||||||
|
newSize="12G"
|
||||||
|
storage="nas02"
|
||||||
|
|
||||||
|
# Container stoppen
|
||||||
|
pct stop $containerID
|
||||||
|
|
||||||
|
# Backup erstellen
|
||||||
|
vzdump $containerID --remove 0 --mode stop --notes-template 'Backup vor Größenänderung durch Script' --storage $storage
|
||||||
|
|
||||||
|
# Dateisystemprüfung
|
||||||
|
e2fsck -fy "${fullLxcPath}/images/${containerID}/${diskFilename}"
|
||||||
|
|
||||||
|
# Größe des LXC anpassen
|
||||||
|
resize2fs "${fullLxcPath}/images/${containerID}/${diskFilename}" $newSize
|
||||||
|
|
||||||
|
# Konfiguration anpassen
|
||||||
|
configFile="/etc/pve/lxc/${containerID}.conf"
|
||||||
|
sed -i "s|rootfs: ${lxcPath}:${containerID}/${diskFilename},size=.*|rootfs: ${lxcPath}:${containerID}/${diskFilename},size=${newSize}|" $configFile
|
||||||
|
|
||||||
|
# Container starten
|
||||||
|
pct start $containerID
|
Loading…
Reference in New Issue
Block a user