本文共 2365 字,大约阅读时间需要 7 分钟。
If you are using the loadable module you must have the module loaded first with the command:
$ sudo modprobe loop
The following commands can be used as an example of using the loop device.
$ dd if=/dev/zero of=file bs=1k count=100100+0 records in100+0 records out102400 bytes (102 kB) copied, 0.00126554 s, 80.9 MB/s$ sudo losetup /dev/loop0 file$ sudo mkfs.ext3 /dev/loop0mke2fs 1.40.8 (13-Mar-2008)Filesystem label=OS type: LinuxBlock size=1024 (log=0)Fragment size=1024 (log=0)16 inodes, 100 blocks5 blocks (5.00%) reserved for the super userFirst data block=11 block group8192 blocks per group, 8192 fragments per group16 inodes per groupWriting inode tables: doneFilesystem too small for a journalWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 24 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.
mount loop device
$ sudo mkdir /mnt/loop$ sudo mount /dev/loop0 /mnt/loop
Now! you can using it as harddisk.
umount loop device
$ sudo umount /mnt/loop/$ sudo losetup -d /dev/loop0
Maybe also encryption modules are needed.
$ sudo modprobe cryptoloop$ sudo modprobe des
enable data encryption
$ dd if=/dev/zero of=encryption_file bs=1k count=100100+0 records in100+0 records out102400 bytes (102 kB) copied, 0.00130537 s, 78.4 MB/s$ sudo losetup -e des /dev/loop0 encryption_file
If you are using the loadable module you may remove the module with the command
$ sudo rmmod loop des cryptoloop
EXAMPLE
If you are using the loadable module you must have the module loaded first with the command # insmod loop.o Maybe also encryption modules are needed. # insmod des.o # insmod cryptoloop.o The following commands can be used as an example of using the loop device. # dd if=/dev/zero of=/file bs=1k count=100 # losetup -e des /dev/loop0 /file Password: Init (up to 16 hex digits): # mkfs -t ext2 /dev/loop0 100 # mount -t ext2 /dev/loop0 /mnt ... # umount /dev/loop0 # losetup -d /dev/loop0 If you are using the loadable module you may remove the module with the command # rmmod loop
原文出处:Netkiller 系列 手札
本文作者:陈景峯 转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。