先上一张鸟哥LVM的图.感觉这张最清楚了。

#以下以Xshell的日志记录系统直接记录.上面添加了一些个人理解的注释

[BEGIN] 2016/9/13 9:22:24

#先查看下硬盘的情况.

[root@linuxidc ~]# fdisk -l

Disk /dev/vda: 64.4 GB, 64424509440 bytes

255 heads, 63 sectors/track, 7832 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: 0x00078f9c

Device Boot      Start        End      Blocks  Id  System

/dev/vda1  *          1        7833    62912512  83  Linux

Disk /dev/vdb: 536.9 GB, 536870912000 bytes

255 heads, 63 sectors/track, 65270 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: 0x3a7be7cb

Device Boot      Start        End      Blocks  Id  System

/dev/vdb1              1      65270  524281243+  8e  Linux LVM

#上面这里显示已经有LVM.但是为了方便演示. 下面先将这个删除掉了

[root@linuxidc ~]# fdisk /dev/vdb

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

Disk /dev/vdb: 536.9 GB, 536870912000 bytes

255 heads, 63 sectors/track, 65270 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: 0x3a7be7cb

Device Boot      Start        End      Blocks  Id  System

/dev/vdb1              1      65270  524281243+  8e  Linux LVM

Command (m for help): d

Selected partition 1

Command (m for help): p

Disk /dev/vdb: 536.9 GB, 536870912000 bytes

255 heads, 63 sectors/track, 65270 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: 0x3a7be7cb

Device Boot      Start        End      Blocks  Id  System

Command (m for help): n

Command action

e  extended

p  primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-65270, default 1):

Using default value 1

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

Using default value 65270

Command (m for help): p

Disk /dev/vdb: 536.9 GB, 536870912000 bytes

255 heads, 63 sectors/track, 65270 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: 0x3a7be7cb

Device Boot      Start        End      Blocks  Id  System

/dev/vdb1              1      65270  524281243+  83  Linux

#此处使用t来修改格式.由于是需要LVM.所以需要改为8e的格式.

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

Disk /dev/vdb: 536.9 GB, 536870912000 bytes

255 heads, 63 sectors/track, 65270 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: 0x3a7be7cb

Device Boot      Start        End      Blocks  Id  System

/dev/vdb1              1      65270  524281243+  8e  Linux LVM

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@linuxidc ~]# partprobe

Warning: WARNING: the kernel failed to re-read the partition table on /dev/vda (Device or resource busy).

As a result, it may not reflect all of your changes until after reboot.

[root@linuxidc ~]# fdisk -l

Disk /dev/vda: 64.4 GB, 64424509440 bytes

255 heads, 63 sectors/track, 7832 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: 0x00078f9c

Device Boot      Start        End      Blocks  Id  System

/dev/vda1  *          1        7833    62912512  83  Linux

Disk /dev/vdb: 536.9 GB, 536870912000 bytes

255 heads, 63 sectors/track, 65270 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: 0x3a7be7cb

Device Boot      Start        End      Blocks  Id  System

/dev/vdb1              1      65270  524281243+  8e  Linux LVM

[root@linuxidc ~]# pvscan

No matching physical volumes found

#先建pv.后面接具体的划分的路径.

[root@linuxidc ~]# pvcreate /dev/vdb1

Physical volume "/dev/vdb1" successfully created

[root@linuxidc ~]# pvscan

PV /dev/vdb1                      lvm2 [499.99 GiB]

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

[root@linuxidc ~]# pvdisplay

"/dev/vdb1" is a new physical volume of "499.99 GiB"

--- NEW Physical volume ---

PV Name              /dev/vdb1

VG Name

PV Size              499.99 GiB

Allocatable          NO

PE Size              0

Total PE              0

Free PE              0

Allocated PE          0

PV UUID              GOeBQF-iCCD-n7i7-Y4DT-U5PE-tjHK-B9Z3CL

#再建VG.由于是直接使用整个划分的区块,所以直接跟区块名 /dev/vdb1,前面接的是vg名称,这个随便命名的.

[root@linuxidc ~]# vgcreate mailbox_vg /dev/vdb1

Volume group "mailbox_vg" successfully created

[root@linuxidc ~]# vgscan

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

Found volume group "mailbox_vg" using metadata type lvm2

[root@linuxidc ~]# pvscan

PV /dev/vdb1  VG mailbox_vg  lvm2 [499.99 GiB / 499.99 GiB free]

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

[root@linuxidc ~]# vgdisplay

--- Volume group ---

VG Name              mailbox_vg

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

PE Size              4.00 MiB

Total PE              127998

Alloc PE / Size      0 / 0

Free  PE / Size      127998 / 499.99 GiB

VG UUID              JjdDER-Y1OK-ICwZ-3FgC-cry2-bZYl-SqD3RP

#下面需要创建LV.-l后面接的是pe的数量.这个可使用上面的vgdisplay的命令来查看.

#然后后面接lv的名称.也是可以随便命名,但是个人建议这里写个可以区分的.要不到时难分清楚.

[root@linuxidc ~]# lvcreate -l 127998 -n mailbox_lv mailbox_vg

Logical volume "mailbox_lv" created

[root@linuxidc ~]# lvdisplay

--- Logical volume ---

LV Path                /dev/mailbox_vg/mailbox_lv

LV Name                mailbox_lv

VG Name                mailbox_vg

LV UUID                VPA4HE-22B4-gZc0-Qo8V-TO1C-tKaF-AT8s5T

LV Write Access        read/write

LV Creation host, time linuxidc, 2016-09-13 09:25:34 +0800

LV Status              available

# open                0

LV Size                499.99 GiB

Current LE            127998

Segments              1

Allocation            inherit

Read ahead sectors    auto

- currently set to    256

Block device          253:0

[root@linuxidc ~]# fdisk -l

Disk /dev/vda: 64.4 GB, 64424509440 bytes

255 heads, 63 sectors/track, 7832 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: 0x00078f9c

Device Boot      Start        End      Blocks  Id  System

/dev/vda1  *          1        7833    62912512  83  Linux

Disk /dev/vdb: 536.9 GB, 536870912000 bytes

255 heads, 63 sectors/track, 65270 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: 0x3a7be7cb

Device Boot      Start        End      Blocks  Id  System

/dev/vdb1              1      65270  524281243+  8e  Linux LVM

Disk /dev/mapper/mailbox_vg-mailbox_lv: 536.9 GB, 536862523392 bytes

255 heads, 63 sectors/track, 65269 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@linuxidc ~]# mkfs -t ext4 /dev/mailbox_vg/mailbox_lv

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

32768000 inodes, 131069952 blocks

6553497 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

4000 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, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,

102400000

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 34 mounts or

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

#创建挂载目录,进行挂载.

[root@linuxidc ~]# mkdir /mail_mailbox

[root@linuxidc ~]# mount /dev/

Display all 179 possibilities? (y or n)

[root@linuxidc ~]# mount /dev/mailbox_vg/mailbox_lv /mail_mailbox/

[root@linuxidc ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/vda1              59G  1.9G  55G  4% /

tmpfs                3.9G    0  3.9G  0% /dev/shm

/dev/mapper/mailbox_vg-mailbox_lv

493G  70M  467G  1% /mail_mailbox

#使用vim修改fstab的文件.让其开机自动的挂载 .

以下是后面cat /etc/fstab的内容补上,这里vim没有记录

--------------------------------------------------------------------------------------

[root@linuxidc ~]# cat /etc/fstab

#

# /etc/fstab

# Created by anaconda on Thu Aug 14 21:16:42 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

#

UUID=94e4e384-0ace-437f-bc96-057dd64f42ee / ext4 defaults,barrier=0 1 1

tmpfs                  /dev/shm                tmpfs  defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                  /sys                    sysfs  defaults        0 0

proc                    /proc                  proc    defaults        0 0

/dev/mailbox_vg/mailbox_lv    /mail_mailbox    ext4    defaults    1 2

[root@linuxidc ~]#

--------------------------------------------------------------------------------------

[root@linuxidc ~]# vim /etc/fstab

#下面进行umount然后再mount -a测试一下fstab是否正常写

[root@linuxidc ~]# umount /mail_mailbox/

[root@linuxidc ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/vda1        59G  1.9G  55G  4% /

tmpfs          3.9G    0  3.9G  0% /dev/shm

[root@linuxidc ~]# mount -a

[root@linuxidc ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/vda1              59G  1.9G  55G  4% /

tmpfs                3.9G    0  3.9G  0% /dev/shm

/dev/mapper/mailbox_vg-mailbox_lv

493G  70M  467G  1% /mail_mailbox

[END] 2016/9/13 9:32:31

这里到此就结束的.整合一下相关的一些步骤:

#fdisk /dev/vdb

#pvcreate /dev/vdb1

#vgcreate mailbox_vg /dev/vdb1

#lvcreate -l 127998 -n mailbox_lv mailbox_vg

#mkfs -t ext4 /dev/mailbox_vg/mailbox_lv

#mkdir /mail_mailbox

#mount /dev/mailbox_vg/mailbox_lv /mail_mailbox/

linux创建目录记录日志,创建LVM的日志记录相关推荐

  1. jenkins构建记录日志_构建企业日志记录层的清单

    jenkins构建记录日志 在有关云迁移服务,数据中心和微服务等大型主题的任何讨论中,企业日志记录主题都可以归结为事后想法. 但是这样做的后果自负,因为如果不进行日志记录,就无法对服务进行有效的诊断和 ...

  2. 思科交换机配置syslog记录日志到syslog watcher日志记录软件

    C3560#config t C3560(config)#logging on C3560(config)#logging host 192.168.210 //日志服务器的IP地址 C3560(co ...

  3. linux查看tcp络连接日志,Linux监控TCP连接数并触发日志记录

    场景 由于服务器经常半夜出现TCP连接数暴增,没办法及时查看处理,回头看记录又看不到现象,不好排查,故编写此脚本用于记录日志. 脚本内容#!/bin/bash #任务计划设置此脚本每分钟执行一次即可, ...

  4. linux磁盘分区创建lvm,Linux下磁盘分区与LVM创建

    Linux下磁盘分区与LVM创建 1. 在系统上添加2块2G的硬盘 2.进入系统以后用fdisk -l 看看两块磁盘是否存在了, 有了磁盘之后,用fdisk和parted 两个工具对磁盘进行分区,现在 ...

  5. 记录日志的测试软件_教程:测试期间的日志记录

    记录日志的测试软件 日志记录是一种流行的解决方案,用于显示软件在运行时的运行状况. 但是,当我们使用jUnit / TestNG对应用程序进行单元测试时,日志记录会怎样? 在自动化测试执行期间,我们通 ...

  6. 基于.NetCore3.1系列 —— 日志记录之自定义日志组件

    前言 回顾:日志记录之日志核心要素揭秘 在上一篇中,我们通过学习了解在.net core 中内置的日志记录中的几大核心要素,在日志工厂记录器(ILoggerFactory)中实现将日志记录提供器(IL ...

  7. TP5日志记录与异常处理

    日志记录 日志配置application/config.php 'log' => [// 日志记录方式,内置 file socket 支持扩展'type' => 'File',// 日志保 ...

  8. 74. 学会使用 SAP ABAP Application Log 在代码里添加应用日志记录功能

    文章目录 ABAP 应用日志对象的概念和创建 如何创建需要通过应用日志记录的消息(message) 使用应用日志创建 API 进行日志记录的创建 使用事物码 SLG1 查看生成的应用日志内容 总结 笔 ...

  9. linux定向查日志_Linux之screen创建、切换、记录屏幕日志

    由于screen的命令太多.太强大,这里扼要的写下screen的创建.切换.恢复会话和窗口缓存log重定向的使用! * 这里假定已经安装好了screen,版本号为:Screen version 4.0 ...

最新文章

  1. 使用java代码代替xml实现SSM
  2. with(nolock)的用法
  3. 初中计算机flash操作,初中信息技术FLASH基础知识
  4. java软件网络工程师面试题_170道Java工程师面试题,你敢挑战吗?
  5. java选填,java选择填空 - osc_ug2wy0bi的个人空间 - OSCHINA - 中文开源技术交流社区
  6. 文件加密问题(中文字符)
  7. WCF入门-项目间调用服务
  8. 主成分分析原理解释(能力工场小马哥)
  9. 如何使用TensorFlow玩转深度学习?
  10. 漫画:如何实现大整数相加
  11. 一招让你拿下seata分布式事务框架,看这篇文章准没错!
  12. Python稳基修炼的经典案例10(计算机二级、初学者必会turtle库例题)
  13. c语言影碟租借管理系统,影碟出租信息管理系统
  14. C语言—— 符号函数
  15. 三角函数公式及工程应用
  16. python 实现批量抠图
  17. 【​观察】六脉神剑第一式-高效之唯快不破
  18. Mac系统 - 升级node版本
  19. 使用 Qt for Android 获取并利用手机传感器数据(上篇)开发环境省心搭建
  20. 前端学习随笔 css篇

热门文章

  1. 微信小程序 蓝牙的使用
  2. sentry使用webpack上传sourceMap源文件定位错误到更详细具体的代码片段
  3. js实现点击自动下载文件
  4. SAFE: Similarity-Aware Multi-Modal Fake News Detection-学习笔记
  5. mysql循环队列_数据结构:循环队列
  6. VuePress 添加百度统计代码
  7. require.context实现前端工程自动化
  8. H5页面在 ios 端滑动不流畅的问题
  9. 响应式布局方法的方法
  10. DeepMind用ReinforcementLearning玩游戏