티스토리 뷰

OS/CentOS

파티션 SIZE 늘리기

pu928 2017. 11. 16. 00:24
반응형

 

여기, 여기에서 참고

 

CentOS 7에서 진행

 

- 현재 정보

[root@localhost]# fdisk -l

 

Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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

Disk label type: dos

Disk identifier: 0x000ad9af

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048     2099199     1048576   83  Linux

/dev/sda2         2099200    33554431    15727616   83  Linux

 

Disk /dev/mapper/cl-root: 6652 MB, 6652166144 bytes, 12992512 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

 

 

Disk /dev/mapper/cl-swap: 859 MB, 859832320 bytes, 1679360 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

 

- 파티션 제거 및 생성으로 Size 추가(데이터가 제거되지 않으나 혹시 모르니 실린더 Start 번호를 확인한다.)

[root@test-linux ~]# fdisk /dev/sda

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.

 

 

Command (m for help): p

 

Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 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

Disk label type: dos

Disk identifier: 0x0006b583

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048     2099199     1048576   83  Linux

/dev/sda2         2099200    16777215     7339008   8e  Linux LVM

 

Command (m for help): d

Partition number (1,2, default 2): 2

Partition 2 is deleted

 

Command (m for help): n

Partition type:

   p   primary (1 primary, 0 extended, 3 free)

   e   extended

Select (default p): p

Partition number (2-4, default 2): 2

First sector (2099200-33554431, default 2099200): 

Using default value 2099200

Last sector, +sectors or +size (2099200-33554431, default 33554431): 

Using default value 33554431

Partition 2 of type Linux and of size 15 GiB is set

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

 

WARNING: Re-reading the partition table failed with error 16: 장치나 자원이 동작 중.

The kernel still uses the old table. The new table will be used at

the next reboot or after you run partprobe(8) or kpartx(8)

Syncing disks.

 

- 재부팅 후 진행하라고 하니 재부팅

[root@test-linux ~]# reboot

-- 재부팅 후 --

 

- PV Resize

[root@localhost]# pvresize /dev/sda2    <-- volume resize

  Physical volume "/dev/sda2" changed

  1 physical volume(s) resized / 0 physical volume(s) not resized

 

- PV 확인

[root@localhost]# pvscan    <-- volume check

  PV /dev/sda2   VG cl              lvm2 [<15.00 GiB / 8.00 GiB free]

  Total: 1 [<15.00 GiB] / in use: 1 [<15.00 GiB] / in no VG: 0 [0   ]

 

- LV 확장

[root@localhost]# lvextend -l +100%FREE /dev/mapper/cl-root    <-- volume extend

  Size of logical volume cl/root changed from <6.20 GiB (1586 extents) to <14.20 GiB (3634 extents).

  Logical volume cl/root successfully resized.

 

- 파티션 확장

xfs 의 경우 xfs_growfs을 사용하고 이 외의 경우에는 resize2fs 를 사용한다.

[root@localhost]# resize2fs /dev/mapper/cl-root    <-- CentOS7에서는 파일 시스템이 xfs라서 아래의 명령으로 진행

resize2fs 1.42.9 (28-Dec-2013)

resize2fs: Bad magic number in super-block while trying to open /dev/mapper/cl-root

Couldn't find valid filesystem superblock.

 

[root@localhost]# xfs_growfs /dev/mapper/cl-root

meta-data=/dev/mapper/cl-root    isize=512    agcount=4, agsize=406016 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=0 spinodes=0

data     =                       bsize=4096   blocks=1624064, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=1

log      =internal               bsize=4096   blocks=2560, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

data blocks changed from 1624064 to 3721216

 

- 파티션 확인

[root@localhost]# df -k

Filesystem          1K-blocks    Used Available Use% Mounted on

/dev/mapper/cl-root  14874624 6472764   8401860  44% /

devtmpfs               930700       0    930700   0% /dev

tmpfs                  941580       0    941580   0% /dev/shm

tmpfs                  941580    8468    933112   1% /run

tmpfs                  941580       0    941580   0% /sys/fs/cgroup

/dev/sda1             1038336  188668    849668  19% /boot

tmpfs                  188320       0    188320   0% /run/user/10000

 

반응형

'OS > CentOS' 카테고리의 다른 글

CentOS 4.8에서 yum 사용하기  (0) 2018.07.31
CentOS 7 에서 libtermcap.so.2가 없는 경우  (0) 2018.05.02
network service start error - Failed to start LSB  (0) 2018.02.20
sudo에 user 등록  (0) 2017.01.05
Hostname 변경  (0) 2017.01.05
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함