본문 바로가기
os/Linux

[실습] 2. LVM & RAID

by #moonyz 2014. 10. 28.
1. 1GB 디스크 3개 추가

2. fdisk -l로 추가한 디스크 확인
[root@localhost /]# fdisk -l

Disk /dev/sda: 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/sda1   *           1          13      104391   83  Linux
/dev/sda2              14         650     5116702+  83  Linux
/dev/sda3             651        1287     5116702+  83  Linux
/dev/sda4            1288        2610    10626997+   5  Extended
/dev/sda5            1288        1542     2048256   82  Linux swap / Solaris
/dev/sda6            1543        1669     1020096   83  Linux
/dev/sda7            1670        2610     7558551   83  Linux

Disk /dev/sdb: 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/sdb1               1        1217     9775521   83  Linux
/dev/sdb2            1218        2610    11189272+  83  Linux

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table


Disk /dev/sdd: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdd doesn't contain a valid partition table


Disk /dev/sde: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sde doesn't contain a valid partition table

3. fdisk로 LVM용 파티션 생성
[root@localhost /]# fdisk /dev/sdc --/dev/sdc, /dev/sdd, /dev/sde 각각 LVM용 파티션으로 생성해주기
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.

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-130, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130):
Using default value 130


Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e --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@localhost /]# fdisk -l --디스크 확인

Disk /dev/sda: 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/sda1   *           1          13      104391   83  Linux
/dev/sda2              14         650     5116702+  83  Linux
/dev/sda3             651        1287     5116702+  83  Linux
/dev/sda4            1288        2610    10626997+   5  Extended
/dev/sda5            1288        1542     2048256   82  Linux swap / Solaris
/dev/sda6            1543        1669     1020096   83  Linux
/dev/sda7            1670        2610     7558551   83  Linux

Disk /dev/sdb: 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/sdb1               1        1217     9775521   83  Linux
/dev/sdb2            1218        2610    11189272+  83  Linux

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         130     1044193+  8e  Linux LVM


Disk /dev/sdd: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd2               1         130     1044193+  8e  Linux LVM


Disk /dev/sde: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sde3               1         130     1044193+  8e  Linux LVM


4. LVM용 디스크 3개를 물리적 볼륨(Physical Volume)으로 변환 - pvcreate
[root@localhost /]# pvcreate /dev/sdc1
  Physical volume "/dev/sdc1" successfully created


[root@localhost /]# pvcreate /dev/sdd2
  Physical volume "/dev/sdd2" successfully created


[root@localhost /]# pvcreate /dev/sde3
  Physical volume "/dev/sde3" successfully created


5. 물리적볼륨3개를 1개의 볼륨그룹(Volume Group)으로 합치기 - vgcreate
[root@localhost /]# vgcreate vol1 /dev/sdc1 /dev/sdd2 /dev/sde3
  /dev/hdc: open failed: No medium found
  Volume group "vol1" successfully created

[root@localhost /]# vgdisplay --생성된 볼륨그룹 확인
  --- Volume group ---
  VG Name               vol1
  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               2.98 GB
  PE Size               4.00 MB
  Total PE              762
  Alloc PE / Size       0 / 0
  Free  PE / Size       762 / 2.98 GB
  VG UUID               puJddN-RwfG-4S9B-ykWN-8qLd-V2ih-di6Bgf

6. 3GB 용량의 볼륨그룹을 1.5GB으로 파티셔닝 - lvcreate
[root@localhost /]# lvcreate -L 1500MB -n lv1 vol1 --논리적볼륨 lv1(1500MB) 을 볼륨그룹vol1안에 만들어라.
  Logical volume "lv1" created

[root@localhost /]# vgdisplay
  --- Volume group ---
  VG Name               vol1
  System ID
  Format                lvm2
  Metadata Areas        3
  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                3
  Act PV                3
  VG Size               2.98 GB
  PE Size               4.00 MB
  Total PE              762
  Alloc PE / Size       375 / 1.46 GB
  Free  PE / Size       387 / 1.51 GB

  VG UUID               puJddN-RwfG-4S9B-ykWN-8qLd-V2ih-di6Bgf

[root@localhost /]# lvcreate -L 1.5GB -n lv2 vol1 --논리적볼륨 lv2(1.5GB) 을 볼륨그룹vol1안에 만들어라.
  Logical volume "lv2" created

[root@localhost /]# lvscan --생성되어 있는 논리적 볼륨그룹 조회
  ACTIVE            '/dev/vol1/lv1' [1.46 GB] inherit
  ACTIVE            '/dev/vol1/lv2' [1.50 GB] inherit

7. 논리적 볼륨 포맷 - mkfs.ext3
[root@localhost /]# mkfs.ext3 /dev/vol1/lv1   --vl1포맷
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
192000 inodes, 384000 blocks
19200 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=394264576
12 block groups
32768 blocks per group, 32768 fragments per group
16000 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@localhost /]# mkfs.ext3 /dev/vol1/lv2 --vl2포맷
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
196608 inodes, 393216 blocks
19660 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=402653184
12 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

8. 디렉토리 생성후 마운트
[root@localhost /]# mkdir /dir3
[root@localhost /]# mkdir /dir4

[root@localhost /]# mount /dev/vol1/lv1 /dir3
[root@localhost /]# mount /dev/vol1/lv2 /dir4

[root@localhost /]# df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             4.8G  3.0G  1.6G  65% /
/dev/sda7             7.0G  145M  6.5G   3% /app
/dev/sda6             965M   72M  844M   8% /var
/dev/sda2             4.8G  138M  4.4G   4% /home
/dev/sda1              99M   12M   83M  12% /boot
tmpfs                 506M     0  506M   0% /dev/shm
/dev/sdb1             9.2G  150M  8.6G   2% /dir1
/dev/sdb2              11G  155M  9.9G   2% /dir2
/dev/mapper/vol1-lv1  1.5G   35M  1.4G   3% /dir3
/dev/mapper/vol1-lv2  1.5G   35M  1.4G   3% /dir4



'os > Linux' 카테고리의 다른 글

[실습] 구구단  (0) 2014.10.28
[실습] shell script  (0) 2014.10.28
[실습] 1. 디스크추가  (0) 2014.10.28
9. 네트워크 (서브넷 정리 필요)  (0) 2014.10.28
8. Shell Script - 조건문, 반복문  (0) 2014.10.28

댓글