This content originally appeared on DEV Community and was authored by Abhilash Kumar | Oracle ACE
{ Abhilash Kumar Bhattaram : Follow on LinkedIn }
The root filesystem
In Oracle Linux 8 (OEL 8), the root filesystem (/) itself is usually kept lean. But depending on how partitions are laid out, some directories under / can grow large and become major space contributors.
This is probably a cake walk for SRE’s and Sys Admins but for DBA’s and developers this is a struggle.
Why and what contributes to its space increace
I recently had a situation where root was set up tp 20G for a small POC environment and I notes space was filling up , before we get to add space lets understand what root contains , a visual representation below.
/
├── bin → Essential user commands (ls, cp, mv, cat, bash)
├── sbin → System binaries for boot/recovery (fsck, systemctl, init)
├── lib → Shared libraries for /bin & /sbin
├── lib64 → 64-bit shared libraries (mandatory in OEL 8)
├── etc → System config files (fstab, passwd, shadow, systemd)
├── root → Home directory for root user
├── dev → Device files (disks, terminals, /dev/null, /dev/console)
├── proc → Virtual filesystem for kernel & process info
├── sys → Sysfs virtual filesystem (kernel, devices, drivers)
├── tmp → Temporary directory (must exist, 1777 perms)
├── boot* → Kernel, initramfs, GRUB configs (*separate partition common)
│
├── usr (opt) → User apps, libraries, documentation (can be separate FS)
├── var (opt) → Logs, spool, runtime state (can be separate FS)
├── home (opt) → User home directories (can be separate FS)
└── opt (opt) → Add-on application software
My Scenario
In my case I had a situotion as below where root was full in OEL 8. Now I need to identify three things Why What How
- Where is my space increasing ?
- Why is my space increasing ?
- How can I move along from here ?
A representation of my findings are below
### My Filesystems
(base) [root@machine1 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 7.2G 0 7.2G 0% /dev
tmpfs tmpfs 7.3G 0 7.3G 0% /dev/shm
tmpfs tmpfs 7.3G 9.3M 7.3G 1% /run
tmpfs tmpfs 7.3G 0 7.3G 0% /sys/fs/cgroup
/dev/mapper/ol-root xfs 19G 18G 971M 95% /
/dev/mapper/optoracle-optoracle_lv ext4 47G 32G 13G 71% /opt/oracle
/dev/mapper/ol-u01 xfs 431G 20G 411G 5% /u01
/dev/sda2 xfs 1.8G 633M 1.2G 36% /boot
/dev/sda1 vfat 1.9G 7.2M 1.9G 1% /boot/efi
tmpfs tmpfs 1.5G 36K 1.5G 1% /run/user/1000
tmpfs tmpfs 1.5G 4.0K 1.5G 1% /run/user/54321
(base) [root@machine1 ~]#
### Size of each folders under root
(base) [root@machine1 /]# du -csh *
0 bin
595M boot
0 dev
33M etc
630M home
0 lib
0 lib64
0 media
0 mnt
33G opt
0 proc
2.7G root <<<<<<---------- My Core OS files
9.2M run
0 sbin
0 srv
0 sys
4.0K tmp
17G u01
12G usr <<<<<<---------- I had several Python module installs
1.9G var <<<<<<---------- I had several log files
66G total
Where is my space increasing ?
In my case I had a 20G space in root and I used up 12GB in /usr , the reason for this is I have several Python modules installed which is installed in /usr
How is my space increasing ?
There are two main contributors.
a) All my system logging happens in /var , /var/log needs to be controlled.
b) If I keep installing more Python modules in /usr it would continue to grow.
Each Server has its software install needs so we need ot understand and size the root and other filesystems accordingly
How can I move along from here ?
Now we need ot understand from the pic above that root ( / ) is a xfs filesystem so we need to use the xfs methods to increase the space. By default in OEL8 xfs is the root filesystem partition.
How to add space to root filesystem
The following are needed
- Add Physical Disks
- Partition the added disks
- Create physical volume on partitioned disk
- Extend volume group
- Extend the logical volume
- Increase root space with xfs_grow
Step 1. Add Physical Disks
Once Physical Disks are added you should see a new disk added in my case /dev/sdc
(base) [root@machine1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 512G 0 disk
├─sda1 8:1 0 1.9G 0 part /boot/efi
├─sda2 8:2 0 1.9G 0 part /boot
└─sda3 8:3 0 478.7G 0 part
├─ol-root 252:0 0 18.6G 0 lvm /
├─ol-swap 252:1 0 29.8G 0 lvm [SWAP]
└─ol-u01 252:3 0 430.3G 0 lvm /u01
sdb 8:16 0 50G 0 disk
└─optoracle-optoracle_lv 252:2 0 48G 0 lvm /opt/oracle
sdc 8:32 0 20G 0 disk <<<<---- My New Disk
Step 2. Partition the added disks
Partition the disks using fdisk
(base) [root@machine1 ~]# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x6f32448c.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039):
Created a new partition 1 of type 'Linux' and of size 20 GiB.
Command (m for help): p
Disk /dev/sdc: 20 GiB, 21474836480 bytes, 41943040 sectors
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: 0x6f32448c
Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 41943039 41940992 20G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
(base) [root@machine1 ~]#
Step 3. Create physical volume on partitioned disk
Use pvcreate to create the physical volme from the partition
(base) [root@machine1 ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created.
(base) [root@machine1 ~]#
Step 4. Extend volume group
Use vgextend to add the new PV to an existing Volume Group, making the space available to the VG.
(base) [root@machine1 ~]# lvdisplay /dev/mapper/ol-root
--- Logical volume ---
LV Path /dev/ol/root
LV Name root
VG Name ol
LV UUID FjAn25-s3HK-nOHD-awQQ-X3el-TBr3-4uAgYS
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2025-02-23 13:03:44 +0530
LV Status available
# open 1
LV Size <18.63 GiB
Current LE 4769
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 252:0
(base) [root@machine1 ~]# vgextend ol /dev/sdc1
Volume group "ol" successfully extended
Step 5. Extend the logical volume
Use lvextend to allocate the newly available space from the VG to a specific Logical Volume. In mycase I use all available space in the volume to be added
(base) [root@machine1 ~]# lvextend -l +100%FREE /dev/ol/root
Size of logical volume ol/root changed from <18.63 GiB (4769 extents) to <38.63 GiB (9889 extents).
Logical volume ol/root successfully resized.
(base) [root@machine1 ~]#
Step 6. Increase root space with xfs_grow
Since my root is xfs I need to use xfs_grow to grow the root filesystem
(base) [root@machine1 ~]# xfs_growfs -d /
meta-data=/dev/mapper/ol-root isize=512 agcount=4, agsize=1220864 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=0 inobtcount=0
data = bsize=4096 blocks=4883456, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=25600, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 4883456 to 10126336
I can see my root file system in now increased to 40GB ( the 20gb disk was added )
Now lsblk shows sdc1 is added to ol-root
(base) [root@machine1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 512G 0 disk
├─sda1 8:1 0 1.9G 0 part /boot/efi
├─sda2 8:2 0 1.9G 0 part /boot
└─sda3 8:3 0 478.7G 0 part
├─ol-root 252:0 0 38.6G 0 lvm /
├─ol-swap 252:1 0 29.8G 0 lvm [SWAP]
└─ol-u01 252:3 0 430.3G 0 lvm /u01
sdb 8:16 0 50G 0 disk
└─optoracle-optoracle_lv 252:2 0 48G 0 lvm /opt/oracle
sdc 8:32 0 20G 0 disk
└─sdc1 8:33 0 20G 0 part
└─ol-root 252:0 0 38.6G 0 lvm /
(base) [root@machine1 ~]#
This content originally appeared on DEV Community and was authored by Abhilash Kumar | Oracle ACE