티스토리 뷰

___리눅스

[리눅스] 리눅스 하드디스크 LVM 증설

변군 변군이글루 2014. 4. 14. 11:48

리눅스 하드디스크 LVM 증설

 

물리 디스크 확인

[root@vm1 ~]# fdisk -l

 

Disk /dev/sda: 85.9 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0003ee54

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26         548     4194304   82  Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3             548       10444    79485952   83  Linux

 

Disk /dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

 

[root@vm1 ~]#

 

새로 만든 디스크 파티션

[root@vm1 ~]# 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 0x35784e8c.

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)

 

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

         switch off the mode (command 'c') and change display units to

         sectors (command 'u').

 

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-2610, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):

Using default value 2610

 

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): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

 

PV (Physical Volume) 생성

[root@vm1 ~]# fdisk -l

 

Disk /dev/sda: 85.9 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0003ee54

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26         548     4194304   82  Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3             548       10444    79485952   83  Linux

 

Disk /dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x35784e8c

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        2610    20964793+  8e  Linux LVM

 

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

  dev_is_mpath: failed to get device for 8:17

  Physical volume "/dev/sdb1" successfully created

[root@vm1 ~]# pvscan

  PV /dev/sdb1                      lvm2 [19.99 GiB]

  Total: 1 [19.99 GiB] / in use: 0 [0   ] / in no VG: 1 [19.99 GiB]

[root@vm1 ~]# pvdisplay

  "/dev/sdb1" is a new physical volume of "19.99 GiB"

  --- NEW Physical volume ---

  PV Name               /dev/sdb1

  VG Name

  PV Size               19.99 GiB

  Allocatable           NO

  PE Size               0

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               aR1xaU-UMkS-V2Nr-pYnM-RNgE-Qed2-5eOdaG

 

[root@vm1 ~]#

 

 

VG (Volume Group) 생성

[root@vm1 ~]# vgcreate vg_data01 /dev/sdb1

  Volume group "vg_data01" successfully created

[root@vm1 ~]# vgscan

  Reading all physical volumes.  This may take a while...

  Found volume group "vg_data01" using metadata type lvm2

[root@vm1 ~]# vgdisplay

  --- Volume group ---

  VG Name               vg_data01

  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               19.99 GiB

  PE Size               4.00 MiB

  Total PE              5118

  Alloc PE / Size       0 / 0

  Free  PE / Size       5118 / 19.99 GiB

  VG UUID               MJVUpC-N9HQ-D2Iv-lEes-a3FM-LDcl-BJvQxx

 

[root@vm1 ~]#

 

 

LV (Logical Volume) 생성

[root@vm1 ~]# lvcreate -L 19.99G -n lv_data01 vg_data01

  Rounding up size to full physical extent 19.99 GiB

  Logical volume "lv_data01" created

[root@vm1 ~]# lvscan

  ACTIVE            '/dev/vg_data01/lv_data01' [19.99 GiB] inherit

[root@vm1 ~]# lvdisplay

  --- Logical volume ---

  LV Path                /dev/vg_data01/lv_data01

  LV Name                lv_data01

  VG Name                vg_data01

  LV UUID                p1n4r8-eCnd-efQx-yD3f-aRXP-XUIa-1B5M7q

  LV Write Access        read/write

  LV Creation host, time vm1.scbyun.com, 2014-04-14 11:33:29 +0900

  LV Status              available

  # open                 0

  LV Size                19.99 GiB

  Current LE             5118

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:0

 

 

파일 시스템 생성

[root@vm1 ~]# mkfs.ext4 /dev/vg_data01/lv_data01

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

1310720 inodes, 5240832 blocks

262041 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

160 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000

 

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 38 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@vm1 ~]#

 

 

마운트

[root@vm1 ~]# mkdir /dataVolume

[root@vm1 ~]# mount /dev/vg_data01/lv_data01 /dataVolume

[root@vm1 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda3              75G  3.1G   68G   5% /

tmpfs                 936M     0  936M   0% /dev/shm

/dev/sda1             194M   57M  127M  31% /boot

/dev/mapper/vg_data01-lv_data01

                       20G  172M   19G   1% /dataVolume

[root@vm1 ~]#

 

 

자동 마운트 설정

[root@vm1 ~]# vi /etc/fstab

#

# /etc/fstab

# Created by anaconda on Thu Apr  3 01:22:11 2014

#

# 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/vg_data01/lv_data01 /dataVolume ext4 defaults 1 2

댓글
댓글쓰기 폼