-- xfs는 확장은되지만 축소는 되지 않는 파일시스템
-- xfs 확장 # xfs_growfs /마운트포인트
-- ext4 확장 # resize2fs [디바이스명] 100M
# fsadm -e -y resize /dev/datavol/database 500M
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
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): First sector (2048-4194303, default 2048): 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 [TEST-root] rh70:/root#
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
[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# [TEST-root] rh70:/root#vi /etc/fstab [TEST-root] rh70:/root# [TEST-root] rh70:/root#cat /etc/fstab | grep uservg /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
[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
7. 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
[TEST-root] rh70:/root#vgextend uservg /dev/sdc2 Volume group "uservg" successfully extended
[TEST-root] rh70:/root#vgdisplay uservg --- Volume group --- VG Name uservg System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 2 Act PV 2 VG Size 1.99 GiB PE Size 4.00 MiB Total PE 510 Alloc PE / Size 255 / 1020.00 MiB Free PE / Size 255 / 1020.00 MiB VG UUID 6btSlf-kaQv-F10J-EOnn-OkDe-0epn-e9bbf8
8. LV, FS 재확장 1) LV 확장
[TEST-root] rh70:/root#lvextend -l +100%FREE /dev/uservg/userlv Extending logical volume userlv to 1.99 GiB Logical volume userlv successfully resized
[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 1 LV Size 1.99 GiB Current LE 510 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2
2) FS확장 (fsadm 명령사용) [TEST-root] rh70:/root#df -h | grep database /dev/mapper/uservg-userlv 1017M 21M 997M 3% /database
[TEST-root] rh70:/root# fsadm -e -y resize /dev/uservg/userlv meta-data=/dev/mapper/uservg-userlv isize=256 agcount=11, agsize=25600 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 data = bsize=4096 blocks=261120, 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 261120 to 522240
[TEST-root] rh70:/root#df -h | grep database /dev/mapper/uservg-userlv 2.0G 21M 2.0G 2% /database
9. FS축소 하기 1) FS 재생성 -> xfs는 축소가안됨 [TEST-root] rh70:/root#mkfs -t ext4 /dev/uservg/userlv mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 130560 inodes, 522240 blocks 26112 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=534773760 16 block groups 32768 blocks per group, 32768 fragments per group 8160 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912
Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done
2) FS축소 [TEST-root] rh70:/root#e2fsck -f /dev/uservg/userlv e2fsck 1.42.9 (28-Dec-2013) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/uservg/userlv: 11/130560 files (0.0% non-contiguous), 17926/522240 blocks
[TEST-root] rh70:/root#resize2fs /dev/uservg/userlv 100M resize2fs 1.42.9 (28-Dec-2013) Resizing the filesystem on /dev/uservg/userlv to 25600 (4k) blocks. The filesystem on /dev/uservg/userlv is now 25600 blocks long.
[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 66M 1.1M 58M 2% /database
3) LV축소
[TEST-root] rh70:/root#lvreduce -L 100M /dev/uservg/userlv WARNING: Reducing active and open logical volume to 100.00 MiB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce userlv? [y/n]: y Reducing logical volume userlv to 100.00 MiB Logical volume userlv successfully resized
[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 1 LV Size 100.00 MiB Current LE 25 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2
4) VG축소 [TEST-root] rh70:/root#pvmove /dev/sdc2 /dev/sdc1 No data to move for uservg
[TEST-root] rh70:/root#vgreduce uservg /dev/sdc2 Removed "/dev/sdc2" from volume group "uservg"
[TEST-root] rh70:/root#vgdisplay uservg --- Volume group --- VG Name uservg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 11 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 25 / 100.00 MiB Free PE / Size 230 / 920.00 MiB VG UUID 6btSlf-kaQv-F10J-EOnn-OkDe-0epn-e9bbf8
10. VG삭제 [TEST-root] rh70:/root#lvremove /dev/uservg/userlv Do you really want to remove active logical volume userlv? [y/n]: y Logical volume "userlv" successfully removed [TEST-root] rh70:/root#vgremove uservg Volume group "uservg" successfully removed [TEST-root] rh70:/root# [TEST-root] rh70:/root#lvs LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert root rhel -wi-ao---- 39.62g swap rhel -wi-ao---- 3.89g [TEST-root] rh70:/root#pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel lvm2 a-- 39.51g 0 /dev/sdb rhel lvm2 a-- 10.00g 6.00g /dev/sdc1 lvm2 a-- 1.00g 1.00g /dev/sdc2 lvm2 a-- 1023.00m 1023.00m |
댓글