Open Jean-Baptiste-Lasselle opened 10 months ago
Plan:
we unmount the /dev/sdb1
disk partition mounted on /var/lib/pokus/docker
Shell script (TOCOMPLETE):
# --- # --- # --- # --- # ---
# --- # --- # ---
# First we stop the docker daemon
sudo systemctl stop docker
sudo systemctl stop docker.socket
sudo systemctl disable docker
sudo systemctl daemon-reload
docker ps -a || true
# --- # --- # --- # --- # ---
# --- # --- # --- now shutdown VM, add the new virtual disk, and restart the VM
# --- # --- # --- # --- # ---
# --- # --- # --- # --- # ---
# --- # --- # --- now let's start the disk operations
# unmount the /dev/sdb1 disk partition mounted on /var/lib/pokus/docker
# sudo umount /var/lib/pokus/docker
sudo umount /dev/sdb1
sudo mkdir -p /var/lib/pokus/docker_backup
sudo mount /dev/sdb1 /var/lib/pokus/docker_backup
sudo df -h /var/lib/pokus/docker
sudo df -h /var/lib/pokus/docker_backup
sudo fdisk -l
# ---
# partition the new disk into ext4: with fdisk its not so easy to run the command silently
# sudo fdisk /dev/sdc1
# sudo mkfs -t ext4 /dev/sdc1
export NEW_DISK_PARTITION_UUID=69a924f3-af50-4ddb-a65d-67454bbc1b79
cat <<EOF >./.etc.fstab.addon
UUID=${NEW_DISK_PARTITION_UUID} /var/lib/pokus/docker ext4 defaults 0 0
EOF
# ---
# And I will use the previous disk partition as a data disk space on /opt/engineering/data
sudo mkdir -p /opt/engineering/data
export TWENTY_GB_DISK_PARTITION_UUID=69a924f3-af50-4ddb-a65d-67454bbc1b79
cat <<EOF >./.etc.fstab.addon
UUID=${NEW_DISK_PARTITION_UUID} /opt/engineering/data ext4 defaults 0 0
EOF
# --- # --- # ---
# then you copy all docker data from the old partition, to the new partition
sudo cp -fR /opt/engineering/data/* /var/lib/pokus/docker
# --- # --- # ---
# then to clean up space
sudo rm -fr /opt/engineering/data/overlay
# --- # --- # --- # --- # ---
# --- # --- # ---
# Finally we re-enable the docker daemon
sudo systemctl enable docker
sudo systemctl sart docker.socket
sudo systemctl start docker
sudo systemctl daemon-reload
Hm, attends, la partition de 20GB je pourrais la monter sur un sous répertoire celui qui s'appelle containers là ci-dessous, ça pourrait peut-être aider :
mouais pas vraiment, c'est réellement le /var/lib/pokus/docker/overlay2
qui utilise 18GB
, alors que /var/lib/pokus/docker
utilise quasiment le même espace, les autres répertoire tous cumulés utilisent mois d'un GB:
sudo fdisk -l
# ---
# interactive, you type first "n" for new, then 2 or3 times just
# hit enter to let the default values, which will create one
# single partition on the whole /dev/sdc disk
# -
#
sudo fdisk /dev/sdc
sudo mkfs -t ext4 /dev/sdc1 | tee ./dev.sdc1.ext4.format.logs
export NEW_DISK_PARTITION_UUID=$(cat ./dev.sdc1.ext4.format.logs | grep 'Filesystem UUID:' | awk '{ print $NF }')
sudo mkdir -p /var/lib/pokus2/docker
export NEW_DISK_PARTITION_UUID=200e736d-7065-4b05-9495-6cc3d3daa92b
cat <<EOF >./.etc.fstab.addon
UUID=${NEW_DISK_PARTITION_UUID} /var/lib/pokus2/docker ext4 defaults 0 0
EOF
cat ./.etc.fstab.addon | sudo tee -a /etc/fstab
# ---
# then reboot to automatically mount the new disk on [/var/lib/pokus2/docker]
# -
#
# ---
# Now copy all files from the currently
# docker daemon [data-root] directory, to
# the new /var/lib/pokus2/docker
# -
#
sudo cp -rT /var/lib/pokus/docker /var/lib/pokus2/docker
cat <<EOF >./etc.docker.daemon.json
{
"data-root": "/var/lib/pokus2/docker"
}
EOF
sudo cp /etc/docker/daemon.json /etc/docker/previous.daemon.json
cat ./etc.docker.daemon.json | sudo tee /etc/docker/daemon.json
# --- # --- # --- # --- # ---
# --- # --- # ---
# We re-enable the docker daemon
sudo systemctl enable docker
sudo systemctl start docker.socket
sudo systemctl start docker
sudo systemctl daemon-reload
# --- # --- # ---
# Finally we reboot the VM
This taks is about :
Basically:
bullseye,
there should be no problem forbookworm
) : with only one disk one partition for all/dev/sdb1
, if my disk device is named/dev/sdb
), and mount on/var/lib/pokus/docker
(I before, of coursemkdir -p /var/lib/pokus/docker
)