How to Extend the Root Partition in Linux
It is not uncommon for the root partition to suddenly become full on Linux. It becomes impossible to install updates and programs, the system begins to produce errors and is unstable. The task seems difficult, especially for beginners, but with a careful approach everything can be solved — below we will figure out how to proceed.
What is the root partition and why is it full?
The root partition (/) is where the system lives: it contains Linux files, installed applications, configurations, and sometimes user data if the /home directory is not located separately.
Space on / can go away for various reasons: you install a lot of programs, large logs and temporary files accumulate, and databases or development tools by default put data directly in the root. When free space runs out, the system starts to act weird, so expanding the partition is an easy way to get it back to normal.
Where to start: checking where the space was missing
First, look at the current disk loading:
df -h
You will see a pivot table. Example: the root is almost full — “Use%: 90%”.
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 20G 18G 2G 90%
tmpfs 2.0G 1.2M 2.0G 1%
Next, examine the disk layout:
fdisk -l<
Example output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 20G 0 part /
├─sda2 8:2 0 10G 0 part /home
└─sda3 8:3 0 20G 0 part
Here root is only 20 GB, /home is 10 GB. Sometimes you can use unallocated space or shrink an adjacent section.
Important Step: Backup
Before any operations with partitions, be sure to backup important data. Errors at the markup change stage are a common cause of losses. rsync (or any tool you are familiar with) will do:
rsync -av --progress / /path/to/backup/
Ways to expand the root partition
The approach depends on how the storage is configured on your server or PC.
Method 1. GParted (useful with Live-USB)
If you have access to a desktop or Live media, the easiest way is GParted.
- Boot from Live-USB/CD. The mounted root partition cannot be changed, so we work from a “live” system.
- Open GParted and look at the list of partitions.
- Find the root partition /, check if there is unallocated space nearby. Right click → Resize/Move.
- Apply the changes (check mark/button Apply) and wait until the operation is completed.
After rebooting, return to the normal system and make sure that the size has increased:
df -h
Method 2. LVM (flexibly and without rebooting into Live mode)
If the root is in LVM (this is often the case in Ubuntu, RHEL, CentOS, etc.), expanding it is more convenient and safer: Live media is not needed.
First check if the root is actually an LVM logical volume:
lsblk
Possible option:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
└─sda2 8:2 0 50G 0 part
├─vg_root-lv_root 253:0 0 20G 0 lvm /
└─vg_root-lv_home 253:1 0 30G 0 lvm /home
If there is free space in the volume group, expand the logical volume:
sudo lvextend -L +10G /dev/vg_root/lv_root
Here +10G — add 10 GB to the root (substitute your path to that).
Then expand the filesystem:
sudo resize2fs /dev/vg_root/lv_root # for ext3/ext4
sudo xfs_growfs / # for XFS (specify the mount point)
And check the size again:
df -h
Method 3. Shrink the adjacent partition and give space to the root
If there is no LVM, and there is no free space left next to /, you can slightly reduce, for example, /home, to free up space.
The algorithm is like this:
— make a backup copy of important data from /home;
— boot from Live-USB so that the partitions are not mounted;
— via GParted, reduce /home, an unallocated area will appear;
— carefully “move” the root partition into the vacated zone and enlarge it;
— Extend the file system.
This path is technically more difficult and riskier: if possible, LVM or already free space next to / is preferable.
Total
Lack of space on the root partition is an unpleasant situation, but it can be solved. For desktops and laptops, the friendliest option is GParted with Live-USB. If you have LVM, you have the most flexible tool in your hands: extensions can be done on the fly. In any scenario, do not forget about backup and carefully check which sections you change — this will save nerves and data.
CONTENT:
Similar
Похожее
Все новости
Adaxa Suite: подробный обзор ERP-системы корпоративного класса
Adaxa Suite — комплексная ERP-платформа для компаний, которым уже тесно в рамках простых учётных систем, но которые при этом не готовы идти в сторону дорогих корпоративных решений уровня SAP или Oracle. Изначально продукт создавался для среднего бизнеса, которому нужна большой набор функций, сквозная автоматизация процессов и надёжная архитектура без чрезмерной стоимости владения. Архитектура и техническая […]
Как заказать дополнительные IP-адреса на UFO.Hosting: пошаговая инструкция
По мере роста проекта одного IP-адреса может стать недостаточно. Это типичная ситуация для компаний, которые масштабируют инфраструктуру, запускают новые сервисы или разделяют внутренние процессы. В UFO.Hosting подключение дополнительных IP-адресов выполняется через биллинговую панель и занимает всего несколько минут. Важно: возможность для заказа дополнительных IP-адресов доступна для тарифов VPS начиная с Haedus. Зачем нужны дополнительные IP-адреса […]