LinuxSir.Org  
| 网站首页 | 论坛帮助 |

欢迎来到LinuxSir.Org!
您还未登录,请登录后查看论坛,或者点击论坛上方的注册链接注册新账号。


发表新主题 回复
精华主题  
主题工具
旧 08-08-08, 19:56 第 1 帖
allisfree
 
allisfree 的头像
 
 
注册会员  
  注册日期: Mar 2003
  帖子: 707
  精华: 2
 

标题: ·[教程]挂载archlinux的img文件


1. 先查看第一个空闲loop设备
代码:
sudo losetup -f /dev/loop0
2. 使用上一步得到的设备名,第一次创建loop设备
代码:
sudo losetup /dev/loop0 archlinux-2008.06-core-i686.img
3. 查看信息
代码:
sudo fdisk -lu /dev/loop0 Disk /dev/loop0: 322 MB, 322469376 bytes 53 heads, 12 sectors/track, 990 cylinders, total 629823 sectors Units = sectors of 1 * 512 = 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/loop0p1 * 63 629822 314880 83 Linux Partition 1 has different physical/logical beginnings (non-Linux?): phys=(0, 1, 1) logical=(0, 5, 4) Partition 1 has different physical/logical endings: phys=(39, 52, 12) logical=(990, 15, 3)
我们可以看到,该镜像只有一个分区(loop0p1),从第63扇区开始(Start列),每扇区512字节(Units = sectors of 1 * 512 = 512 bytes),我们算出offset,下面mout命令会用到:
代码:
63*512=32256
4. mout
代码:
sudo losetup -o 32256 /dev/loop1 archlinux-2008.06-core-i686.img sudo mount -o loop /dev/loop1 /mnt/ ls /mnt/ addons archlive.sqfs boot lost+found
事实上,fdisk可以直接查看img文件(虽然功能不全,下面会说到),mount可以自动创建loop设备,所以上面步骤可以简化为:
I. 查看信息
代码:
sudo fdisk -lu archlinux-2008.06-core-i686.img You must set cylinders. You can do this from the extra functions menu. Disk archlinux-2008.06-core-i686.img: 0 MB, 0 bytes 53 heads, 12 sectors/track, 0 cylinders, total 0 sectors Units = sectors of 1 * 512 = 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System archlinux-2008.06-core-i686.img1 * 63 629822 314880 83 Linux Partition 1 has different physical/logical beginnings (non-Linux?): phys=(0, 1, 1) logical=(0, 5, 4) Partition 1 has different physical/logical endings: phys=(39, 52, 12) logical=(990, 15, 3)
第一行抱怨不能得到cylinders,原因是普通文件上没有实现ioctl操作,我们可以看到0 cylinders,但这对我们不重要,关键是我们依然可以得到第一个分区(archlinux-2008.06-core-i686.img1)的偏移值

II. 直接mount
代码:
sudo mount -o loop,offset=32256 archlinux-2008.06-core-i686.img /mnt/ ls /mnt/ addons archlive.sqfs boot lost+found
参考Loop-mounting partitions from a disk image
  allisfree 当前离线   回复时引用此帖
旧 08-08-08, 23:00 第 2 帖
gsli52
 
 
 
注册会员  
  注册日期: Aug 2007
  我的住址: 四川什邡
  帖子: 387
  精华: 0
 

可以修改不?我的1G优盘。。被活活阉割了。。
然后自己把后面空间分区了。。







__________________
该用户已被禁言!
  gsli52 当前离线   回复时引用此帖
旧 08-08-09, 11:19 第 3 帖
allisfree
 
allisfree 的头像
 
 
注册会员  
  注册日期: Mar 2003
  帖子: 707
  精华: 2
 

想怎么修改?想使它占据1G?那好象有点浪费啊
  allisfree 当前离线   回复时引用此帖
旧 09-03-28, 11:50 第 4 帖
adam8157
 
adam8157 的头像
 
 
注册会员  
  注册日期: Mar 2009
  帖子: 1,024
  精华: 0
 

img也是grub的,看看它的参数,文件复制过去参数启动就ok啦,正宗的硬盘安装。

测试成功







__________________
我的博客
http://adam8157.info/

我的配置文件, 脚本和开源项目
http://adam8157.info/projects/

此帖于 09-03-28 12:21 被 adam8157 编辑. 原因: 测试成功
  adam8157 当前离线   回复时引用此帖
旧 09-03-28, 16:07 第 5 帖
cwjiof
 
cwjiof 的头像
 
 
注册会员  
  注册日期: Mar 2006
  帖子: 624
  精华: 0
 

赞一个!我还真是不知道怎样挂载它。
  cwjiof 当前离线   回复时引用此帖
旧 09-03-28, 17:11 第 6 帖
nonplus
 
nonplus 的头像
 
 
注册会员  
  注册日期: Jan 2009
  帖子: 645
  精华: 0
 

挂载
mount -o loop /path/to/img /where/to/mount

安装
dd if=/path/to/img of=/dev/sdX
  nonplus 当前离线   回复时引用此帖
旧 09-03-28, 19:10 第 7 帖
cwjiof
 
cwjiof 的头像
 
 
注册会员  
  注册日期: Mar 2006
  帖子: 624
  精华: 0
 

楼上的,没有指定偏移值选项,你就能把archlinux的img文件挂载成功?!
  cwjiof 当前离线   回复时引用此帖
旧 09-04-13, 12:31 第 8 帖
axlrose
 
 
 
注册会员  
  注册日期: Feb 2006
  我的住址: 四川成都
  帖子: 1,463
  精华: 2
 

完全能行,验证过了,不过有网友用这种方法挂 monoWall的img没成功
我测试用的是archlinux liveusb image完全OK







__________________
gentoo archlinux debian freebsd amd3600+ T61
GunsNRose

我的百度BLOG: http://hi.baidu.com/3444542
  axlrose 当前离线   回复时引用此帖
发表新主题 回复


主题工具

发帖规则
您 [不可以] 发表新主题
您 [不可以] 回复主题
您 [不可以] 上传附件
您 [不可以] 编辑您的帖子

已 [启用] BB 代码
已 [启用] 表情符号
已 [启用] IMG 代码
已 [禁用] HTML 代码
[论坛跳转…]


所有时间均为[北京时间]。现在的时间是 08:27


Powered by vBulletin 版本 3.6.8
版权所有 ©2000 - 2012, Jelsoft Enterprises Ltd.
官方中文技术支持: vBulletin 中文
版权所有 ©2002 - 2011, LinuxSir.Org