linux下lvm的簡單操作

super_sky發表於2013-12-25

[root@localhost rc.d]# fdisk -l

 

Disk /dev/sda: 536.8 GB, 536870912000 bytes

16 heads, 255 sectors/track, 257003 cylinders

Units = cylinders of 4080 * 512 = 2088960 bytes

 

   Device Boot      Start         End      Blocks   Id  System

 

Disk /dev/hda: 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/hda1   *           1          13      104391   83  Linux

/dev/hda2              14        2610    20860402+  8e  Linux LVM

 

建立PV

[root@localhost rc.d]# pvcreate /dev/sda

  Physical volume "/dev/sda" successfully created

檢視PV

[root@localhost rc.d]# pvscan

  PV /dev/hda2   VG VolGroup00      lvm2 [19.88 GB / 0    free]

  PV /dev/sda                       lvm2 [500.00 GB]

  Total: 2 [519.88 GB] / in use: 1 [19.88 GB] / in no VG: 1 [500.00 GB]

 

建立VG

[root@localhost rc.d]# vgcreate VolGroup01 /dev/sda

  Volume group "VolGroup01" successfully created

啟用VG

[root@localhost rc.d]# vgchange -a y VolGroup01

  0 logical volume(s) in volume group "VolGroup01" now active

 

建立LV

[root@localhost rc.d]# lvcreate -L8192M -nswapvol00 VolGroup01

  Logical volume "swapvol00" created

查詢LV

[root@localhost rc.d]# lvscan

  ACTIVE            '/dev/VolGroup00/LogVol00' [18.88 GB] inherit

  ACTIVE            '/dev/VolGroup00/LogVol01' [1.00 GB] inherit

  ACTIVE            '/dev/VolGroup01/swapvol00' [8.00 GB] inherit

 

[root@localhost rc.d]# lvcreate -L30720M -ndataVol00 VolGroup01

  Logical volume "dataVol00" created

[root@localhost rc.d]#

[root@localhost rc.d]# lvscan

  ACTIVE            '/dev/VolGroup00/LogVol00' [18.88 GB] inherit

  ACTIVE            '/dev/VolGroup00/LogVol01' [1.00 GB] inherit

  ACTIVE            '/dev/VolGroup01/swapvol00' [8.00 GB] inherit

  ACTIVE            '/dev/VolGroup01/dataVol00' [30.00 GB] inherit

 

格式化lv

[root@localhost rc.d]# mkfs -t ext3 /dev/VolGroup01/dataVol00

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

3932160 inodes, 7864320 blocks

393216 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

240 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

 

Writing inode tables: done                           

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 28 mounts or

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

 

掛載檔案系統

[root@localhost rc.d]# mount /dev/VolGroup01/dataVol00 /u01

 

 

掛載swap

[root@localhost rc.d]# lvscan

  ACTIVE            '/dev/VolGroup00/LogVol00' [18.88 GB] inherit

  ACTIVE            '/dev/VolGroup00/LogVol01' [1.00 GB] inherit

  ACTIVE            '/dev/VolGroup01/swapvol00' [8.00 GB] inherit

  ACTIVE            '/dev/VolGroup01/dataVol00' [30.00 GB] inherit

[root@localhost rc.d]#

[root@localhost rc.d]#

[root@localhost rc.d]# mkswap /dev/VolGroup01/swapvol00

Setting up swapspace version 1, size = 8589930 kB

[root@localhost rc.d]#

[root@localhost rc.d]# swapon /dev/VolGroup01/swapvol00

[root@localhost rc.d]#

[root@localhost rc.d]# swapon -s

Filename                                Type            Size    Used    Priority

/dev/mapper/VolGroup00-LogVol01         partition       1048568 0       -1

/dev/mapper/VolGroup01-swapvol00        partition       8388600 0       -3

[root@localhost rc.d]#

[root@localhost rc.d]# free -m

             total       used       free     shared    buffers     cached

Mem:          3959        481       3478          0         32        328

-/+ buffers/cache:        121       3838

Swap:         9215          0       9215

[root@localhost rc.d]# 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/11590946/viewspace-1064217/,如需轉載,請註明出處,否則將追究法律責任。

相關文章