一般在live system中,尤其是mini live system,在制作的時候作者為了把系統容量壓到最低,會把他認為不常用到的東西剔除以減少系統體重.這裡要討論的是如果你的live system的內核中沒有編譯loop設備模塊該如何創建他.
1.一般來說如果Linux系統內核沒有loop模塊的時候,當你使用"mount -o loop"掛載某個鏡像文件的時候,通常會出現如下錯誤
Error message "couldn't find any free loop device"
2.這時你要使用iso文件需要以下幾個步驟
# 首先創建一個新的loop設備
mknod /dev/loop/300 b 7 300
# 然後將你的要掛載的鏡像文件(如iso,img)分配給剛才創建的loop設備
losetup /dev/loop/300 your_loop_file.iso
# 最後掛載你的loop設備(事實上是你的鏡像文件)到你的掛載點即可
mount /dev/loop/300 /your_mount_point/
# 如果要卸載,使用如下命令
umount /your_mount_point/
losetup -d /dev/loop/300
如果你想以後自動創建loop設備並掛載鏡像,可以自己寫個腳本,我的腳本如下:
#!/bin/bash
#Usage:$1 is your iso files,$2 is your mountpoint.
if [ -z $1 ];then
echo 'Image file is not specified.'
echo 'Usage: [loop_mount.sh ]'
exit 0
elif [ ! -f $1 ];then
echo 'Image file is not found'
exit 0
fi
if [ -z $2 ];then
echo 'Mount point is not specified.'
echo 'Usage: [loop_mount.sh ]'
exit 0
elif [ ! -d $2 ];then
echo 'Mount point is not created.'
exit 0
fi
# create a new loop device
$(mknod /dev/loop/loop300 b 7 300)
NEW_LOOP="/dev/loop/loop300"
# assign your loop file to created loop device
losetup $NEW_LOOP $1
# mount the loop device insetad of the file
mount $NEW_LOOP $2