QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 934|回复: 8

关于loop device问题请教

[复制链接]
发表于 2003-8-20 09:10:45 | 显示全部楼层 |阅读模式
我在Redhat8,内核是2.4.18-14,想通过以下操作
losetup /dev/loop0 /dev/hda1
mount -t rw /dev/loop0 /mnt/loop

把/dev/hda1映射为一个loop0设备,操作完成后,用df -l查看设备情况发现:

1K-blocks used available use% mounted on
/dev/hda1 101089 12557 83313 14% /boot

/dev/loop0 6132824 6132824 0 100% /mnt/loop

这是怎么回事呢?而且ls /mnt/loop看到的是一堆乱码.请碰到过的各位指点一下.
发表于 2003-8-20 10:05:29 | 显示全部楼层
u commands are correct. and i can run it well on rh 8 with 2.4.20-8 and my gentoo 1.4 with 2.4.21.

if u can mount, then at least kernel know the fs type, so do not know why u ls /mnt/loop see messed content.

can u try another kernel?

btw, this is not kernel source code reading related. i will move it to another kernel branch,
回复

使用道具 举报

 楼主| 发表于 2003-8-20 13:23:43 | 显示全部楼层
o,
我在另一台同样内核版本的机子上
  losetup /dev/loop0 /dev/hda1
  mount  -o rw /dev/loop0 /mnt/loop
然后用ls /mnt/loop可以看到以下内容了,
   2201220?.c03  802c d _._de  87e1 d _._de   d __dev.ice  tr_1229?.c03
221?c032.7f7  803f d _._de  87f2 d _._de   d __dev.ice  tr_1231?.c03
22a?c032.80c  83af d _._de  8800 d _._de   d __dev.ice  tr_1239?.c03
232?c032.816  83b7 d _._de  8840 d _._de   d __dev.ice  tr_1241?.c03
23a?c032.823  83bf d _._de  8880 d _._de  _devices.tr_  tr_1249?.c03
242?c032.834  83cf d _._de  88c0 d _._de  _devices.tr_  tr_1251?.c03
253?c032.85e  83e3 d _._de  8900 d _._de   d __ven.dor  tr_125a?.c03
25b?c032.873  83eb d _._de  891f d _._de   d __ven.dor  _vendors.tr_
400?c032.874  8610 d _._de  893b d _._de   d __ven.dor  _vendors.tr_
643?c032.835  861b d _._de   d __dev.ice   d __ven.dor  _vendors.tr_
7fbf d _._de  8627 d _._de   d __dev.ice   d __ven.dor  _vendors.tr_
7fc7 d _._de  8631 d _._de   d __dev.ice   d __ven.dor  _vendors.tr_
7fcd d _._de  863e d _._de   d __dev.ice   d __ven.dor  _vendors.tr_
7fd3 d _._de  8780 d _._de   d __dev.ice   d __ven.dor  _vendors.tr_
7fda d _._de  879f d _._de   d __dev.ice   d __ven.dor  _vendors.tr_
7ff3 d _._de  87a5 d _._de   d __dev.ice  icestr_1.23f  _vendors.tr_
8006 d _._de  87b6 d _._de   d __dev.ice  icestr_1.24f
8019 d _._de  87cf d _._de   d __dev.ice  tr_1220?.c03

但我试着建立 mkdir /mnt/loop/testdir时,提示说是
  mkdir: cannot create directory `/mnt/loop/testloop': Read-only file system

那我应该怎样使用/mnt/loop这个设备呢?请继续指教
回复

使用道具 举报

发表于 2003-8-20 23:24:35 | 显示全部楼层
total a mess! can u try to
1) create a large file with xxMB or xxxMB, for example file1
2) losetup /dev/loop0 file1
3) mkfs /dev/loop0
4) mount /dev/loop0 /mnt/loop
?
do not try this on partition since it may corrupt u system.
and try a vanilla kernel if possible.
回复

使用道具 举报

 楼主| 发表于 2003-8-21 10:24:53 | 显示全部楼层
对一个普通文件回接是没有问题的:它是把这个文件回接后当做一个块设备来用.
我觉得对一个设备文件如/dev/hda1应该也可以回接,在loop.c源码中可以看到它是处理了这种情况的,而且<情景分析>p501也说是可以的.再研究一下
回复

使用道具 举报

发表于 2003-8-21 23:31:25 | 显示全部楼层
yes, it can , i do that on my gentoo and rh without problem.

i suggest u to recompile a vanilla kernel to see if it is ok.
回复

使用道具 举报

 楼主| 发表于 2003-8-22 10:21:20 | 显示全部楼层
我不能在rh上成功,是因为下面的第二个命令没有加文件类型,现在可以了
  losetup /dev/loop0 /dev/hda1
  mount /dev/loop0 /mnt/loop

"vanilla kernel"是什么啊?
回复

使用道具 举报

发表于 2003-8-22 10:37:32 | 显示全部楼层
soo strange. what fs type u use? if fs type is wrong. then superblock is wrong, then the mount should fail.

vanilla kernel is the kernel u download from www.kernel.org. without any hack from ac, rh, mdk... or can be called as stock kernel.
回复

使用道具 举报

 楼主| 发表于 2003-8-22 10:45:43 | 显示全部楼层
因为 losetup /dev/loop0 /dev/hda1以后,
mount /dev/loop0 /mnt/loop 时没有指定/dev/loop0的fs,但它不显示失败比较奇怪.不过从dmesg中可以看到它默认以FAT方式挂接,而我的/dev/hda1是ext3的.

3x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-9-18 15:24 , Processed in 0.049313 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表