http://rain.boanlab.com/index.php?mid=textyle&category=24274&document_srl=25171
5.2.3 리눅스 LVM 구성
1. VMware GuestOS에 HDD 3개를 각각 100MB, 200MB, 300MB를 추가 하도록 한다.
이 구성에서의 LVM의 총 Size는 100+200+300 = 600MB의 논리적 단일 HDD 구성이다.
2. 시스템 부팅 후 리눅스 LVM 구성
- 관련 명령어
- LVM 구성하기
1. LVM 생성
추가된 HDD 정보 확인 [root@naruto etc]# fdisk -l
Disk /dev/sda: 17.2 GB, 17179869184 bytes 255 heads, 63 sectors/track, 2088 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x0000c8a6
Device Boot Start End Blocks Id System /dev/sda1 * 1 26 206580+ 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 26 2088 16565248 8e Linux LVM
Disk /dev/sdb: 106 MB, 106954752 bytes 64 heads, 32 sectors/track, 102 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 213 MB, 213909504 bytes 64 heads, 32 sectors/track, 204 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Disk identifier: 0x00000000
Disk /dev/sdc doesn't contain a valid partition table
Disk /dev/sdd: 321 MB, 321912832 bytes 64 heads, 32 sectors/track, 307 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Disk identifier: 0x00000000
Disk /dev/sdd doesn't contain a valid partition table
Fdisk를 사용하여 추가된 HDD를 LVM 타입의 파티션으로 만들기 [root@naruto etc]# fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x97fbaf9e. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-102, default 1): 1 Last cylinder, +cylinders or +size{K,M,G} (1-102, default 102): 102
Command (m for help): t Selected partition 1 Hex code (type L to list codes): 8e Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/sdb: 106 MB, 106954752 bytes 64 heads, 32 sectors/track, 102 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Disk identifier: 0x97fbaf9e
Device Boot Start End Blocks Id System /dev/sdb1 1 102 104432 8e Linux LVM
Command (m for help): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
[root@naruto etc]# fdisk /dev/sdc Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xe41b0956. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-204, default 1): 1 Last cylinder, +cylinders or +size{K,M,G} (1-204, default 204): 204
Command (m for help): t Selected partition 1 Hex code (type L to list codes): 8e Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/sdc: 213 MB, 213909504 bytes 64 heads, 32 sectors/track, 204 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Disk identifier: 0xe41b0956
Device Boot Start End Blocks Id System /dev/sdc1 1 204 208880 8e Linux LVM
Command (m for help): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
[root@naruto etc]# fdisk /dev/sdd Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x1882e12e. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-307, default 1): 1 Last cylinder, +cylinders or +size{K,M,G} (1-307, default 307): 307
Command (m for help): t Selected partition 1 Hex code (type L to list codes): 8e Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/sdd: 321 MB, 321912832 bytes 64 heads, 32 sectors/track, 307 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Disk identifier: 0x1882e12e
Device Boot Start End Blocks Id System /dev/sdd1 1 307 314352 8e Linux LVM
Command (m for help): w The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
물리볼륨(PV)을 만든다. [root@naruto etc]# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created [root@naruto etc]# pvcreate /dev/sdc1 Physical volume "/dev/sdc1" successfully created [root@naruto etc]# pvcreate /dev/sdd1 Physical volume "/dev/sdd1" successfully created
볼륨그룹(VG)을 만든다 [root@naruto etc]# vgcreate VG-test /dev/sdb1 /dev/sdc1 /dev/sdd1 Volume group "VG-test" successfully created
볼륨그룹(VG)상태 확인 [root@naruto etc]# vgdisplay VG-test --- Volume group --- VG Name VG-test System ID Format lvm2 Metadata Areas 3 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 3 Act PV 3 VG Size 604.00 MB PE Size 4.00 MB Total PE 151 Alloc PE / Size 0 / 0 Free PE / Size 151 / 604.00 MB VG UUID rxWdQF-Krtg-a3fR-a5o7-xHJf-4308-Z46Bax
논리볼륨(LV)을 만든다. [root@naruto etc]# lvcreate -L 604MB -n LV-test VG-test Logical volume "LV-test" created
논리볼륨(LV) 포맷 (ext4는 페도라11부터 지원하는 파일 시스템이므로 여러분들은 자신의 시스템에 맞는 파일 시스템으로 선택하여야 한다) [root@naruto etc]# mkfs.ext4 /dev/VG-test/LV-test mke2fs 1.41.9 (22-Aug-2009) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 38720 inodes, 154624 blocks 7731 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=159383552 5 block groups 32768 blocks per group, 32768 fragments per group 7744 inodes per group Superblock backups stored on blocks: 32768, 98304
Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 35 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. |
2. 생성된 LVM 시스템에 Mount
시스템 Mount정보 확인 [root@naruto ~]# mount /dev/mapper/vg_naruto-naruto00 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0") /dev/sda1 on /boot type ext4 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
LVM을 Mount할 디렉터리 생성 [root@naruto ~]# mkdir /LVMdata
LVM을 /LVMdata 디렉터리에 Mount [root@naruto ~]# mount -t ext4 /dev/VG-test/LV-test /LVMdata/
시스템 Mount 정보 확인 [root@naruto ~]# mount /dev/mapper/vg_naruto-naruto00 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0") /dev/sda1 on /boot type ext4 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) /dev/mapper/VG--test-LV--test on /LVMdata type ext4 (rw)
[root@naruto ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_naruto-naruto00 15G 9.9G 4.0G 72% / tmpfs 376M 88K 376M 1% /dev/shm /dev/sda1 196M 36M 151M 19% /boot /dev/mapper/VG--test-LV--test 595M 17M 548M 3% /LVMdata |
3. 시스템에 자동으로 LVM Mount 설정
/etc/fstab 에 설정 등록 [root@naruto ~]# vi /etc/fstab # # /etc/fstab # Created by anaconda on Mon Nov 23 20:54:59 2009 # # 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_naruto-naruto00 / ext4 defaults 1 1 UUID=03d18320-e28c-41eb-a72e-a85c6c3eae92 /boot ext4 defaults 1 2 /dev/mapper/vg_naruto-naruto01 swap swap defaults 0 0 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 /dev/VG-test/LV-test /LVMdata ext4 defaults 1 1 저장하고 리부팅을 해주도록 한다. 만약 시스템이 제대로 부팅 되지 않는다면 100% 오타이다. 응급 복구로 부팅 하여서 기존의 수정된 /etc/fstab를 복구해주면 해결 된다.
자동 Mount의 확인 [root@naruto ~]# mount /dev/mapper/vg_naruto-naruto00 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0") /dev/sda1 on /boot type ext4 (rw) /dev/mapper/VG--test-LV--test on /LVMdata type ext4 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
[root@naruto ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_naruto-naruto00 15G 9.9G 4.0G 72% / tmpfs 376M 88K 376M 1% /dev/shm /dev/sda1 196M 36M 151M 19% /boot /dev/mapper/VG--test-LV--test 595M 17M 548M 3% /LVMdata |
'UNIX > 유닉스 공통' 카테고리의 다른 글
/etc/fstab 내용 (0) | 2012.07.20 |
---|---|
하드디스크 장치명 (0) | 2012.07.19 |
LVM 상세내용 - 구성요소 및 개념도 (0) | 2012.07.19 |
리눅스 LVM 생성 (0) | 2012.07.19 |
EXT 파일 시스템(ext1, ext2, ext3, ext4) (0) | 2012.07.19 |