专栏首页运维前线kvm虚拟机挂载lvm卷

kvm虚拟机挂载lvm卷

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

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • KVM 初探

    KVM 是业界最为流行的 Hypervisor,全称是 Kernel-based Virtual Machine。它是作为 Linux kernel 中的一个内...

    CloudDeveloper
  • KVM 操作虚拟机常用命令

    管理kvm虚拟机 常用的虚拟机管理命令 列出所有的虚拟机 virsh list --all 显示虚拟机信息 virsh dominfo kvm-1 显示虚...

    shaonbean
  • 内存虚拟化

    虚拟内存 我们知道,早期的计算机内存,只有物理内存,而且空间是极其有限的,每个应用或进程在使用内存时都得小心翼翼,不能覆盖别的进程的内存区。 为了避免这些问题,...

    CloudDeveloper
  • 使用CentOS7 kvm虚拟机安装蓝鲸社区版(3.15)

    使用C7 kvm虚拟机安装蓝鲸平台 蓝鲸介绍 蓝鲸官网: http://bk.tencent.com/ 蓝鲸社区版本下载:http://bk.tencent.c...

    shaonbean
  • kvm基础使用及Virt-tools工具使用

    kvm基础使用 查看虚拟机状态 [root@sh-kvm-1 ~]# virsh list --all Id Name ...

    shaonbean
  • KVM 实战虚拟机克隆

    KVM克隆虚拟机 使用克隆的方式保存两台vm配置完全一致。 暂停虚拟机(suspend)用于克隆 [root@sh-kvm-2 ~]# virsh sus...

    shaonbean
  • CentOS6 最小化安装KVM 详细教程

    CentOS6 mininial 安装KVM 详细教程 系统初始化设置 # CentOS6 最小化安装完成后初始化 ## 关闭防火墙和SELINUX /et...

    shaonbean
  • CentOS 7 安装KVM,并创建虚拟机

    使用KVM(基于内核的虚拟机)+ QEMU的虚拟化。 需要具有Intel VT或AMD-V功能的CPU。 安装KVM [root@kvm-centos7 ...

    shaonbean
  • mydate97时间控件的使用

    mydate97官网: http://www.my97.net/dp/index.asp   1:用法如下所示,首先下载一个这个东西:     链接:http:...

    别先生

扫码关注云+社区

领取腾讯云代金券