新增两块硬盘,来进行实验:

[root@jp ~]# fdisk -l

Disk /dev/sda: 107.3 GB, 107374182400 bytes

255 heads, 63 sectors/track, 13054 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1         255     2048256   83  Linux

/dev/sda2             256         777     4192965   82  Linux swap / Solaris

/dev/sda3             778       13054    98615002+  83  Linux

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

随便将/dev/sdb分成三个区

[root@jp ~]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. 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)

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-652, default 1): 1

Last cylinder or +size or +sizeM or +sizeK (1-652, default 652): +1000M

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (124-652, default 124):

Using default value 124

Last cylinder or +size or +sizeM or +sizeK (124-652, default 652): +2000M

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 3

First cylinder (368-652, default 368):

Using default value 368

Last cylinder or +size or +sizeM or +sizeK (368-652, default 652):

Using default value 652

Command (m for help): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         123      987966   83  Linux

/dev/sdb2             124         367     1959930   83  Linux

/dev/sdb3             368         652     2289262+  83  Linux

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: Device or resource busy.

The kernel still uses the old table.

The new table will be used at the next reboot.

Syncing disks.

/dev/sdc随便分两个区:

[root@jp ~]# fdisk /dev/sdc

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. 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)

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-652, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-652, default 652): +2000M

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (245-652, default 245):

Using default value 245

Last cylinder or +size or +sizeM or +sizeK (245-652, default 652):

Using default value 652

Command (m for help): p

Disk /dev/sdc: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1         244     1959898+  83  Linux

/dev/sdc2             245         652     3277260   83  Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

将全部分区创建PV

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

Physical volume "/dev/sdb1" successfully created

[root@jp ~]# pvcreate /dev/sdb2

Physical volume "/dev/sdb2" successfully created

[root@jp ~]# pvcreate /dev/sdb3

Physical volume "/dev/sdb3" successfully created

[root@jp ~]# pvcreate /dev/sdc1

Physical volume "/dev/sdc1" successfully created

[root@jp ~]# pvcreate /dev/sdc2

Physical volume "/dev/sdc2" successfully created

创建VG。将/dev/sdb1和/dev/sdc1放到该VG中

[root@jp ~]# vgcreate test1 /dev/sdb1 /dev/sdc1

/dev/cdrom: open failed: No medium found

Volume group "test1" successfully created

向VG中添加磁盘:

[root@jp ~]# vgextend test1 /dev/sdb2

Volume group "test1" successfully extended

查看VG信息:

[root@jp ~]# vgdisplay

--- Volume group ---

VG Name               test1

System ID

Format                lvm2

Metadata Areas        3

Metadata Sequence No  4

VG Access             read/write

VG Status             resizable

MAX LV                0

Cur LV                1

Open LV               1

Max PV                0

Cur PV                3

Act PV                3

VG Size               4.68 GB

PE Size               4.00 MB

Total PE              1197

Alloc PE / Size       300 / 1.17 GB

Free  PE / Size       897 / 3.50 GB

VG UUID               0ux9KE-yHJP-07Y0-9yCd-ppG2-wWe0-78nLbh

创建LV,从VG:test1中拿出1000M给该LV:lv_test1

[root@jp ~]# lvcreate -L 1000M -n lv_test1 test1

Logical volume "lv_test1" created

格式化LV,LV仅仅有在格式化之后才干存储数据

[root@jp ~]# mke2fs -j /dev/test1/lv_test1

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

128000 inodes, 256000 blocks

12800 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=264241152

8 block groups

32768 blocks per group, 32768 fragments per group

16000 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 33 mounts or

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

挂载LV:

[root@jp ~]# mkdir /test

[root@jp ~]# mount /dev/test1/lv_test1 /test

[root@jp ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda3              92G   20G   67G  23% /

/dev/sda1             1.9G   42M  1.8G   3% /boot

tmpfs                1014M     0 1014M   0% /dev/shm

/dev/mapper/test1-lv_test1

985M   18M  918M   2% /test

挂载之后,能够但到此LV的容量。

假设要在系统启动的时候启动LV,最好是将LV01写入fstable文件里

调整LV的大小

[root@jp ~]# lvresize -L +200M /dev/test1/lv_test1

Extending logical volume lv_test1 to 1.17 GB

Logical volume lv_test1 successfully resized

[root@jp ~]# resize2fs /dev/test1/lv_test1

resize2fs 1.39 (29-May-2006)

Filesystem at /dev/test1/lv_test1 is mounted on /test; on-line resizing required

Performing an on-line resize of /dev/test1/lv_test1 to 307200 (4k) blocks.

The filesystem on /dev/test1/lv_test1 is now 307200 blocks long.

【Linux】lvm基础操作的更多相关文章

  1. Linux LVM 简单操作

    查看当前磁盘分区情况fdisk -l 磁盘分区fdisk /dev/sdb# 可能用到的Type :# 8e Linux LVM# fd Linux raid auto 创建PVpvcreate /d ...

  2. linux lvm的操作手册_pvcreate_vgcreate_lvcreate_相关

    一. 前言 每个Linux使用者在安装Linux时都会遇到这样的困境:在为系统分区时,如何精确评估和分配各个硬盘分区的容量,因为系统管理员不但要考虑到当前某 个分区需要的容量,还要预见该分区以后可能需 ...

  3. Linux的基础操作

    1.概念 Linux是基于Unix的开源免费的操作系统,由于系统的稳定性和安全性几乎成为程序代码运行的最佳系统环境. 2.Linux的分类 1.按市场需求分为: 图形化界面版.服务器版 2.按原生程度 ...

  4. Linux - 系统基础操作

    wall # 给其它用户发消息 whereis ls # 查找命令的目录 which # 查看当前要执行的命令所在的路径 clear # 清空整个屏幕 reset # 重新初始化屏幕 cal # 显示 ...

  5. Linux mysql 基础操作

    命令  #查看版本 mysql --version   #进入mysql 命令 mysql -u root -p mysql -u root@localhost  (没有密码的情况)   #创建数据库 ...

  6. Linux命令基础操作--vim 归档 压缩 分区 格式化 挂载 Innode

    1 将用户信息数据库文件和组信息数据库文件纵向合并为一个文件/1.txt(覆盖) 使用 cat命令将查看的文件合并输出到/1.txt 这里的关键:定位到文件,如果后面加上/后被认为是目录 分为两步,先 ...

  7. 假期学习【一】Ubuntu中Linux的基础操作

    题目: Linux 系统的安装和常用命令 姓名: 赵路仓 日期: 2020.1.24 实验环境: Ubuntu 实验内容与完成情况: (1)切换到目录 /usr/bin: (2)查看目录/usr/lo ...

  8. Linux Mysql基础操作

    1). 打开MySQL 使用如下两条命令,打开MySQL服务并使用root用户登录: # 启动 MySQL 服务 sudo service mysql start # 使用 root 用户登录,实验楼 ...

  9. linux之基础操作

随机推荐

  1. 【智能家居篇】wifi网络接入原理(上)——扫描Scanning

    转载请注明出处:http://blog.csdn.net/Righthek 谢谢! 对于低头党来说,在使用WIFI功能时,常常性的操作是打开手机上的WIFI设备,搜索到心目中的热点,输入passwor ...

  2. Codeforces Round #296 (Div. 2) A. Playing with Paper

    A. Playing with Paper One day Vasya was sitting on a not so interesting Maths lesson and making an o ...

  3. uva 11355(极角计算)

    传送门:Cool Points 题意:给一个圆心为原点的圆和一些线段,问所有线段两端点与圆心连线构成的角度总和占总360度的百分比. 分析:首先将所有线段的两端点变成极角,然后排序(范围[-PI,PI ...

  4. virtenv 0.8.6 发布,虚拟桌面配置工具 - 开源中国社区

    virtenv 0.8.6 发布,虚拟桌面配置工具 - 开源中国社区 virtenv 0.8.6 发布,virtenv 是一个用 QT4 开发的应用,用来配置和启动基于 LXC 的虚拟桌面环境.该容器 ...

  5. Android支付接入(八):Amazon亚马逊支付

    下面跟大家一起走一遍Amazon亚马逊的支付,亚马逊目前刚把业务拓展到大陆市场,但这并不代表Amazon支付不成熟,恰恰相反,Amazon的支付流程,支付结果获取及测试另人称赞,支付流程.测试流程简洁 ...

  6. 提领NULL指针

    通常之中导致程序崩溃的最重要的原因是试图取消引用NULL指针.正如在以前的文章中指出,智能指针RefCountPtr和ScopedPtr它提供了一个诊断的执行时间. 但,并不是所有的指针是所有的对象都 ...

  7. C# 计算字符串/文件的哈希值(MD5、SHA)

    原文 C# 计算字符串的哈希值(MD5.SHA) 已做修改 一.关于本文 本文中是一个类库,包括下面几个函数: /// 1)计算32位MD5码(大小写):Hash_MD5_32 /// 2)计算16位 ...

  8. C#多线程问题整合

    一.跨进程访问组件 错误:线程间操作无效: 从不是创建控件“XXX”的线程访问它 解决方法: 1:把CheckForIllegalCrossThreadCalls设置为false 这个方法只是不去捕获 ...

  9. auto_ptr and scoped_ptr

    #include "boost/scoped_ptr.hpp" #include <iostream> #include <memory>//contain ...

  10. Android版本铎A梦幻连连看游戏源代码完整版

    我写主代码,没有版权问题,它少量小游戏和应用源代码稍后会陆续上线!哆啦A梦连连看包含了2种游戏模式和60关卡,并能够通过改动配置文件非常方便的实现自行添加新关卡.採用andengine游戏引擎开发,内 ...