LVM 마운트 하는 방법에 대해서 알아보자
[root@i-955-6459-VM ~]# fdisk -l
Disk /dev/xvdb: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/xvdb doesn’t contain a valid partition table
Disk /dev/xvda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 13 104391 83 Linux
/dev/xvda2 14 2610 20860402+ 8e Linux LVM
요렇게 확인해볼 수 있다.
[root@i-955-6459-VM ~]# ls /dev/xv*
/dev/xvc0 /dev/xvda /dev/xvda1 /dev/xvda2 /dev/xvdb
fdisk를 이용해 /dev/xvdb에 파티션을 생성해준다. (80GB 통으로 잡았고, 밑줄친 부분이 입력한 부분)
[root@i-955-6459-VM ~]# fdisk /dev/xvdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won’t be recoverable.
The number of cylinders for this disk is set to 10443.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): p
Disk /dev/xvdb: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-10443, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-10443, default 10443):
Using default value 10443
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e ==> VG, LV를 사용하려면 반드시 ‘8e’ Linux LVM 타입을 선택!
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
잘 됐는지 확인.
[root@i-955-6459-VM ~]# fdisk -l
Disk /dev/xvdb: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvdb1 1 10443 83883366 8e Linux LVM
Disk /dev/xvda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 13 104391 83 Linux
/dev/xvda2 14 2610 20860402+ 8e Linux LVM
PV 생성.
[root@i-955-6459-VM ~]# pvcreate /dev/xvdb1
Physical volume “/dev/xvdb1” successfully created
VG 생성: VG이름을 “DataVG”로 주었다.
[root@i-955-6459-VM ~]# vgcreate DataVG /dev/xvdb1
Volume group “DataVG” successfully created
VG 정보 보기.
[root@i-955-6459-VM ~]# vgdisplay
— Volume group —
VG Name DataVG
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 80.00 GB
PE Size 4.00 MB
Total PE 20479
Alloc PE / Size 0 / 0
Free PE / Size 20479 / 80.00 GB
VG UUID 1Lgw05-rK7Y-t6M4-gm6v-Po6Y-Nktn-oScFfW
— Volume group —
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 19.88 GB
PE Size 32.00 MB
Total PE 636
Alloc PE / Size 636 / 19.88 GB
Free PE / Size 0 / 0
VG UUID 5UlLWB-skhS-kYkE-hg3U-TYW7-wgQ0-hfcsJ4
위 참고 사이트에서 PE 크기가 어쩌고 하는 내용이 있다. PE 크기를 16MB로 변경해보자. vgremove 후 다시 vgcreate하면 된다.(이 부분은 좀 더 공부하자.)
[root@i-955-6459-VM ~]# vgremove DataVG
Volume group “DataVG” successfully removed
[root@i-955-6459-VM ~]# vgcreate -s 16m DataVG /dev/xvdb1
Volume group “DataVG” successfully created
[root@i-955-6459-VM ~]# vgdisplay
— Volume group —
VG Name DataVG
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 79.98 GB
PE Size 16.00 MB
Total PE 5119
Alloc PE / Size 0 / 0
Free PE / Size 5119 / 79.98 GB
VG UUID bdUjjs-gxNi-0170-Gzur-H3aQ-hw2B-5Ug5AQ
— Volume group —
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 19.88 GB
PE Size 32.00 MB
Total PE 636
Alloc PE / Size 636 / 19.88 GB
Free PE / Size 0 / 0
VG UUID 5UlLWB-skhS-kYkE-hg3U-TYW7-wgQ0-hfcsJ4
마지막으로 LV를 만들자. 그전에 LV 확인. 기본적으로 생성돼 있는 Logical Volume 들이다.
/dev/VolGroup00/LogVol01 은 swap 파티션이다. (/etc/fstab 파일을 열어보면 알 수 있다.)
[root@i-955-6459-VM ~]# lvdisplay
— Logical volume —
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID 2EmbII-Vyhb-TkaO-iZDh-dK0c-JKyD-3K10l6
LV Write Access read/write
LV Status available
# open 1
LV Size 15.88 GB
Current LE 508
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:0
— Logical volume —
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID EUFrRy-0UTw-3DE3-LL5b-0kKL-dIAX-Gri1kD
LV Write Access read/write
LV Status available
# open 1
LV Size 4.00 GB
Current LE 128
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:1
LV를 생성해 보자. -L 옵션은 용량을 직접 적을 수 있다. PE를 16MB로 잡아서 80GB를 full로 쓸 수 없다.
[root@i-955-6459-VM ~]# lvcreate -L 80g -n data00 DataVG
Insufficient free extents (5119) in volume group DataVG: 5120 required
-l 옵션으로 LE(=PE) 수를 직접 지정할 수 있다. 에러 메시지의 ‘5119’가 최대값이다. 다음과 같이 하면 순순히 만들어 준다..
[root@i-955-6459-VM ~]# lvcreate -l 5119 -n data00 DataVG
Logical volume “data00” created
LV 정보를 보면 data00이 생성된 것을 볼 수 있다.
[root@i-955-6459-VM ~]# lvdisplay
— Logical volume —
LV Name /dev/DataVG/data00
VG Name DataVG
LV UUID APPToZ-SZ59-O1LT-zwni-n9zJ-5sbV-ezzJvE
LV Write Access read/write
LV Status available
# open 0
LV Size 79.98 GB
Current LE 5119
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:2
— Logical volume —
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID 2EmbII-Vyhb-TkaO-iZDh-dK0c-JKyD-3K10l6
LV Write Access read/write
LV Status available
# open 1
LV Size 15.88 GB
Current LE 508
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:0
— Logical volume —
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID EUFrRy-0UTw-3DE3-LL5b-0kKL-dIAX-Gri1kD
LV Write Access read/write
LV Status available
# open 1
LV Size 4.00 GB
Current LE 128
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:1
이제 /dev/DataVG/data00 를 일반 스토리지처럼 사용하면 된다.
파일 시스템을 만들고,
[root@i-955-6459-VM ~]# mkfs.ext3 /dev/DataVG/data00
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
10485760 inodes, 20967424 blocks
1048371 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
640 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
마운트 한다.
[root@i-955-6459-VM ~]# mount /dev/DataVG/data00 /mnt/tmp
디스크 정보를 보면 이쁘게 들어와 있다.
[root@i-955-6459-VM ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
16G 1.2G 14G 8% /
/dev/xvda1 99M 14M 81M 15% /boot
tmpfs 512M 0 512M 0% /dev/shm
/dev/mapper/DataVG-data00
79G 184M 75G 1% /mnt/tmp
/mnt/tmp 는 임시로 마운트한 것이고, /home 등 원하는 곳에 마운트하고 쓰면 끝.
그 뒤는 알아서..