kvm虚拟机挂载lvm卷

原创 2017年08月11日 21:20:31

kvm虚拟机挂载lvm卷

virsh attach-disk kvm-3 /dev/vg_shkvm3/kvm-3-data vdb --driver qemu --mode shareable

登录到kvm-3

[root@sh-kvm-3-3 ~]# fdisk -l

Disk /dev/vda: 21.5 GB, 21474836480 bytes
16 heads, 63 sectors/track, 41610 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00002155

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3        1018      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2            1018       41611    20458496   8e  Linux LVM
Partition 2 does not end on cylinder boundary.

Disk /dev/mapper/VolGroup-lv_root: 18.8 GB, 18798870528 bytes
255 heads, 63 sectors/track, 2285 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


Disk /dev/mapper/VolGroup-lv_swap: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 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


Disk /dev/vdb: 53.7 GB, 53687091200 bytes
16 heads, 63 sectors/track, 104025 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
[root@sh-kvm-3-3 ~]# fdisk /dev/vdb #分区 
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x93edb871.
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)

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): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-104025, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-104025, default 104025): 
Using default value 104025

Command (m for help): p

Disk /dev/vdb: 53.7 GB, 53687091200 bytes
16 heads, 63 sectors/track, 104025 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x93edb871

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1      104025    52428568+  83  Linux

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): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
  • 挂载lvm 到data目录
mkfs.ext4 /dev/vdb1
pvcreate /dev/vdb1
vgextend VolGroup /dev/vdb1
lvcreate -n data -L 30G VolGroup
mkdir /data
mkfs.ext4 /dev/VolGroup/data
mount /dev/VolGroup/data  /data/
echo "/dev/mapper/VolGroup-data    /data                   ext4    defaults        1 1"  >> /etc/fstab
  • 扩容根目录
# lvextend -l +100%FREE /dev/mapper/VolGroup-lv_root
# resize2fs /dev/mapper/VolGroup-lv_root
# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      103G   40G   58G  41% /
tmpfs                 4.9G   12K  4.9G   1% /dev/shm
/dev/xvda1            477M  153M  299M  34% /boot
版权声明:本文为木偶人shaon原创文章,转载请注明原文地址,非常感谢。

经典KVM详解,太详细太深入了

KVM 介绍(1):简介及安装 http://www.cnblogs.com/sammyliu/p/4543110.html 学习 KVM 的系列文章:  (1)介绍和安装 (...

RHCE认证之LVM、软RAID5和KVM虚拟机

三、搭建KVM虚拟机 RHCL6 KVM支持条件:rhel-server-6.0_x64和cpu支持虚拟化 查看cpu是否支持虚拟化技术:cat /proc/cpuinfo |grep "vm...
  • AWHANE
  • AWHANE
  • 2015年01月27日 15:54
  • 297

使用guestmount挂载KVM虚拟机的磁盘

在宿主机中,挂载非Raw格式的客户机磁盘需要使用软件包libguestfs和libguestfs-tools。 使用如下命令查看系统中是否安装相应软件包。 [root@manager kvm]# rp...
  • zdq0394
  • zdq0394
  • 2016年04月26日 15:19
  • 3913

在qemu kvm虚拟机中挂载硬盘分区的方法总结

转载注明:http://blog.csdn.net/hubbybob1/article/details/76889846 通过qemu创建的虚拟机之后想对虚拟机进行扩充或者添加几个新的硬盘,因此在此...

linux kvm虚拟机img文件挂载到宿主机

在使用虚拟化的过程中,难免会遇到虚拟机异常导致无法启动等故障,这时候如何从虚拟机的img中将重要文件或数据拷贝出来显得尤为重要,今天介绍一下利用qemu-nbd的方式将img文件挂载到宿主机。 需要...

KVM存储池与存储卷,使用virt-install创建虚拟机

KVM存储池与存储卷,使用virt-install创建虚拟机 参考链接:http://blog.sina.com.cn/s/blog_53ab41fd01013rcg.html   在机器上...

KVM存储池与存储卷,使用virt-install创建虚拟机

http://blog.sina.com.cn/s/blog_53737d110100xabl.html   在机器上装了一个Centos6.2用来测试KVM,对比Windows下的VMwar...

lvm虚拟机设计与实现

  • 2009年06月27日 14:08
  • 165KB
  • 下载

KVM虚拟机网络环境介绍

  • 2015年07月08日 12:36
  • 554KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:kvm虚拟机挂载lvm卷
举报原因:
原因补充:

(最多只允许输入30个字)