kvm的img文件的本机挂载
非lvm分区挂载方法:
mount -o loop xxx.img /mnt/xxx
系统提示:
“mount: you must specify the filesystem type”
执行:fdisk -ul xxx.img,和显示一大堆信息,如:
Disk 3059.img: 4294 MB, 4294967296 bytes255 heads, 63 sectors /track , 522 cylinders, total 8388608 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical /physical ): 512 bytes / 512 bytesI /O size (minimum /optimal ): 512 bytes / 512 bytesDisk identifier: 0x000bdbdcDevice Boot Start End Blocks Id System3059.img1 * 63 7903979 3951958+ 83 Linux3059.img2 7903980 8385929 240975 5 Extended3059.img5 7904043 8385929 240943+ 82 Linux swap / Solaris |
看到这行,发现linux的文件系统是从第63块开始的,所以挂载的时候应该从这个地方开始挂载
3059.img1 * 63 7903979 3951958+ 83 Linux
由这条信息可以的出,扇区大小为512
Units = sectors of 1 * 512 = 512 bytes
所以我们需要从512*63出开始挂载
最后执行:
mount -o loop,offset=32256 xxx.img /mnt/xxx……
lvm分区挂载方法:
[root@jay-linux image]# fdisk -lu rhel6u2.img
You must set cylinders.
You can do this from the extra functions menu.
Disk rhel6u2.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00048b34
Device Boot Start End Blocks Id System
rhel6u2.img1 * 2048 1026047 512000 83 Linux
Partition 1 does not end on cylinder boundary.
rhel6u2.img2 1026048 104857599 51915776 8e Linux LVM
Partition 2 has different physical/logical endings:
phys=(1023, 254, 63) logical=(6527, 21, 22)
[root@jay-linux image]# echo $((1026048*512))
525336576
[root@jay-linux image]# losetup /dev/loop0 rhel6u2.img -o 525336576
[root@jay-linux image]# pvscan
PV /dev/loop0 VG VolGroup lvm2 [49.51 GiB / 0 free]
Total: 1 [49.51 GiB] / in use: 1 [49.51 GiB] / in no VG: 0 [0 ]
[root@jay-linux image]# vgchange -ay VolGroup
2 logical volume(s) in volume group "VolGroup" now active
[root@jay-linux image]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
lv_root VolGroup -wi-a--- 45.57g
lv_swap VolGroup -wi-a--- 3.94g
[root@jay-linux image]# mount /dev/VolGroup/lv_root /media/
[root@jay-linux image]# ls /media/
bin cgroup etc lib lost+found misc net proc sbin srv tmp var
boot dev home lib64 media mnt opt root selinux sys usr
(使用完后的卸载操作,如下)
[root@jay-linux image]# umount /media/
[root@jay-linux image]# vgchange -an VolGroup
0 logical volume(s) in volume group "VolGroup" now active
[root@jay-linux image]# losetup -d /dev/loop0 总结:
参考了如下博客:
https://my.oschina.net/toyandong/blog/65002
http://blog.csdn.net/lucien_cc/article/details/11158055
kvm的img文件的本机挂载的更多相关文章
- 手动给kvm虚机挂载lvm卷
1.查看计算节点上虚机挂载的卷 [root@xgto01n010243186070 ~]# virsh domblklist instance- Target Source ------------- ...
- 将.Net Core发布至Docker,并连接 Redis、上传文件到本机、连接sqlserver数据库
此片文章目标是将 .Net Core 发布到 Docker 上,并且连接到在 Docker上的 Redis .上传文件到本机文件夹和连接 sqlserver 数据库. 创建项目 创建项目就不用说了,我 ...
- 怎么从docker中copy文件到 本机
怎么从docker中copy文件到 本机 docker cp <containerId>:/file/path/within/container /host/path/target
- Linux系统下 MYSQL数据库中的数据库文件在本机内迁移 (需暂停服务的方式)
Linux系统下 MYSQL数据库中的数据库文件在本机内迁移 本机采用Ubuntu16.04系统,tar方式安装MySQL5.7.21 数据库安装文件夹为 /home/devil/mysql 现 ...
- linux文件系统命令和分区 挂载
文件系统命令df [选项][挂载点]选项:-a 显示所有的文件系统信息,包括特殊文件,如/proc,/sysfs-h 使用习惯单位显示容量,如KB,MB或GB等-T 显示文件系统类型-m 以MB为单位 ...
- Linux文件系统管理 开机自动挂载及fstab文件修复
概述 开机自动挂载及fstab文件修复 开机自动挂载 实现开机后自动挂载,就需要修改系统的自动挂载文件 /etc/fstab.因为系统就是依赖这个文件决定启动时加载的文件系统的.通过vi 打开/etc ...
- ABAP下载服务器文件到本机
转自http://blog.sina.com.cn/s/blog_701594f40100l8ml.html ABAP:下载服务器文件到本机 对服务器的文件进行读写操作,SAP提供了OPEN DATA ...
- [转] 如何让CloudStack使用KVM创建Windows实例成功识别并挂载数据盘
在使用kvm给windows虚拟机动态挂载virtio类型的硬盘时候遇到问题,通过下面的文章知道需要安装virtio驱动,从而解决问题使挂在正常,在此处mark一下 问题产生背景: 使用CloudSt ...
- Azure: 给 ubuntu 虚机挂载数据盘
在 azure 上创建的虚机默认会分配两个磁盘,分别是系统盘和一个临时磁盘.如果我们要在系统中安装使用 mysql 等软件,需要再创建并挂载单独的数据盘用来保存数据库文件.这是因为临时磁盘被定义为:用 ...
随机推荐
- Sass函数-数字函数-floor()函数
floor() 函数刚好与 ceil() 函数功能相反,其主要将一个数去除其小数部分,并且不做任何的进位.也就是只做舍,不做入的计算: >> floor(2.1) 2 >> f ...
- 谈一谈测试驱动开发(TDD)的好处以及你的理解
DD是指在编写真正的功能实现代码之前先写测试代码,然后根据需要重构实现代码.在JUnit的作者Kent Beck的大作<测试驱动开发:实战与模式解析>(Test-Driven Develo ...
- python输出转义字符
转义字符在字符串中不代表自己,比如\n代表回车,不代表\n字符,那我想输入转义字符本身呢? 答:在字符串前面加个r 如print(“aa\nbb”) 会输出aa bb 如print(r"aa ...
- 【leetcode】1021. Best Sightseeing Pair
题目如下: Given an array A of positive integers, A[i]represents the value of the i-th sightseeing spot, ...
- 【锁】MySQL和Oracle行锁比较
InnoDB INNODB表是索引组织的表,主键是聚集索引,非主键索引都包含主键信息. INNODB默认是行锁. INNODB行锁是通过给索引项加锁来实现的,即只有通过索引条件检索数据,InnoDB才 ...
- jmeter.bat无法启动
jmeter.bat启动时提示:'findstr' 不是内部或外部命令,也不是可运行的程序或批处理文件. 学习中遇到的问题: 'findstr' 不是内部或外部命令,也不是可运行的程序或批处理文件. ...
- SimpleDateFormat线程不安全原因及解决方案
一. 线程不安全验证: /** * SimpleDateFormat线程安全测试 * 〈功能详细描述〉 * * @author 17090889 * @see [相关类/方法](可选) * @sinc ...
- Java反射学习-4 - 反射调用方法
反射调用方法: package cn.tx.reflect; import java.lang.reflect.Constructor; import java.lang.reflect.Method ...
- Python3解leetcode Lowest Common Ancestor of a Binary Search Tree
问题描述: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in ...
- 组合的输出(回溯、dfs)
问题 O: [回溯法]组合的输出 题目描述 排列与组合是常用的数学方法,其中组合就是从n个元素中抽出r个元素(不分顺序且r<=n),我们可以简单地将n个元素理解为自然数1,2,…,n,从中任取r ...