While upgrading my Kali Linux running on VMware, I encountered this error:
E: You don't have enough free space in /var/cache/apt/archives/.
When I checked my disk space using:
df -h
I found that my /var
partition was almost full, preventing the system from downloading and installing updates.
๐ Investigating the Disk Space
To analyze the situation, I ran:
lsblk
Disk Layout Before Fixing the Issue:
NAME SIZE USED AVAIL MOUNTPOINTS
sda 500G
โโsda1 487M 186M 245M /boot
โโsda2 124.5G
โ โโkalilinux--vg-root 23G 14G 8.3G /
โ โโkalilinux--vg-var 9.3G 7.2G 1.5G /var
โ โโkalilinux--vg-home 89.1G 227M 83G /home
I had already expanded my VMware virtual disk to 500GB, but my LVM partitions hadnโt been extended to use the extra space.
๐ ๏ธ Step-by-Step Solution: Expanding the /var
Partition in LVM
Since my Kali Linux uses LVM (Logical Volume Manager), I had to allocate more space to /var
.
๐ Step 1: Expanding the Virtual Disk in VMware
If you're using VMware, you can increase the disk size:
- Power off your Kali Linux VM.
- Open VMware Workstation/Player.
- Go to VM Settings > Hard Disk > Expand.
- Increase the disk size to 500GB.
- Apply changes & boot into Kali Linux.
After this, the virtual disk (/dev/sda
) now had extra space, but the partitions hadnโt changed yet.
๐ Step 2: Checking Available Space
After booting up Kali, I checked the available space using:
lsblk
Output Before Resizing Partitions:
NAME SIZE USED AVAIL MOUNTPOINTS
sda 500G
โโsda1 487M
โโsda2 124.5G
โ โโkalilinux--vg-root 23G
โ โโkalilinux--vg-var 9.3G
โ โโkalilinux--vg-home 89.1G
โโ Free space 375G (Unused)
I had 375GB of free space that needed to be allocated to /var
.
๐ Step 3: Resizing the Partition (/dev/sda5
) to Use the Free Space
I had to extend /dev/sda5
(the LVM partition) to use the extra 375GB.
-
Open
cfdisk
to edit partitions:
sudo cfdisk /dev/sda
-
Select
/dev/sda2
(Extended Partition). - Choose Resize and extend it to fill the free space.
-
Select
/dev/sda5
inside/dev/sda2
, and resize it to use all available space. - Write changes and exit.
๐จ Important: Reboot the system for changes to take effect:
sudo reboot
๐ Step 4: Expanding LVM to Use the New Space
After rebooting, I had to tell LVM to use the expanded partition.
- Resize the LVM Physical Volume:
sudo pvresize /dev/sda5
- Check how much free space is available in the Volume Group:
sudo vgdisplay
Look for "Free PE / Size", which should now show the extra space.
๐ Step 5: Extending the /var
Logical Volume
Since /var
was running out of space, I extended it:
sudo lvextend -L +30G /dev/mapper/kalilinux--vg-var
Or, to use all available space:
sudo lvextend -l +100%FREE /dev/mapper/kalilinux--vg-var
๐ Step 6: Resizing the /var
Filesystem
Now that the partition was larger, I had to resize the filesystem:
sudo resize2fs /dev/mapper/kalilinux--vg-var
For XFS filesystems, use:
sudo xfs_growfs /var
๐ Step 7: Verify the New Space
To confirm that /var
had more space, I ran:
df -h
Output After Resizing:
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/kalilinux--vg-var 40G 7.2G 32G 20% /var
โ
/var
now had plenty of space for updates!
๐ Step 8: Running the Upgrade Again
Now that /var
had enough space, I retried the upgrade:
sudo apt-get update && sudo apt-get upgrade
This time, the upgrade completed successfully without any storage issues! ๐
๐ Conclusion
If you're running Kali Linux in VMware and get a "Not Enough Free Space in /var" error, follow these steps:
โ Expand the virtual disk in VMware
โ Resize the partitions (/dev/sda5
)
โ Update LVM with pvresize
, lvextend
, and resize2fs
โ Retry the upgrade!
This method works not only for Kali Linux, but for any LVM-based Linux system running in a VM or a physical machine.
If this guide helped you, feel free to share it! ๐๐ฅ
โ๏ธ Author: Khuram Murad
๐ Follow me for more Linux tips!
Top comments (0)