1. fdisk 명령을 이용한 디스크 파티션 구성
]# fdisk -l
Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 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/sda: 64.4 GB, 64424509440 bytes, 125829120 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: 0x000a3166
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1173503 585728 83 Linux
/dev/sda2 1173504 98838527 48832512 8e Linux LVM
/dev/sda3 98838528 114475007 7818240 8e Linux LVM
Disk /dev/mapper/vg_root_lv_root-root00: 50.0 GB, 49996103680 bytes, 97648640 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/vg_root_lv_swap-swap: 8002 MB, 8002732032 bytes, 15630336 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
]# 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 0x3c5ba26b.
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): 1
First sector (2048-10485759, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759): +5G
Value out of range.
Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759):
Using default value 10485759
Partition 1 of type Linux and of size 5 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'
]# fdisk -l <== 파티션 생성 확인
Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 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: 0x3c5ba26b
Device Boot Start End Blocks Id System
/dev/sdb1 2048 10485759 5241856 8e Linux LVM
Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 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: 0x000a3166
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1173503 585728 83 Linux
/dev/sda2 1173504 98838527 48832512 8e Linux LVM
/dev/sda3 98838528 114475007 7818240 8e Linux LVM
Disk /dev/mapper/vg_root_lv_root-root00: 50.0 GB, 49996103680 bytes, 97648640 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/vg_root_lv_swap-swap: 8002 MB, 8002732032 bytes, 15630336 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
2. PV 생성
]# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name vg_root_lv_swap
PV Size 7.46 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 1908
Free PE 0
Allocated PE 1908
PV UUID GFXFg4-Uh4S-09EA-xXnk-SSBJ-HMH4-Zy994C
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_root_lv_root
PV Size 46.57 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 11921
Free PE 1
Allocated PE 11920
PV UUID N6mWCm-9oFi-tbKv-8KSH-2g0Q-fO0F-OwN0FU
]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
]# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name vg_root_lv_swap
PV Size 7.46 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 1908
Free PE 0
Allocated PE 1908
PV UUID GFXFg4-Uh4S-09EA-xXnk-SSBJ-HMH4-Zy994C
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_root_lv_root
PV Size 46.57 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 11921
Free PE 1
Allocated PE 11920
PV UUID N6mWCm-9oFi-tbKv-8KSH-2g0Q-fO0F-OwN0FU
"/dev/sdb1" is a new physical volume of "5.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 5.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID y5ifZE-GdmP-6T4r-dtDk-wP3c-byVd-AfYcAj
]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_root_lv_root lvm2 a-- 46.57g 4.00m
/dev/sda3 vg_root_lv_swap lvm2 a-- 7.45g 0
/dev/sdb1 lvm2 --- 5.00g 5.00g
3. VG 생성
]# vgdisplay
--- Volume group ---
VG Name vg_root_lv_swap
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 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 7.45 GiB
PE Size 4.00 MiB
Total PE 1908
Alloc PE / Size 1908 / 7.45 GiB
Free PE / Size 0 / 0
VG UUID Q6ZQrg-41tr-MqyP-fqWe-MkWi-v0kr-5R4uyr
--- Volume group ---
VG Name vg_root_lv_root
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 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 46.57 GiB
PE Size 4.00 MiB
Total PE 11921
Alloc PE / Size 11920 / 46.56 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID e1Th4d-7Vo7-XtzK-YgJn-iz38-qtp2-4SFeya
]# vgcreate vg_data_lv_data /dev/sdb1
Volume group "vg_data_lv_data" successfully created
]#
]# vgdisplay
--- Volume group ---
VG Name vg_root_lv_swap
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 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 7.45 GiB
PE Size 4.00 MiB
Total PE 1908
Alloc PE / Size 1908 / 7.45 GiB
Free PE / Size 0 / 0
VG UUID Q6ZQrg-41tr-MqyP-fqWe-MkWi-v0kr-5R4uyr
--- Volume group ---
VG Name vg_root_lv_root
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 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 46.57 GiB
PE Size 4.00 MiB
Total PE 11921
Alloc PE / Size 11920 / 46.56 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID e1Th4d-7Vo7-XtzK-YgJn-iz38-qtp2-4SFeya
--- Volume group ---
VG Name vg_data_lv_data
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 5.00 GiB
PE Size 4.00 MiB
Total PE 1279
Alloc PE / Size 0 / 0
Free PE / Size 1279 / 5.00 GiB
VG UUID ckAcyg-JoX3-iMTD-hk7T-v4Y8-vvck-dvbHKf
4. LV 생성
]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_root_lv_swap/swap
LV Name swap
VG Name vg_root_lv_swap
LV UUID CUhLW3-LvJk-dxNY-5cfc-dr18-yvYR-2aor3F
LV Write Access read/write
LV Creation host, time localhost, 2016-02-05 13:26:24 +0900
LV Status available
# open 2
LV Size 7.45 GiB
Current LE 1908
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/vg_root_lv_root/root00
LV Name root00
VG Name vg_root_lv_root
LV UUID XHxbGI-fsv1-BCOR-aWzK-3Tps-Uj0f-nGxH6A
LV Write Access read/write
LV Creation host, time localhost, 2016-02-05 13:26:22 +0900
LV Status available
# open 1
LV Size 46.56 GiB
Current LE 11920
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
]# lvcreate -L 2G -n data1 vg_data_lv_data
]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_root_lv_swap/swap
LV Name swap
VG Name vg_root_lv_swap
LV UUID CUhLW3-LvJk-dxNY-5cfc-dr18-yvYR-2aor3F
LV Write Access read/write
LV Creation host, time localhost, 2016-02-05 13:26:24 +0900
LV Status available
# open 2
LV Size 7.45 GiB
Current LE 1908
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/vg_root_lv_root/root00
LV Name root00
VG Name vg_root_lv_root
LV UUID XHxbGI-fsv1-BCOR-aWzK-3Tps-Uj0f-nGxH6A
LV Write Access read/write
LV Creation host, time localhost, 2016-02-05 13:26:22 +0900
LV Status available
# open 1
LV Size 46.56 GiB
Current LE 11920
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_data_lv_data/data1
LV Name data1
VG Name vg_data_lv_data
LV UUID 8okrS1-xJdF-lD18-s2b1-x8yc-5NVm-v2dhjT
LV Write Access read/write
LV Creation host, time SCIDNS2, 2016-02-15 14:18:32 +0900
LV Status available
# open 0
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
]# mkfs.ext4 /dev/vg_data_lv_data/data1
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
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
5. 마운트
]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Feb 5 04:26:24 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_root_lv_root-root00 / xfs defaults 0 0
UUID=43594df6-3372-4152-9bca-fe51ece6bbfe /boot xfs defaults 0 0
/dev/mapper/vg_root_lv_swap-swap swap swap defaults 0 0
/dev/vg_data_lv_data/data1 /data ext4 defaults 0 0
]# mount -a
]#
]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_root_lv_root-root00 xfs 47G 4.3G 43G 10% /
devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs tmpfs 2.0G 84K 2.0G 1% /dev/shm
tmpfs tmpfs 2.0G 8.8M 2.0G 1% /run
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 xfs 569M 110M 459M 20% /boot
tmpfs tmpfs 2.0G 8.8M 2.0G 1% /var/named/chroot/run/named
/dev/mapper/vg_data_lv_data-data1 ext4 2.0G 6.0M 1.8G 1% /data
6. 디스크 용량 확장
]# 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.
Command (m for help): p
Disk /dev/sdb: 6442 MB, 6442450944 bytes, 12582912 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: 0x3c5ba26b
Device Boot Start End Blocks Id System
/dev/sdb1 2048 10485759 5241856 8e Linux LVM
Command (m for help): n <==== sdb2 신규 생성
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (2-4, default 2):
First sector (10485760-12582911, default 10485760):
Using default value 10485760
Last sector, +sectors or +size{K,M,G} (10485760-12582911, default 12582911):
Using default value 12582911
Partition 2 of type Linux and of size 1 GiB is set
Command (m for help): p
Disk /dev/sdb: 6442 MB, 6442450944 bytes, 12582912 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: 0x3c5ba26b
Device Boot Start End Blocks Id System
/dev/sdb1 2048 10485759 5241856 8e Linux LVM
/dev/sdb2 10485760 12582911 1048576 83 Linux
Command (m for help): t
Partition number (1,2, default 2):
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/sdb: 6442 MB, 6442450944 bytes, 12582912 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: 0x3c5ba26b
Device Boot Start End Blocks Id System
/dev/sdb1 2048 10485759 5241856 8e Linux LVM
/dev/sdb2 10485760 12582911 1048576 8e Linux LVM
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: Device or resource busy.
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.
]#
]#
]#
]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_root_lv_root lvm2 a-- 46.57g 4.00m
/dev/sda3 vg_root_lv_swap lvm2 a-- 7.45g 0
/dev/sdb1 vg_data_lv_data lvm2 a-- 5.00g 0
]# pvcreate /dev/sdb2
Device /dev/sdb2 not found (or ignored by filtering).
]# partprobe <== 파티션 재검색
]#
]#
]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_root_lv_root lvm2 a-- 46.57g 4.00m
/dev/sda3 vg_root_lv_swap lvm2 a-- 7.45g 0
/dev/sdb1 vg_data_lv_data lvm2 a-- 5.00g 0
]# pvcreate /dev/sdb2 << === PV 신규 생성
Physical volume "/dev/sdb2" successfully created
]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_root_lv_root lvm2 a-- 46.57g 4.00m
/dev/sda3 vg_root_lv_swap lvm2 a-- 7.45g 0
/dev/sdb1 vg_data_lv_data lvm2 a-- 5.00g 0
/dev/sdb2 lvm2 --- 1.00g 1.00
]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_data_lv_data 1 1 0 wz--n- 5.00g 0
vg_root_lv_root 1 1 0 wz--n- 46.57g 4.00m
vg_root_lv_swap 1 1 0 wz--n- 7.45g 0
7. VG 확장
]# vgextend vg_data_lv_data /dev/sdb2
Volume group "vg_data_lv_data" successfully extended
8. LV 확장
]# lvextend -L +1020m /dev/vg_data_lv_data/data1 -r
Size of logical volume vg_data_lv_data/data1 changed from 5.00 GiB (1279 extents) to 5.99 GiB (1534 extents).
Logical volume data1 successfully resized
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mapper/vg_data_lv_data-data1 is mounted on /data; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mapper/vg_data_lv_data-data1 is now 1570816 blocks long.
'Operating System' 카테고리의 다른 글
캐시 메모리 교체 알고리즘의 종류 (0) | 2022.10.23 |
---|---|
SSH 패스워드 없이 로그인하기 (0) | 2022.10.21 |
댓글