Wednesday, August 29, 2018

Creating a loop device (for testing)

==============================================
// create the backing file
# dd if=/dev/zero of=loopbackfile.img bs=100M count=10
10+0 records in
10+0 records out
1048576000 bytes (1.0 GB) copied, 1.26748 s, 827 MB/s

# du -sh loopbackfile.img
1000M loopbackfile.img

// get free loop device and associate with backing file
// -f free   ||  -P partscan to force kernel scan partition table
# losetup --show -fP loopbackfile.img

// show the devices
# losetup -a

// here loopX is the device associated - check with above step
# mkfs.xfs /dev/loopX


# mkdir -p /testdata

// do mount
# mount -o loop /dev/loop0 /testdata


// verify
# df -hP /loopfs/

# mount | grep testdata

==============================================



No comments:

Post a Comment