非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 bytes
255 heads, 63 sectors /track , 522 cylinders, total 8388608 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: 0x000bdbdc
 
Device Boot Start End Blocks Id System
3059.img1 * 63 7903979 3951958+ 83 Linux
3059.img2 7903980 8385929 240975 5 Extended
3059.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文件的本机挂载的更多相关文章

  1. 手动给kvm虚机挂载lvm卷

    1.查看计算节点上虚机挂载的卷 [root@xgto01n010243186070 ~]# virsh domblklist instance- Target Source ------------- ...

  2. 将.Net Core发布至Docker,并连接 Redis、上传文件到本机、连接sqlserver数据库

    此片文章目标是将 .Net Core 发布到 Docker 上,并且连接到在 Docker上的 Redis .上传文件到本机文件夹和连接 sqlserver 数据库. 创建项目 创建项目就不用说了,我 ...

  3. 怎么从docker中copy文件到 本机

    怎么从docker中copy文件到 本机 docker cp <containerId>:/file/path/within/container /host/path/target

  4. Linux系统下 MYSQL数据库中的数据库文件在本机内迁移 (需暂停服务的方式)

    Linux系统下 MYSQL数据库中的数据库文件在本机内迁移 本机采用Ubuntu16.04系统,tar方式安装MySQL5.7.21 数据库安装文件夹为    /home/devil/mysql 现 ...

  5. linux文件系统命令和分区 挂载

    文件系统命令df [选项][挂载点]选项:-a 显示所有的文件系统信息,包括特殊文件,如/proc,/sysfs-h 使用习惯单位显示容量,如KB,MB或GB等-T 显示文件系统类型-m 以MB为单位 ...

  6. Linux文件系统管理 开机自动挂载及fstab文件修复

    概述 开机自动挂载及fstab文件修复 开机自动挂载 实现开机后自动挂载,就需要修改系统的自动挂载文件 /etc/fstab.因为系统就是依赖这个文件决定启动时加载的文件系统的.通过vi 打开/etc ...

  7. ABAP下载服务器文件到本机

    转自http://blog.sina.com.cn/s/blog_701594f40100l8ml.html ABAP:下载服务器文件到本机 对服务器的文件进行读写操作,SAP提供了OPEN DATA ...

  8. [转] 如何让CloudStack使用KVM创建Windows实例成功识别并挂载数据盘

    在使用kvm给windows虚拟机动态挂载virtio类型的硬盘时候遇到问题,通过下面的文章知道需要安装virtio驱动,从而解决问题使挂在正常,在此处mark一下 问题产生背景: 使用CloudSt ...

  9. Azure: 给 ubuntu 虚机挂载数据盘

    在 azure 上创建的虚机默认会分配两个磁盘,分别是系统盘和一个临时磁盘.如果我们要在系统中安装使用 mysql 等软件,需要再创建并挂载单独的数据盘用来保存数据库文件.这是因为临时磁盘被定义为:用 ...

随机推荐

  1. demo板 apt-get install stress

    demo 那个网口 没有绑定mac 大电脑绑定了mac 大电脑上网认证系统:http://1.1.1.2 大电脑mac:6C-4B-90-3C-D5-7B 将demo板的mac改为大电脑mac ifc ...

  2. 第三节 基本数据写入 --------增加&查询

    启动mongodb服务 net start mongodb 链接mongodb  进入bin目录 mongo 127.0.0.1:12345 启动连接 show dbs   显示所有的数据库 use ...

  3. python 利用subprocess调用cmd命令程序,并正确输出控制台的输出中文

    平台Python3.7 1.利用控制台运行程序后在控制台会输出中文提示,但是用python调用subprocess.run函数后返回的输出是乱码,于是,解决方法是用subprocess.check_o ...

  4. 【leetcode】1012. Complement of Base 10 Integer

    题目如下: Every non-negative integer N has a binary representation.  For example, 5 can be represented a ...

  5. HttpClient之EntityUtils工具类

    今天看到tttpclient-tutorial上面有这样一句话-----非常的不推荐使用EntityUtils,除非知道Entity是来自可信任的Http Server 而且还需要知道它的最大长度.文 ...

  6. Shiro安全框架的说明及配置入门

    Shiro是什么? Shiro是一个非常强大的,易于使用的,开源的,权限框架.它包括了权限校验,权限授予,会话管理,安全加密等组件 什么时候使用它呢? 如果你是设计RBAC基础系统,需要编写大量用于权 ...

  7. MIS(管理信息系统)

    MIS 管理信息系统(Management Information System,简称MIS) 是一个以人为主导,利用计算机硬件.软件.网络通信设备以及其他办公设备,进行信息的收集.传输.加工.储存. ...

  8. spring cloud gateway 拦截request Body

    在接入Spring-Cloud-Gateway时,可能有需求进行缓存Json-Body数据或者Form-Urlencoded数据的情况. 由于Spring-Cloud-Gateway是以WebFlux ...

  9. ExecutorException: A query was run and no Result Maps were found for the Mapped Statement ‘com.win.mall.dao.CartMapper.test’. It’s likely that neither a Result Type nor a Result Map was specified.

    ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'com.win.m ...

  10. Windows 08R2_AD图文详解

    目录 目录 软件环境 Active Directory域服务 AD的应用 创建ADDS域 使用Windows窗口来创建ADDS域控制器 使用Powershell来创建ADDS域控制器 检查ADDC域控 ...