Redhat Linux7 버전을 디폴트로 설치하다 보면 생성되어지는 시스템이 xfs 파일시스템 이다.
ext4에 비해 여러면 에서 개선되었다고 하지만 xfs는 확장은 되지만 축소는 되지 않는다고 한다.
안정성을 생각하면 운영되는 서버에 파일시스템을 축소 할일 이 있을지는 모르겠지만 어쨋건 xfs는 확장만 가능한 시스템이다.
축소하려면 백업 후 파일시스템을 재 생성하여 다시 리스토어 하는 방식 밖에 없는 것 같다.
Xfs를 사용하여 파일시스템을 생성, 확장 하여 보자
1. 파티션 생성
1) 디스크 디바이스 확인
[TEST-root] rh70:/root#lsscsi
[0:0:0:0] disk VMware Virtual disk 1.0 /dev/sda
[0:0:1:0] disk VMware Virtual disk 1.0 /dev/sdb
[0:0:2:0] disk VMware Virtual disk 1.0 /dev/sdc
[2:0:0:0] cd/dvd NECVMWar VMware IDE CDR10 1.00 /dev/sr0
-- 새로 붙인 LUN이 /dev/sdc 라고 가정하자
2) 파티션 정보확인
[TEST-root] rh70:/root#fdisk -l /dev/sdc
Disk /dev/sdc: 2147 MB, 2147483648 bytes, 4194304 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: 0x83695c0d
Device Boot Start End Blocks Id System
3) 파티션 생성
[TEST-root] rh70:/root#fdisk /dev/sdc
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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
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): <ENTER>
First sector (2048-4194303, default 2048): <ENTER>
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303): +1024M
Partition 1 of type Linux and of size 1 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): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (2-4, default 2):
First sector (2099200-4194303, default 2099200):
Using default value 2099200
Last sector, +sectors or +size{K,M,G} (2099200-4194303, default 4194303):
Using default value 4194303
Partition 2 of type Linux and of size 1023 MiB is set
Command (m for help): t
Partition number (1,2, default 2): 2
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.
4)파티션 테이블 반영
[TEST-root] rh70:/root#partprobe
5) 파티션 정보보기
[TEST-root] rh70:/root#fdisk -l /dev/sdc
Disk /dev/sdc: 2147 MB, 2147483648 bytes, 4194304 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: 0x83695c0d
Device Boot Start End Blocks Id System
/dev/sdc1 2048 2099199 1048576 8e Linux LVM
/dev/sdc2 2099200 4194303 1047552 8e Linux LVM
2. PV생성
[TEST-root] rh70:/root#pvcreate /dev/sdc1 /dev/sdc2
Physical volume "/dev/sdc1" successfully created
Physical volume "/dev/sdc2" successfully created
3. VG 생성
[TEST-root] rh70:/root#vgcreate -s 4 uservg /dev/sdc1
Volume group "uservg" successfully created
-- vg생성 확인
[TEST-root] rh70:/root#vgs
VG #PV #LV #SN Attr VSize VFree
rhel 2 2 0 wz--n- 49.50g 6.00g
uservg 1 0 0 wz--n- 1020.00m 1020.00m
[TEST-root] rh70:/root#vgdisplay uservg
--- Volume group ---
VG Name uservg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 1020.00 MiB
PE Size 4.00 MiB
Total PE 255
Alloc PE / Size 0 / 0
Free PE / Size 255 / 1020.00 MiB
VG UUID 6btSlf-kaQv-F10J-EOnn-OkDe-0epn-e9bbf8
4. LV생성
[TEST-root] rh70:/root#lvcreate -l 100 -n userlv uservg
WARNING: ext4 signature detected on /dev/uservg/userlv at offset 1080. Wipe it? [y/n] y
Wiping ext4 signature on /dev/uservg/userlv.
Logical volume "userlv" created
[TEST-root] rh70:/root#lvdisplay uservg
--- Logical volume ---
LV Path /dev/uservg/userlv
LV Name userlv
VG Name uservg
LV UUID IarT1r-6chm-feoC-DLd6-64Jv-2Qcz-tDudEn
LV Write Access read/write
LV Creation host, time rh70, 2015-02-13 13:45:11 +0900
LV Status available
# open 0
LV Size 400.00 MiB
Current LE 100
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
[TEST-root] rh70:/root#vgdisplay uservg
--- Volume group ---
VG Name uservg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 1020.00 MiB
PE Size 4.00 MiB
Total PE 255
Alloc PE / Size 100 / 400.00 MiB
Free PE / Size 155 / 620.00 MiB
VG UUID 6btSlf-kaQv-F10J-EOnn-OkDe-0epn-e9bbf8
5. FS생성(XFS) 및 마운트
[TEST-root] rh70:/root#mkfs -t xfs /dev/mapper/uservg-userlv
meta-data=/dev/mapper/uservg-userlv isize=256 agcount=4, agsize=25600 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=102400, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
-- 라인추가
[TEST-root] rh70:/root#vi /etc/fstab
/dev/mapper/uservg-userlv /database xfs defaults 1 2
-- 마운트
[TEST-root] rh70:/root#mount -a
-- 파일시스템 마운트 확인
[TEST-root] rh70:/root# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 40G 7.8G 32G 20% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 80K 1.9G 1% /dev/shm
tmpfs 1.9G 8.8M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 497M 119M 379M 24% /boot
/dev/mapper/uservg-userlv 397M 21M 377M 6% /database
6. FS확장하기
1) LV확장
[TEST-root] rh70:/root# lvextend -l +155 /dev/uservg/userlv
Extending logical volume userlv to 1020.00 MiB
Logical volume userlv successfully resized
2) VG정보 확인
[TEST-root] rh70:/root# vgdisplay uservg
--- Volume group ---
VG Name uservg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 1020.00 MiB
PE Size 4.00 MiB
Total PE 255
Alloc PE / Size 255 / 1020.00 MiB
Free PE / Size 0 / 0
VG UUID 6btSlf-kaQv-F10J-EOnn-OkDe-0epn-e9bbf8
3) FS확장
[TEST-root] rh70:/root# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 40G 7.8G 32G 20% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 80K 1.9G 1% /dev/shm
tmpfs 1.9G 8.8M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 497M 119M 379M 24% /boot
/dev/mapper/uservg-userlv 397M 21M 377M 6% /database
-- 파일시스템 확장하기 이명령이 xfs사용에서 가장 중요한 명령어 인 듯 하다
[TEST-root] rh70:/root# xfs_growfs /database
meta-data=/dev/mapper/uservg-userlv isize=256 agcount=4, agsize=25600 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=102400, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 102400 to 261120
-- 파일시스템 반영 확인
[TEST-root] rh70:/root#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 40G 7.8G 32G 20% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 80K 1.9G 1% /dev/shm
tmpfs 1.9G 8.8M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 497M 119M 379M 24% /boot
/dev/mapper/uservg-userlv 1017M 21M 997M 3% /database
'IT > LINUX' 카테고리의 다른 글
[LINUX][RHEL7] hostname 변경하기 (0) | 2016.12.24 |
---|---|
[LINUX] 리눅스에서 rsync 명령으로 특정 디렉토리를 타 서버에 백업하기 (0) | 2016.12.23 |
[LINUX][RHEL6] 리눅스 서버에 ICMP Ping 패킷 차단하기 (0) | 2016.12.23 |
[LINUX] SELINUX 모드 설정하기 (0) | 2016.12.23 |
[LINUX][RHEL6] GRUB 패스워드 설정하기 (0) | 2016.12.22 |
댓글