본문 바로가기

Linux

Linux LVM생성

반응형

 

[root@vm1 dev]# fdisk -cul sda

 Disk sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 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 identifier: 0x97be5b6a

Device Boot      Start         End      Blocks   Id  System
  sda1   *        2048     1026047      512000   83  Linux
  sda2         1026048   210741247   104857600   83  Linux
  sda3       210741248   212838399     1048576   82  Linux swap / Solaris



[root@vm1 dev]# fdisk -cu /dev/sda

 Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Selected partition 4
First sector (212838400-488397167, default 212838400):
Using default value 212838400
Last sector, +sectors or +size{K,M,G} (212838400-488397167, default 488397167):
Using default value 488397167

Command (m for help): p

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 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 identifier: 0x97be5b6a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   210741247   104857600   83  Linux
/dev/sda3       210741248   212838399     1048576   82  Linux swap / Solaris
/dev/sda4       212838400   488397167   137779384    5  Extended


Command (m for help): n
First sector (212840448-488397167, default 212840448):
Using default value 212840448
Last sector, +sectors or +size{K,M,G} (212840448-488397167, default 488397167): +20G

Command (m for help): p

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 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 identifier: 0x97be5b6a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   210741247   104857600   83  Linux
/dev/sda3       210741248   212838399     1048576   82  Linux swap / Solaris
/dev/sda4       212838400   488397167   137779384    5  Extended
/dev/sda5       212840448   254783487    20971520   83  Linux

Command (m for help): t
Partition number (1-5): 5
Hex code (type L to list codes): 8e
Changed system type of partition 5 to 8e (Linux LVM)

Command (m for help): n
First sector (254785536-488397167, default 254785536):
Using default value 254785536
Last sector, +sectors or +size{K,M,G} (254785536-488397167, default 488397167): +20G

Command (m for help): t
Partition number (1-6): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 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 identifier: 0x97be5b6a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   210741247   104857600   83  Linux
/dev/sda3       210741248   212838399     1048576   82  Linux swap / Solaris
/dev/sda4       212838400   488397167   137779384    5  Extended
/dev/sda5       212840448   254783487    20971520   8e  Linux LVM
/dev/sda6       254785536   296728575    20971520   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: 장치나 자원이 동작 중.
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.

 


[root@vm1 dev]# ls /dev/sda*

/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3 

 

 

reboot.....

 

 

[root@vm1 ~]# ls /dev/sda*

 /dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sda4  /dev/sda5  /dev/sda6

 


[root@vm1 ~]# pvcreate /dev/sda5 /dev/sda6

  Physical volume "/dev/sda5" successfully created
  Physical volume "/dev/sda6" successfully created


 

[root@vm1 ~]# vgcreate vmvg /dev/sda5 /dev/sda6

  Volume group "vmvg" successfully created 

 

 

[root@vm1 ~]# lvcreate -L 30G -n station1 vmvg

  Logical volume "station1" created 



[root@vm1 ~]# vgs

  VG   #PV #LV #SN Attr   VSize  VFree
  vmvg   2   1   0 wz--n- 39.99g 9.99g 


 

[root@vm1 ~]# vgdisplay vmvg

 

  --- Volume group ---
  VG Name               vmvg
  System ID            
  Format                lvm2
  Metadata Areas        2
  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                2
  Act PV                2
  VG Size               39.99 GiB
  PE Size               4.00 MiB
  Total PE              10238
  Alloc PE / Size       7680 / 30.00 GiB
  Free  PE / Size       2558 / 9.99 GiB
  VG UUID               hXgPtV-bjIl-LL23-OrjX-aTpx-K101-4uZHKH
  
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   210741247   104857600   83  Linux
/dev/sda3       210741248   212838399     1048576   82  Linux swap / Solaris
/dev/sda4       212838400   488397167   137779384    5  Extended
/dev/sda5       212840448   254783487    20971520   8e  Linux LVM
/dev/sda6       254785536   296728575    20971520   8e  Linux LVM
/dev/sda7       296730624   359645183    31457280   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: 장치나 자원이 동작 중.
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.


[root@vm1 ~]# pvcreate /dev/sda7

  Device /dev/sda7 not found (or ignored by filtering). 


[root@vm1 ~]# ls /dev/sda* 

/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sda4  /dev/sda5  /dev/sda6 


 

새로운 파티션디스크를 만들고 리붓해야 하도록 6.0에서 정책을 변경했으나, 이전의 커널을 불러서 리붓하지 않고 파티션을 바로 불러올 수 있는 훼이크 (커널 시스템콜..)

7번디스크는 에러가 나지 않고 인식완료함. 1~6은 이미 사용하고 있기 때문에 에러


[root@vm1 ~]# partx -a /dev/sda

BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4
BLKPG: Device or resource busy
error adding partition 5
BLKPG: Device or resource busy
error adding partition 6 


[root@vm1 ~]# ls /dev/sda*

/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sda4  /dev/sda5  /dev/sda6  /dev/sda7 


 

[root@vm1 ~]# pvcreate /dev/sda7

  Physical volume "/dev/sda7" successfully created 


 

[root@vm1 ~]# vgs

  VG   #PV #LV #SN Attr   VSize  VFree
  vm     2   1   0 wz--n- 39.75g 9.75g 

 


[root@vm1 ~]# vgextend vm /dev/sda7

  Volume group "vm" successfully extended 

 


[root@vm1 ~]# vgs 

  VG   #PV #LV #SN Attr   VSize  VFree
  vm     3   1   0 wz--n- 69.62g 39.62g 

 

반응형

'Linux' 카테고리의 다른 글

Linux의 부트과정  (0) 2014.03.26
kickstart 설치방법  (0) 2014.03.26
kvm  (0) 2014.03.25
리눅스가상화 KVM  (0) 2014.03.24
UNIX 기본 명령어 목록  (0) 2014.02.18