Managing RHEL Linux System Using the /var Directory

Understanding the Linux file system is a fundamental part of managing a RHEL (Red Hat Enterprise Linux) system.

One directory that plays a vital role in system management is the /var directory. This post will delve into what the /var directory is, its importance, and how it can be managed effectively in a RHEL system.

svc directory <– guide

Understanding the /var Directory

In a Linux system, the /var directory is where variable data information that is expected to grow over time is stored.

This includes system logs, databases, websites, and email, among other things.

The Importance of the /var Directory in System Management

The data stored in the /var directory is crucial for monitoring system performance and troubleshooting issues. For instance, system logs (/var/log) can provide valuable information about system operations and any errors that may occur.


/var 디렉터리를 위해서 언급한 듯이 따로 분리해서 관리할려고 합니다.

초반에는 로그의 용량이 크지 않기 때문에 10GB 디스크를 추가하였습니다.

제 시스템 상에는 /dev/nvme0n2로 확인이 됩니다.

# fdisk -l 
새로운 10기가 디스크 추가

물리적인 스토리지 장치(/dev/nvme0n2)를 LVM 시스템의 일부로 만들기 위해 사용하며

pvcreate /dev/nvme0n2 명령을 실행하면, ‘/dev/nvme0n2’ 장치는 LVM에 의해 관리되는 PV(Physical Volume)가 됩니다.

vgextend rhel /dev/nvme0n2 명령을 실행하면, ‘/dev/nvme0n2’ PV가 ‘rhel’이라는 VG에 추가되어, ‘rhel’ VG(Volume Group)의 총 용량이 증가합니다.

추가적인 설명은 여기를 클릭해주세요.ㅊ

# pvcreate /dev/nvme0n2
# vgextend rhel /dev/nvme0n2

lvcreate 명령어는 LVM(Logical Volume Manager)에서 논리 볼륨을 생성하는 명령어

  • -n 옵션은 논리 볼륨의 이름을 지정합니다.
  • -1은 논리 볼륨의 크기를 MB 단위로 지정합니다.
  • +100%FREE는 현재 사용 가능한 여유 공간을 모두 사용하여 논리 볼륨을 생성합니다.
  • rhel은 생성할 논리 볼륨이 위치할 물리적 볼륨 그룹(PVG)의 이름
# lvcreate -n var -1 +100%FREE rhel
lvcreate 명령어는 LVM(Logical Volume Manager)에서 논리 볼륨을 생성하는 명령어

ext4 파일 시스템을 생성

# mkfs -t ext4 /dev/mapper/rhel-var
ext4 파일 시스템을 생성

임시 마운트 포인트 생성 -> 임시 마운트 포인트에 새 디스크 마운트 -> 기존의 /var 디렉터리 내용 복사

-> 새 디스크를 /var에 마운트 -> 부팅 시 자동 마운트 설정

# mkdir /mnt/newvar 
# mount /dev/mapper/rhel-var /mnt/newvar
# cp -a /var/* /mnt/newvar/
# mv /var /var.old
# mkdir /var
# mount /dev/sdb1 /var

# echo "/dev/mapper/rhel-var /var ext4 defaults 0 0" | sudo tee -a /etc/fstab
임시 마운트 포인트 생성 -> 임시 마운트 포인트에 새 디스크 마운트 -> 기존의 /var 디렉터리 내용 복사
-> 새 디스크를 /var에 마운트 -> 부팅 시 자동 마운트 설정

자동 마운트까지 설정 하시면 아래 df 명령어로 정상적으로 표기가 됩니다.

/var 디렉터리 디스크 마운트

By Low ahn

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다