gxqing 发表于 2003-8-20 09:10:45

关于loop device问题请教

我在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看到的是一堆乱码.请碰到过的各位指点一下.

Dragonfly 发表于 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,

gxqing 发表于 2003-8-20 13:23:43

o, :oops:
我在另一台同样内核版本的机子上
losetup /dev/loop0 /dev/hda1
mount-o rw /dev/loop0 /mnt/loop
然后用ls /mnt/loop可以看到以下内容了,
   2201220?.c03802c d _._de87e1 d _._de   d __dev.icetr_1229?.c03
221?c032.7f7803f d _._de87f2 d _._de   d __dev.icetr_1231?.c03
22a?c032.80c83af d _._de8800 d _._de   d __dev.icetr_1239?.c03
232?c032.81683b7 d _._de8840 d _._de   d __dev.icetr_1241?.c03
23a?c032.82383bf d _._de8880 d _._de_devices.tr_tr_1249?.c03
242?c032.83483cf d _._de88c0 d _._de_devices.tr_tr_1251?.c03
253?c032.85e83e3 d _._de8900 d _._de   d __ven.dortr_125a?.c03
25b?c032.87383eb d _._de891f d _._de   d __ven.dor_vendors.tr_
400?c032.8748610 d _._de893b d _._de   d __ven.dor_vendors.tr_
643?c032.835861b d _._de   d __dev.ice   d __ven.dor_vendors.tr_
7fbf d _._de8627 d _._de   d __dev.ice   d __ven.dor_vendors.tr_
7fc7 d _._de8631 d _._de   d __dev.ice   d __ven.dor_vendors.tr_
7fcd d _._de863e d _._de   d __dev.ice   d __ven.dor_vendors.tr_
7fd3 d _._de8780 d _._de   d __dev.ice   d __ven.dor_vendors.tr_
7fda d _._de879f d _._de   d __dev.ice   d __ven.dor_vendors.tr_
7ff3 d _._de87a5 d _._de   d __dev.iceicestr_1.23f_vendors.tr_
8006 d _._de87b6 d _._de   d __dev.iceicestr_1.24f
8019 d _._de87cf d _._de   d __dev.icetr_1220?.c03

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

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

Dragonfly 发表于 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.

gxqing 发表于 2003-8-21 10:24:53

对一个普通文件回接是没有问题的:它是把这个文件回接后当做一个块设备来用.
我觉得对一个设备文件如/dev/hda1应该也可以回接,在loop.c源码中可以看到它是处理了这种情况的,而且<情景分析>p501也说是可以的.再研究一下

Dragonfly 发表于 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.

gxqing 发表于 2003-8-22 10:21:20

我不能在rh上成功,是因为下面的第二个命令没有加文件类型,现在可以了
losetup /dev/loop0 /dev/hda1
mount /dev/loop0 /mnt/loop

"vanilla kernel"是什么啊? :oops:

Dragonfly 发表于 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.
:-D

gxqing 发表于 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
页: [1]
查看完整版本: 关于loop device问题请教