// 进入 LVM 模式

Debian:/home/reistlin#lvm

// 查看 LVM 磁盘状态 - 目前没有任何 LVM 磁盘信息

lvm>lvmdiskscan

/dev/ram0 [ 8.00 MB]

/dev/ram1 [ 8.00 MB]

/dev/root [ 7.91 GB]

/dev/ram2 [ 8.00 MB]

/dev/sda2 [ 2.08 GB]

/dev/ram3 [ 8.00 MB]

/dev/ram4 [ 8.00 MB]

/dev/ram5 [ 8.00 MB]

/dev/ram6 [ 8.00 MB]

/dev/ram7 [ 8.00 MB]

/dev/ram8 [ 8.00 MB]

/dev/ram9 [ 8.00 MB]

/dev/ram10 [ 8.00 MB]

/dev/ram11 [ 8.00 MB]

/dev/ram12 [ 8.00 MB]

/dev/ram13 [ 8.00 MB]

/dev/ram14 [ 8.00 MB]

/dev/ram15 [ 8.00 MB]

/dev/sdb [ 1.00 GB]

2 disks

17 partitions

0 LVM physical volume whole disks

0 LVM physical volumes

// 查看 LVM 配置文件 - dump 模式

lvm>dumpconfig

devices {

dir=”/dev”

scan=”/dev”

preferred_names=[]

filter=”a/.*/”

cache_dir=”/etc/lvm/cache”

cache_file_prefix=”"

write_cache_state=1

sysfs_scan=1

md_component_detection=1

ignore_suspended_devices=0

}

activation {

missing_stripe_filler=”/dev/ioerror”

reserved_stack=256

reserved_memory=8192

process_priority=-18

mirror_region_size=512

readahead=”auto”

mirror_log_fault_policy=”allocate”

mirror_device_fault_policy=”remove”

}

global {

umask=63

test=0

units=”h”

activation=1

proc=”/proc”

locking_type=1

fallback_to_clustered_locking=1

fallback_to_local_locking=1

locking_dir=”/var/lock/lvm”

}

shell {

history_size=100

}

backup {

backup=1

backup_dir=”/etc/lvm/backup”

archive=1

archive_dir=”/etc/lvm/archive”

retain_min=10

retain_days=30

}

log {

verbose=0

syslog=1

overwrite=0

level=0

indent=1

command_names=0

prefix=” ”

}

// 创建 Physical Volume (PV)

lvm> pvcreate

Please enter a physical volume path

lvm>pvcreate /dev/sdb1

Physical volume “/dev/sdb1″ successfully created

// 查看 Physical Volume (PV) 状态

lvm>pvdisplay

CTRL-c detected: giving up waiting for lock

— Physical volume —

PV Name /dev/sdb1

VG Name vg_test

PV Size 1023.98 MB / not usable 3.98 MB

Allocatable yes (but full)

PE Size (KByte) 4096

Total PE 255

Free PE 0

Allocated PE 255

PV UUID SwfyW5-veGN-1Ptd-VIUo-0I3I-CdVB-QF7BwC

// 再次查看 LVM 磁盘状态

lvm>lvmdiskscan

/dev/ram0 [ 8.00 MB]

/dev/ram1 [ 8.00 MB]

/dev/root [ 7.91 GB]

/dev/ram2 [ 8.00 MB]

/dev/sda2 [ 2.08 GB]

/dev/ram3 [ 8.00 MB]

/dev/ram4 [ 8.00 MB]

/dev/ram5 [ 8.00 MB]

/dev/ram6 [ 8.00 MB]

/dev/ram7 [ 8.00 MB]

/dev/ram8 [ 8.00 MB]

/dev/ram9 [ 8.00 MB]

/dev/ram10 [ 8.00 MB]

/dev/ram11 [ 8.00 MB]

/dev/ram12 [ 8.00 MB]

/dev/ram13 [ 8.00 MB]

/dev/ram14 [ 8.00 MB]

/dev/ram15 [ 8.00 MB]

/dev/sdb1 [ 1023.98 MB] LVM physical volume

1 disk

17 partitions

0 LVM physical volume whole disks

1 LVM physical volume

// 创建 Volume Group (VG)

lvm> vgcreate vg_test

Please enter physical volume name(s)

lvm>vgcreate vg_test /dev/sdb1

Volume group “vg_test” successfully created

// 查看 Volume Group (VG) 状态

lvm>vgdisplay

— Volume group —

VG Name vg_test

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 1020.00 MB

PE Size 4.00 MB

Total PE 255

Alloc PE / Size 0 / 0

Free PE / Size 255 / 1020.00 MB

VG UUID Dbm7gQ-HDao-0z2Z-2u3q-XK9A-bmEv-ES3qC0

// 创建 Logical Volume (LV) - 如果需要使用全部VG空间. 输入 -l 的值.

// 的值可以使用 vgdisplay 命令查看: Total PE = 255

lvm>lvcreate -l 255 vg_test -n lv_test

Logical volume “lv_test” created

// 查看 Logical Volume (LV) 状态

lvm>lvdisplay

— Logical volume —

LV Name /dev/vg_test/lv_test

VG Name vg_test

LV UUID l3GUct-M3nG-m837-wOe2-4EWo-ZPU6-xskaq8

LV Write Access read/write

LV Status available

# open 0

LV Size 1020.00 MB

Current LE 255

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 254:0

// 输入 exit 退出 LVM 配置模式. Ext3 格式化 lv_test 逻辑卷

Debian:/home/reistlin#mkfs -t ext3 -j /dev/vg_test/lv_test

mke2fs 1.41.3 (12-Oct-2008)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

65280 inodes, 261120 blocks

13056 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=268435456

8 block groups

32768 blocks per group, 32768 fragments per group

8160 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 25 mounts or

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

// 挂载 lv_test 逻辑卷到 /mnt 目录. 你也可以挂载到 /home 目录

Debian:/home/reistlin#mount /dev/vg_test/lv_test /mnt

Debian:/home/reistlin# cd /mnt

// 测试文件读写. Reistlin.Com. OKay.

Debian:/mnt# vim Reistlin.Com

Debian:/mnt# cat Reistlin.Com

Welcome to Reistlin.Com

  1. 实例解析:Linux系统下LVM扩充方法
  2. Linux下使用网站主机作为加密代理服务器
  3. linux下磁盘lvm挂在显示容量问题


相关内容