I'm running docker containers on my machine which puts it all in /var/. DF shows that /var/ is 6.9G and no free space. The Linux system is running under VMWare and I've given the server extra 100 GB's in VMWare console. How do I increase "/var" in the linux vm without restarting the the server?
root@TB-IOT02:/var# df -a | grep sda
/dev/sda1 19276020 4530700 13743080 25% /
/dev/sda5 6722700 6706316 0 100% /var
/dev/sda7 1182728 3748 1100852 1% /tmp
/dev/sda8 74238884 65640 70359052 1% /home
root@TB-IOT02:~# fdisk --list
Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0b21c5c6
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 39436287 39434240 18.8G 83 Linux
/dev/sda2 39438334 209713151 170274818 81.2G 5 Extended
/dev/sda5 39438336 53231615 13793280 6.6G 83 Linux
/dev/sda6 53233664 55326719 2093056 1022M 82 Linux swap / Solaris
/dev/sda7 55328768 57798655 2469888 1.2G 83 Linux
/dev/sda8 57800704 209713151 151912448 72.4G 83 Linux
Thanks
Best Answer
Since the server is using traditional partitioning scheme, it is not possible to expand
/var
partition without restarting the server.If I were you, I would create a new file system, and mount it to directory where Docker has its files.
Depending on how you added the space, there are two options:
If you increased size of existing virtual disk 1.1. Use
fdisk
to create/dev/sda9
partition 1.2. Usemke2fs /dev/sda9
to create file systemIf you added a new virtual disk to VM 2.1. Use
fdisk
to create partition on the new device 2.2. Usemke2fs
to create file systemThen, perform these steps:
Run
mount /dev/sda9 /mnt
to mount new file systemStop Docker
Run
mv /var/lib/docker/* /mnt
Run
umount /mnt
Add following line to
/etc/fstab
/dev/sda9 /var/lib/docker ext4 relatime 0 1
Mount new filesystem by executing
mount /var/lib/docker
Start Docker
Replace
/dev/sda9
with the partition name of the added virtual disk in above instructions.After this, Docker files are in the new file system on the added space.