On Mon, Oct 20, 2008 at 03:28:07PM +0530, rishi agrawal wrote: > Hello Everyone, > > I would like to know about the use of "losetup". > > By use I want mean that in what all situations will I use losetup. Its > okay that it attaches a loop device to any regular file but how do we > use this feature. Anytime you use the option loop to mount, you use (indirectly) losetup: mount -o loop,ro distro.iso /mnt It is also useful for temporary/test block devices. For instance, a snapshot: dd if=/dev/zero of=snapshot bs=1 count=0 seek=4G dev=$(losetup -fs snapshot) echo 0 $(blockdev --getsize /dev/sda) snapshot /dev/sda $dev P 16 | dmsetup create snapshot e2fsck -yf /dev/mapper/snapshot Also joining a disc image together: declare -a loops for i in sda.img.*; do loops+=($(losetup -fs $i)) done size=0 for l in ${loops[*]}; do bsize=$(($(blockdev --getsz $l)+size)) echo $size $bsize linear $l 0 size=$bsize done | dmsetup create image mount /dev/mapper/image /mnt -- Luciano Rocha <luciano@xxxxxxxxxxx> Eurotux Informática, S.A. <http://www.eurotux.com/>
Attachment:
pgpaVDRsFPa47.pgp
Description: PGP signature