11.10. loop devices

简介:

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=100
100+0 records in
100+0 records out
102400 bytes (102 kB) copied, 0.00126554 s, 80.9 MB/s

$ sudo losetup /dev/loop0 file

$ sudo mkfs.ext3 /dev/loop0
mke2fs 1.40.8 (13-Mar-2008)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
16 inodes, 100 blocks
5 blocks (5.00%) reserved for the super user
First data block=1
1 block group
8192 blocks per group, 8192 fragments per group
16 inodes per group

Writing inode tables: done

Filesystem too small for a journal
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or
180 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=100
100+0 records in
100+0 records out
102400 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
	

11.10.1. losetup - set up and control loop devices

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 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

目录
相关文章
ResizeObserver loop completed with undelivered notifications
ResizeObserver loop completed with undelivered notifications
|
6月前
|
Ubuntu iOS开发 MacOS
Could not enumerate video devices (or none found).解决办法
Could not enumerate video devices (or none found).解决办法
87 0
|
存储 Linux Windows
ChIP-seq 分析:Call Peak(8)
ChIP-seq 分析:Call Peak(8)
307 0
|
安全
解决:efi usb device has been blocked by the current security policy
解决:efi usb device has been blocked by the current security policy 问题描述:U盘装系统或者其他操作时,是因为BIOS安全策略,出现上述错误无法进入后续步骤。 解决方法:按F2(Fn+F2)进入BIOS,在secure Boot 中security选择disable。解决! 延伸(可不读): 黑苹
11030 0
|
C语言
解决Dev-C++ [Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode
Dev-C++ [Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode
701 0
解决Dev-C++ [Error] ‘for‘ loop initial declarations are only allowed in C99 or C11 mode
|
算法
循环不变式(loop invariant)
循环不变式,是指让每次循环都成立的逻辑表达式,用于证明整个算法的正确性。 它通过证明循环体三条性质的正确性来证明整个算法的正确性。 三条性质: 初始化:循环的第一次迭代前,循环不变式为真。
1417 0