728x90
반응형

 

  • cannot create temp file for here-document: 장치에 남은 공간이 없음 에러가 발생할 경우 
  • 리눅스 용량 부족시 디스크 추가하는 방법에 대해 정리합니다. 

 => cannot create temp file for here-document: 장치에 남은 공간이 없음

현재 디스크 사용량 확인 

  • df -Th 명령을 통해 현재 사용중인 디스크 사용량을 확인합니다. 
[root@mysvr:/root]$ df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
devtmpfs                devtmpfs  1.9G     0  1.9G   0% /dev
tmpfs                   tmpfs     1.9G     0  1.9G   0% /dev/shm
tmpfs                   tmpfs     1.9G   13M  1.9G   1% /run
tmpfs                   tmpfs     1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root xfs       6.0G  6.0G  3.5M 100% /
/dev/sda1               xfs      1014M  185M  830M  19% /boot
/dev/mapper/centos-home ext2       25G  8.9G   15G  38% /home
tmpfs                   tmpfs     378M  8.0K  378M   1% /run/user/42
tmpfs                   tmpfs     378M     0  378M   0% /run/user/0

 

  • lvdisplay 확인 
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                cwMNqw-gJSs-7nDO-GrRU-bgxE-FLB5-7acfhK
  LV Write Access        read/write
  LV Creation host, time localhost, 2023-03-09 07:40:48 +0900
  LV Status              available
  # open                 2
  LV Size                8.00 GiB
  Current LE             2048
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                kRPPw7-Ffr2-Bf20-CsE9-UDkt-aCdO-Y4DvFo
  LV Write Access        read/write
  LV Creation host, time localhost, 2023-03-09 07:40:48 +0900
  LV Status              available
  # open                 1
  LV Size                <6.00 GiB
  Current LE             1535
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

 

디스크 추가 

  • fdisk -l 을 통해 추가한 disk 정보를 확인 합니다. 
  • 용량 증설을 위해 hdd 를 20G 추가 했습니다. 

 

  • 추가한 디스크에 대해 파티션을 생성 합니다. 
  • fdisk /dev/sdb
[root@mysvr:/root]$ fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

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
Building a new DOS disklabel with disk identifier 0x8135267e.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048): =>엔터
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): =>엔터
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

 

  • 파티셔닝한 디스크 /dev/sdb1 를 Physical Volume 생성 한다.
  • pvscan 이나 pvdisplay 명령을 통해 pysical volume 정보를 확인 한다. 
pvcreate  /dev/sdb1
pvscan
pvdisplay

 

  • vgextend 명령을 통해 centos 볼륨 그룹에 새로 추가한 pysical volume 를 확장 한다.
vgextend centos /dev/sdb1

 

  • lvextend 명령을 통해 부족했던 lvm 을 확장 합니다. 
lvextend /dev/mapper/centos-root -l +100%FREE

 

  • pvscan 명령을 통해 centos 으로 pv 가 추가 되었는지 확인 한다.

 

  • xfs_growfs 명령을 통해 논리 볼륨을 resizing 한다. 
    • ext4  포멧일 경울 resize2fs /dev/mapper/centos-root 수행 합니다. 
    • xfs type 에 대해  resize2fs 명령을 수행 하면 아래 처럼 에러가 발생함.

[root@mysvr:/root]$ resize2fs /dev/mapper/centos-root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root
Couldn't find valid filesystem superblock.
[root@mysvr:/root]$ blkid /dev/mapper/centos-root
/dev/mapper/centos-root: UUID="f4704f6c-5120-4c0f-b46b-7a0c31f390e5" TYPE="xfs" 

 

  • xfs_growfs 를 수행 하지 않으면 용량 증설이 되지 않는다.
xfs_growfs /dev/mapper/centos-root

 

  • df -Th 명령을 통해 용량이 증설 되었는지 확인 
  • 6G 에서 20G 로 용량이 증설 된것을 확인 할수 있다.

 

 

728x90
반응형

+ Recent posts