LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do I create a loopback disk image? (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-create-a-loopback-disk-image-747798/)

judoka 08-15-2009 02:40 PM

How do I create a loopback disk image?
 
I'm running Ubuntu 9.04 and i'm trying to create aloopback disk image when I type ~$ dd if+/dev/zero of=~/secret.img bs=1M count=100 i get: 100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 0.171021 s, 613 MB/s
then i type ~$ sudo losetup /dev/loop/0 ~/secret.img and get:
/dev/loop/0: No such file or directory
What am I doing wrong? How can I create a loopback disk image?

w1k0 08-15-2009 02:57 PM

Maybe you have to use /dev/loop0 device...

judoka 08-15-2009 03:01 PM

I'm trying to create an empty disk image to mount as a loopback device.

paulsm4 08-15-2009 03:04 PM

WTF?

This might help:
http://en.wikipedia.org/wiki/Loop_device

(Note: "loop/0" <> "loop0")

w1k0 08-15-2009 03:21 PM

Quote:

Originally Posted by paulsm4 (Post 3644643)
(Note: "loop/0" <> "loop0")

As well as:

dd if+/dev/zero of=~/secret.img

isn't equal:

dd if=/dev/zero of=~/secret.img

Such ``tiny'' differences can destroy all the system.

jschiwal 08-15-2009 04:13 PM

If you use the "-fs" options for losetup, it will select the first available loop device and print which loop device was selected.

linus72 08-15-2009 04:18 PM

Unless mistaken

Mustn't the file be formatted ext2 or ext3 before you can mount or use it?

w1k0 08-15-2009 05:01 PM

Quote:

Originally Posted by linus72 (Post 3644707)
Mustn't the file be formatted ext2 or ext3 before you can mount or use it?

Yes. Look here for some example: http://wiki.osdev.org/Loopback_Device.

linus72 08-15-2009 05:55 PM

also
tinycore and I believe grml use a qemu-img as a persistent storage area

ubuntu uses a partition named casper-rw or a dd img as a persistent store
same with debian/grml(live-rw) and sidux (sidux-rw)
and others too

to make a casper thing it's

dd if=/dev/zero of=casper-rw bs=1M count=128

for a 128mb casper-rw

to make a ubuntu persistent partition

sudo mkfs.ext3 -b 4096 -L casper-rw /dev/hdxx

judoka 08-16-2009 12:54 AM

Thanks for the info; however, given that i'm a linux newbie and strapped for time it's gonna take me a while to do the necessary research to solve this problem. Your input is greatly appreciated.

jschiwal 08-18-2009 07:53 AM

Quote:

Originally Posted by linus72 (Post 3644707)
Unless mistaken

Mustn't the file be formatted ext2 or ext3 before you can mount or use it?

Yes. You can either use mkfs on the file, or use losetup first and then create a filesystem using the loop device.


All times are GMT -5. The time now is 04:29 PM.