Compare commits

..

12 Commits
v4.08 ... v4.10

Author SHA1 Message Date
Kroese
f0e5a61e73 Delete network on shutdown
Delete network on shutdown
2023-07-04 18:56:18 +02:00
Kroese
b07577b60d style: Remove spaces 2023-07-04 18:46:16 +02:00
Kroese
4571fe9c4f feat: Close network on shutdown 2023-07-04 18:36:38 +02:00
Kroese
9f6fbc3f7c fix: Use pidwait only on recent kernels 2023-07-04 18:22:50 +02:00
Kroese
bbc033f032 feat: Close network on shutdown 2023-07-04 18:21:37 +02:00
Kroese
160e5a07be feat: Close network on shutdown 2023-07-04 18:20:03 +02:00
Kroese
0cca2a7079 fix: Wait for address 2023-07-04 12:52:49 +02:00
Kroese
64257d1a6f Fix issue #281 and #283
Fix issue #281 and #283
2023-07-03 12:02:33 +02:00
Kroese
d6dde093b2 docs: Resize info 2023-07-03 11:59:40 +02:00
Kroese
d1957f5eb7 fix: Fix issue #281 2023-07-03 11:38:11 +02:00
Kroese
f3f9a9f480 fix: Fix issue #281 2023-07-03 11:26:10 +02:00
Kroese
15d67203c9 fix: Fix issue #283 2023-07-03 11:11:47 +02:00
6 changed files with 57 additions and 11 deletions

View File

@@ -61,6 +61,8 @@ docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-ti
DISK_SIZE: "256G" DISK_SIZE: "256G"
``` ```
This can also be used to resize the existing disk to a larger capacity without data loss.
* ### How do I change the location of the virtual disk? * ### How do I change the location of the virtual disk?
To change the virtual disk's location from the default Docker volume, include the following bind mount in your compose file: To change the virtual disk's location from the default Docker volume, include the following bind mount in your compose file:

View File

@@ -39,7 +39,9 @@ if [ -f "${DATA}" ]; then
if [[ "${ALLOCATE}" == [Nn]* ]]; then if [[ "${ALLOCATE}" == [Nn]* ]]; then
# Resize file by changing its length # Resize file by changing its length
truncate -s "${DATA_SIZE}" "${DATA}"; if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
error "Could not resize the file for the virtual disk." && exit 85
fi
else else
@@ -55,7 +57,9 @@ if [ -f "${DATA}" ]; then
# Resize file by allocating more space # Resize file by allocating more space
if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
error "Could not allocate a file for the virtual disk." && exit 85 if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
error "Could not resize the file for the virtual disk." && exit 85
fi
fi fi
if [[ "${ALLOCATE}" == [Zz]* ]]; then if [[ "${ALLOCATE}" == [Zz]* ]]; then
@@ -84,7 +88,10 @@ if [ ! -f "${DATA}" ]; then
if [[ "${ALLOCATE}" == [Nn]* ]]; then if [[ "${ALLOCATE}" == [Nn]* ]]; then
# Create an empty file # Create an empty file
truncate -s "${DATA_SIZE}" "${DATA}" if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
rm -f "${DATA}"
error "Could not create a file for the virtual disk." && exit 87
fi
else else
@@ -98,8 +105,10 @@ if [ ! -f "${DATA}" ]; then
# Create an empty file # Create an empty file
if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then if ! fallocate -l "${DATA_SIZE}" "${DATA}"; then
if ! truncate -s "${DATA_SIZE}" "${DATA}"; then
rm -f "${DATA}" rm -f "${DATA}"
error "Could not allocate a file for the virtual disk." && exit 87 error "Could not create a file for the virtual disk." && exit 87
fi
fi fi
if [[ "${ALLOCATE}" == [Zz]* ]]; then if [[ "${ALLOCATE}" == [Zz]* ]]; then

View File

@@ -179,8 +179,10 @@ SPACE=$(df --output=avail -B 1 "$TMP" | tail -n 1)
(( SYSTEM_SIZE > SPACE )) && error "Not enough free space to create a 4 GB system disk." && exit 87 (( SYSTEM_SIZE > SPACE )) && error "Not enough free space to create a 4 GB system disk." && exit 87
if ! fallocate -l "${SYSTEM_SIZE}" "${SYSTEM}"; then if ! fallocate -l "${SYSTEM_SIZE}" "${SYSTEM}"; then
if ! truncate -s "${SYSTEM_SIZE}" "${SYSTEM}"; then
rm -f "${SYSTEM}" && error "Could not allocate a file for the system disk." && exit 88 rm -f "${SYSTEM}" && error "Could not allocate a file for the system disk." && exit 88
fi fi
fi
if [[ "${ALLOCATE}" == [Zz]* ]]; then if [[ "${ALLOCATE}" == [Zz]* ]]; then
info "Install: Preallocating 4 GB of diskspace..." info "Install: Preallocating 4 GB of diskspace..."

View File

@@ -31,7 +31,10 @@ configureDHCP() {
error "and that the NET_ADMIN capability has been added to the container config: --cap-add NET_ADMIN" && exit 16 error "and that the NET_ADMIN capability has been added to the container config: --cap-add NET_ADMIN" && exit 16
fi fi
ip link set "${VM_NET_TAP}" up while ! ip link set "${VM_NET_TAP}" up; do
info "Waiting for address to become available..."
sleep 2
done
TAP_NR=$(</sys/class/net/"${VM_NET_TAP}"/ifindex) TAP_NR=$(</sys/class/net/"${VM_NET_TAP}"/ifindex)
TAP_PATH="/dev/tap${TAP_NR}" TAP_PATH="/dev/tap${TAP_NR}"
@@ -127,11 +130,20 @@ configureNAT () {
fi fi
ip address add ${VM_NET_IP%.*}.1/24 broadcast ${VM_NET_IP%.*}.255 dev dockerbridge ip address add ${VM_NET_IP%.*}.1/24 broadcast ${VM_NET_IP%.*}.255 dev dockerbridge
ip link set dockerbridge up
while ! ip link set dockerbridge up; do
info "Waiting for address to become available..."
sleep 2
done
# QEMU Works with taps, set tap to the bridge created # QEMU Works with taps, set tap to the bridge created
ip tuntap add dev "${VM_NET_TAP}" mode tap ip tuntap add dev "${VM_NET_TAP}" mode tap
ip link set "${VM_NET_TAP}" up promisc on
while ! ip link set "${VM_NET_TAP}" up promisc on; do
info "Waiting for tap to become available..."
sleep 2
done
ip link set dev "${VM_NET_TAP}" master dockerbridge ip link set dev "${VM_NET_TAP}" master dockerbridge
# Add internet connection to the VM # Add internet connection to the VM
@@ -165,6 +177,24 @@ configureNAT () {
return 0 return 0
} }
closeNetwork () {
if [[ "${DHCP}" == [Yy1]* ]]; then
ip link set "${VM_NET_TAP}" down || true
ip link delete "${VM_NET_TAP}" || true
else
ip link set "${VM_NET_TAP}" down promisc off || true
ip link delete "${VM_NET_TAP}" || true
ip link set dockerbridge down || true
ip link delete dockerbridge || true
fi
}
# ###################################### # ######################################
# Configure Network # Configure Network
# ###################################### # ######################################

View File

@@ -81,6 +81,8 @@ _graceful_shutdown() {
echo && echo " Quitting..." echo && echo " Quitting..."
echo 'quit' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}" >/dev/null 2>&1 || true echo 'quit' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}" >/dev/null 2>&1 || true
closeNetwork
return return
} }

View File

@@ -21,6 +21,7 @@ trap 'error "Status $? while: ${BASH_COMMAND} (line $LINENO/$BASH_LINENO)"' ERR
STORAGE="/storage" STORAGE="/storage"
KERNEL=$(uname -r | cut -b 1) KERNEL=$(uname -r | cut -b 1)
MINOR=$(uname -r | cut -d '.' -f2)
ARCH=$(dpkg --print-architecture) ARCH=$(dpkg --print-architecture)
VERS=$(qemu-system-x86_64 --version | head -n 1 | cut -d '(' -f 1) VERS=$(qemu-system-x86_64 --version | head -n 1 | cut -d '(' -f 1)
@@ -92,7 +93,7 @@ set -m
) )
set +m set +m
if (( KERNEL > 4 )); then if (( KERNEL > 5 )) || ( (( KERNEL == 5 )) && (( MINOR > 10 )) ); then
pidwait -F "${_QEMU_PID}" & wait $! pidwait -F "${_QEMU_PID}" & wait $!
else else
tail --pid "$(cat "${_QEMU_PID}")" --follow /dev/null & wait $! tail --pid "$(cat "${_QEMU_PID}")" --follow /dev/null & wait $!