LVM

LVM

步骤 分区的创建和更改系统idlvmid  8e

[root@xx etc]# fdisk /dev/sda

P查看现有区域

 

 

Command (m for help): p

 

Disk /dev/sda: 53.6 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        2550    20482843+  83  Linux

/dev/sda2            2551        4462    15358140   83  Linux

/dev/sda3            4463        4615     1228972+  82  Linux swap / Solaris

 

N创建

 

Command (m for help): n

Command action

   e   extended  (扩展分区)

   p   primary partition (1-4)    (主分区)

e

Selected partition 4

First cylinder (4616-6527, default 4616):

Using default value 4616

Last cylinder or +size or +sizeM or +sizeK (4616-6527, default 6527):

Using default value 6527

 

P查看

 

Command (m for help): p

 

Disk /dev/sda: 53.6 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        2550    20482843+  83  Linux

/dev/sda2            2551        4462    15358140   83  Linux

/dev/sda3            4463        4615     1228972+  82  Linux swap / Solaris

/dev/sda4            4616        6527    15358140    5  Extended

 

N创建逻辑分区

Command (m for help): n

First cylinder (4616-6527, default 4616):

Using default value 4616

Last cylinder or +size or +sizeM or +sizeK (4616-6527, default 6527): +100M

 

创建三个

Command (m for help): P

 

Disk /dev/sda: 53.6 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        2550    20482843+  83  Linux

/dev/sda2            2551        4462    15358140   83  Linux

/dev/sda3            4463        4615     1228972+  82  Linux swap / Solaris

/dev/sda4            4616        6527    15358140    5  Extended

/dev/sda5            4616        4628      104391   83  Linux

/dev/sda6            4629        4641      104391   83  Linux

/dev/sda7            4642        4654      104391   83  Linux

 

t修改系统id

Command (m for help): t  

Partition number (1-7): 5

Hex code (type L to list codes): 8e

Changed system type of partition 5 to 8e (Linux LVM)

修改三个

P结果

Command (m for help): p

 

Disk /dev/sda: 53.6 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        2550    20482843+  83  Linux

/dev/sda2            2551        4462    15358140   83  Linux

/dev/sda3            4463        4615     1228972+  82  Linux swap / Solaris

/dev/sda4            4616        6527    15358140    5  Extended

/dev/sda5            4616        4628      104391   8e  Linux LVM

/dev/sda6            4629        4641      104391   8e  Linux LVM

/dev/sda7            4642        4654      104391   8e  Linux LVM

 

W保存

 

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.

Syncing disks.

 

出现以上情况使用[root@xx etc]# partprobe [root@xx etc]# pvscan  (查看有无pv在系统上)

 

建立pv

[root@xx etc]# pvcreate /dev/sda{5,6,7}  5,6,7都建立为pv(物理卷)

Physical volume "/dev/sda5" successfully created

  Physical volume "/dev/sda6" successfully created

  Physical volume "/dev/sda7" successfully created

查看

[root@xx etc]# pvscan

  /dev/cdrom: open failed: 只读文件系统

  Attempt to close device '/dev/cdrom' which is not open.

  PV /dev/sda5                      lvm2 [101.94 MB]

  PV /dev/sda6                      lvm2 [101.94 MB]

  PV /dev/sda7                      lvm2 [101.94 MB]

  Total: 3 [305.83 MB] / in use: 0 [0   ] / in no VG: 3 [305.83 MB]

建立完成!(可用[root@xx etc]# pvdisplay查看每个pv的详细信息)

 

创建vg(卷用户组)

[root@xx etc]# vgcreate xiao /dev/sda{5,6}   xiao为名称  5,6两个物理卷创建vg

 

[root@xx etc]# vgscan  (查看是否创建成功)

 

[root@xx etc]# pvscan

  /dev/cdrom: open failed: 只读文件系统

  Attempt to close device '/dev/cdrom' which is not open.

  PV /dev/sda5   VG xiao            lvm2 [100.00 MB / 100.00 MB free]

  PV /dev/sda6   VG xiao            lvm2 [100.00 MB / 100.00 MB free]

  PV /dev/sda7                      lvm2 [101.94 MB]

  Total: 3 [301.94 MB] / in use: 2 [200.00 MB] / in no VG: 1 [101.94 MB]

 

 

可增加vg的容量(将7也加入到vg中)

[root@xx etc]# vgextend xiao /dev/sda7

[root@xx etc]# pvscan

  /dev/cdrom: open failed: 只读文件系统

  Attempt to close device '/dev/cdrom' which is not open.

  PV /dev/sda5   VG xiao   lvm2 [100.00 MB / 100.00 MB free]

  PV /dev/sda6   VG xiao   lvm2 [100.00 MB / 100.00 MB free]

  PV /dev/sda7   VG xiao   lvm2 [100.00 MB / 100.00 MB free]

  Total: 3 [300.00 MB] / in use: 3 [300.00 MB] / in no VG: 0 [0   ]

 

[root@xx etc]# vgdisplay(查看lg

创建lv(逻辑卷)

[root@xx etc]# lvcreate -L 50M -n xxiao xiao  xxiaolv的名称  xiaolg的名称)

 

[root@xx etc]# lvdisplay  (查看lv

  --- Logical volume ---

  LV Name                /dev/xiao/xxiao

  VG Name                xiao

  LV UUID                XT135A-i1Ky-PlwI-a0ae-xk3w-4pjP-oReap6

  LV Write Access        read/write

  LV Status              available

  # open                 0

  LV Size                52.00 MB

  Current LE             13

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:0

 

创建完成!

格式化xxiao

[root@xx etc]# mkfs -t ext3 /dev/xiao/xxiao ext3为系统类型  后面是绝对路径)

创建一个文件夹用于挂载

[root@xx /]# mkdir xxiao

挂载

[root@xx /]# mount /dev/xiao/xxiao /xiao

[root@xx /]# df -h

文件系统              容量  已用 可用 已用% 挂载点

/dev/sda2              15G  5.9G  7.6G  44% /

/dev/sda1              19G  178M   18G   1% /boot

tmpfs                 127M     0  127M   0% /dev/shm

/dev/hdc              2.9G  2.9G     0 100% /media/RHEL_5.3 i386 DVD

/dev/hdc              2.9G  2.9G     0 100% /mnt

/dev/mapper/xiao-xxiao

                       51M  4.9M   43M  11% /xiao

 

 

 

放大lv的容量

[root@xx /]# fdisk /dev/sda 新建一个分区8

创建pv

[root@xx /]# pvcreate /dev/sda8

[root@xx /]# pvscan

  /dev/cdrom: open failed: 只读文件系统

  Attempt to close device '/dev/cdrom' which is not open.

  PV /dev/sda5   VG xiao            lvm2 [100.00 MB / 48.00 MB free]

  PV /dev/sda6   VG xiao            lvm2 [100.00 MB / 100.00 MB free]

  PV /dev/sda7   VG xiao            lvm2 [100.00 MB / 100.00 MB free]

  PV /dev/sda8                      lvm2 [101.94 MB]

  Total: 4 [401.94 MB] / in use: 3 [300.00 MB] / in no VG: 1 [101.94 MB]

 

添加到xiaovg)里

[root@xx /]# vgextend xiao /dev/sda8

 

[root@xx /]# vgdisplay(查看)

 

放大lv

 

[root@xx /]# lvextend -L +30M /dev/xiao/xxiao (增加了30m

查看

 

 

[root@xx /]# lvdisplay

[root@xx /]# df /xiao  (发现并没用生效到系统)

[root@xx /]# resize2fs /dev/xiao/xxiao  (重置,使之生效)

[root@xx /]# df /xiao  再次查看 ,显示生效后的结果!

 

你可能感兴趣的:(职场,磁盘分区,休闲)