1. [root@cache01 ~]# df -hT
  2. Filesystem Type Size Used Avail Use% Mounted on
  3. /dev/mapper/VolGroup-lv_root
  4. ext4 8.3G 937M 7.0G 12% /
  5. tmpfs tmpfs 119M 0 119M 0% /dev/shm
  6. /dev/vda1 ext4 477M 33M 419M 8% /boot
  7. [root@cache01 ~]#
  8. 生成一块新的硬盘
  9. [root@bass virhost]# qemu-img create -f raw o5cache.add.disk.raw 2G
  10. Formatting '05cache.add.disk.raw', fmt=raw size=2147483648
  11. <disk type='file' device='disk'>
  12. <driver name='qemu' type='raw' cache='none'/>
  13. <source file='/home/virhost/05cache.add.disk.raw'/>
  14. <target dev='vda' bus='virtio'/>
  15. <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
  16. </disk>
  17. [root@bass virhost]# virsh start 05cache
  18. Domain 05cache started
  19.  
  20. [root@bass virhost]# virsh attach-disk 05cache /home/virhost/05cache.add.disk.raw vdb --cache none
  21. Disk attached successfully
  22. virsh edit 05cache---------------->
  23. <disk type='file' device='disk'>
  24. <driver name='qemu' type='raw' cache='none'/>
  25. <source file='/home/virhost/05cache.img'/>
  26. <target dev='vda' bus='virtio'/>
  27. <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
  28. </disk>
  29. <disk type='block' device='cdrom'>
  30. <driver name='qemu' type='raw'/>
  31. <target dev='hdc' bus='ide'/>
  32. <readonly/>
  33. <address type='drive' controller='0' bus='1' target='0' unit='0'/>
  34. </disk>
  35. [root@cache01 ~]# fdisk -l
  36.  
  37. Disk /dev/vda: 10.7 GB, 10737418240 bytes
  38. 16 heads, 63 sectors/track, 20805 cylinders
  39. Units = cylinders of 1008 * 512 = 516096 bytes
  40. Sector size (logical/physical): 512 bytes / 512 bytes
  41. I/O size (minimum/optimal): 512 bytes / 512 bytes
  42. Disk identifier: 0x000c1fb8
  43.  
  44. Device Boot Start End Blocks Id System
  45. /dev/vda1 * 3 1018 512000 83 Linux
  46. Partition 1 does not end on cylinder boundary.
  47. /dev/vda2 1018 20806 9972736 8e Linux LVM
  48. Partition 2 does not end on cylinder boundary.
  49.  
  50. Disk /dev/vdb: 2147 MB, 2147483648 bytes #挂上的新的硬盘
  51. 16 heads, 63 sectors/track, 4161 cylinders
  52. Units = cylinders of 1008 * 512 = 516096 bytes
  53. Sector size (logical/physical): 512 bytes / 512 bytes
  54. I/O size (minimum/optimal): 512 bytes / 512 bytes
  55. Disk identifier: 0x00000000
  56.  
  57. Disk /dev/mapper/VolGroup-lv_root: 9168 MB, 9168748544 bytes
  58. 255 heads, 63 sectors/track, 1114 cylinders
  59. Units = cylinders of 16065 * 512 = 8225280 bytes
  60. Sector size (logical/physical): 512 bytes / 512 bytes
  61. I/O size (minimum/optimal): 512 bytes / 512 bytes
  62. Disk identifier: 0x00000000
  63.  
  64. Disk /dev/mapper/VolGroup-lv_swap: 1040 MB, 1040187392 bytes
  65. 255 heads, 63 sectors/track, 126 cylinders
  66. Units = cylinders of 16065 * 512 = 8225280 bytes
  67. Sector size (logical/physical): 512 bytes / 512 bytes
  68. I/O size (minimum/optimal): 512 bytes / 512 bytes
  69. Disk identifier: 0x00000000

在虚拟机中对硬盘进行格式化

  1. [root@cache01 ~]# mkfs.ext4 /dev/vdb
  2. mke2fs 1.41.12 (17-May-2010)
  3. Filesystem label=
  4. OS type: Linux
  5. Block size=4096 (log=2)
  6. Fragment size=4096 (log=2)
  7. Stride=0 blocks, Stripe width=0 blocks
  8. 131072 inodes, 524288 blocks
  9. 26214 blocks (5.00%) reserved for the super user
  10. First data block=0
  11. Maximum filesystem blocks=536870912
  12. 16 block groups
  13. 32768 blocks per group, 32768 fragments per group
  14. 8192 inodes per group
  15. Superblock backups stored on blocks:
  16. 32768, 98304, 163840, 229376, 294912
  17.  
  18. Writing inode tables: done
  19. Creating journal (16384 blocks): done
  20. Writing superblocks and filesystem accounting information: done
  21.  
  22. This filesystem will be automatically checked every 34 mounts or
  23. 180 days, whichever comes first. Use tune2fs -c or -i to override.

接下来建一个目录来挂载新的硬盘:

  1. [root@cache01 ~]# mkdir /nd
  2. [root@cache01 ~]# mkdir /nd
  3. [root@cache01 ~]# mount /dev/vdb /nd/
  4. #获取硬盘的UUID
  5. [root@cache01 ~]# blkid /dev/vdb
  6. /dev/vdb: UUID="a35e0890-3aa6-47a7-921c-c2cb9dd431e6" TYPE="ext4"

将挂载添加到开机启动中:

  1. [root@cache01 ~]# cat /etc/fstab
  2.  
  3. #
  4. # /etc/fstab
  5. # Created by anaconda on Tue Jun 28 08:57:38 2016
  6. #
  7. # Accessible filesystems, by reference, are maintained under '/dev/disk'
  8. # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
  9. #
  10. /dev/mapper/VolGroup-lv_root / ext4 defaults 1 1
  11. UUID=04e8e77f-2604-4683-833b-a06a7300c7a3 /boot ext4 defaults 1 2
  12. /dev/mapper/VolGroup-lv_swap swap swap defaults 0 0
  13. tmpfs /dev/shm tmpfs defaults 0 0
  14. devpts /dev/pts devpts gid=5,mode=620 0 0
  15. sysfs /sys sysfs defaults 0 0
  16. proc /proc proc defaults 0 0
  17. UUID=a35e0890-3aa6-47a7-921c-c2cb9dd431e6 /nd ext4 defaults 1 2
  1. [root@cache01 ~]# df -h
  2. Filesystem Size Used Avail Use% Mounted on
  3. /dev/mapper/VolGroup-lv_root
  4. 8.3G 644M 7.3G 9% /
  5. tmpfs 119M 0 119M 0% /dev/shm
  6. /dev/vda1 477M 33M 419M 8% /boot
  7. /dev/vdb 2.0G 3.0M 1.9G 1% /nd

KVM中Linux虚拟机的硬盘添加方法的更多相关文章

  1. VMWare中Linux虚拟机设置静态IP上网的设置方法

    VMWare中Linux虚拟机设置静态IP上网的设置方法 标签: vmwareLinux虚拟机securecrt静态IP上网 2016-05-18 02:30 702人阅读 评论(0) 收藏 举报   ...

  2. VirtualBox中Linux虚拟机与主机共享文件夹

    VirtualBox中Linux虚拟机与主机共享文件夹 一.Linux虚拟机安装增强功能 二.点击虚拟机 设置-->选择 共享文件夹-->点击右侧的带加号的文件夹图标,执行下面的操作1. ...

  3. 在VMware上克隆Linux虚拟机及其网卡配置方法

    最近在搭建Hadoop集群,1个Master,3个Workers.使用VMware workstations创建Linux虚拟机,版本是CentOS7.安装完成并做了相应的网络配置后,使用VMware ...

  4. [linux]vmware中linux虚拟机扩容 标签: vmware虚拟机linux 2016-09-05 08:03 315人阅读 评

    扩容原因 现阶段,虚拟机的标配都是1G内存和20G硬盘,大部分时候是够用的,但是也会出现虚拟机里面东西放多了硬盘不够用的情况,这种情况下,除了清理垃圾,另外就只能给虚拟机扩容了.因为window扩容相 ...

  5. VMware Esxi5.5中嵌套虚拟机的网络设置方法

    环境: Esxi5.5服务器->虚拟机(WinServer2008R2)->VMware WorkStation(Win7虚拟机) 网络问题: VMware WorkStation中的虚拟 ...

  6. VMware中Linux虚拟机与Windows主机共享文件夹

    VMware下Linux虚拟机与Windows主机共享文件夹 1. 安装vm-tool 2. 开启共享文件夹 虚拟机->设置->选项->共享文件夹"右边选择"总是 ...

  7. vmware中linux虚拟机使用NAT模式不能连接外网解决

    linux虚拟机一直配置的桥接模式,今天改成NAT模式发现不能上外网 环境:VMware12,CentOS 6.8,NAT模式 ①电脑实际ip:192.168.1.100 ②NAT使用虚拟网卡网关: ...

  8. Vbox中Linux虚拟机网络配置(比较实用)

    好久没写过东西了,主要大部分都是来自对生活的感悟,很少有实实在在的关于学得有成就感的技术可以“炫耀”,所以也就懒得在这个上面登了. 实验室很早就有位师兄曾在吃饭的路上问过我们这群小弟,你们知道Vbox ...

  9. xenserver中linux虚拟机修改启动顺序

    xenserver是思杰的一款类似于vmware ESXI的虚拟化平台,或者说虚拟化操作系统,上面可以安装许多虚拟机,但是当你装完linux虚拟机,你会发现一个问题,不能像windows vm那样直接 ...

随机推荐

  1. BurpSuite之HTTP brute暴力破解

    常规的对username/passwprd进行payload测试,我想大家应该没有什么问题,但对于Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=这样的问题, ...

  2. MySQL使用痕迹清理~/.mysql_history

    mysql会给出我们最近执行的SQL命令和脚本:同linux command保存在~/.bash_history一样,你用mysql连接MySQL server的所有操作也会被记录到~/.mysql_ ...

  3. Spring入门_01

    <bean id="userAction" class="com.umgsai.spring.UserAction"> <property n ...

  4. Component creation must be done on Event Dispatch Thread错误解决方法

    在用java swing 做例子,给页面设置皮肤样式的时候出现了这个错误: org.jvnet.substance.api.UiThreadingViolationException: Compone ...

  5. mysql字符串截取

    mysql字符串截取 update zcat ) where lev1 is null; update zcat ) where lev2 is null; 函数: 1.从左开始截取字符串 left( ...

  6. DEDECMS 后台登录空白怎么办 后台无法登陆

    刚安装完dedecms,兴致冲冲的准备进后台,输入完用户名和密码后,页面 中显示一片空白. 立马到网上搜搜,发现大家各抒己见,但是都没有解决问题. 不过,下面的这个方法是可以的.马上记录下来,以备其他 ...

  7. SecureCRT光标颜色

    SecureCRT连linux光标一直没有,尤其是在vim编辑文档的时候特别麻烦,今天找出解决办法: 选项->会话选项->仿真:将ANSI颜色选中: 选项->会话选项->外观: ...

  8. POJ 1191 棋盘分割

    棋盘分割 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11213 Accepted: 3951 Description 将一个 ...

  9. 关于windows程序的学习及思考系列之一

    1.窗口类的注册 a.windows程序中最简单的就是创建一个简单的窗口,而窗口程序的创建是基于窗口类的,窗口类决定了处理窗口消息的过程函数. b.一个窗口类可以用于创建多个窗口,也就是说窗口是窗口类 ...

  10. lvs之ip-tun(ip隧道)技术的学习与实践

    1.配置测试环境 修改IP windows 200.168.10.4 lvs server  ip:200.168.10.1 因为IP隧道模式只需要一个网卡  所以就停掉其他网卡 web server ...