LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-15-2009, 02:40 PM   #1
judoka
Member
 
Registered: Jul 2009
Distribution: Ubuntu 14.04 LTS, CentOS
Posts: 218

Rep: Reputation: 16
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?
 
Old 08-15-2009, 02:57 PM   #2
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware, Mint
Posts: 1,252

Rep: Reputation: 205Reputation: 205Reputation: 205
Maybe you have to use /dev/loop0 device...
 
Old 08-15-2009, 03:01 PM   #3
judoka
Member
 
Registered: Jul 2009
Distribution: Ubuntu 14.04 LTS, CentOS
Posts: 218

Original Poster
Rep: Reputation: 16
I'm trying to create an empty disk image to mount as a loopback device.
 
Old 08-15-2009, 03:04 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
WTF?

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

(Note: "loop/0" <> "loop0")
 
Old 08-15-2009, 03:21 PM   #5
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware, Mint
Posts: 1,252

Rep: Reputation: 205Reputation: 205Reputation: 205
Quote:
Originally Posted by paulsm4 View Post
(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.
 
Old 08-15-2009, 04:13 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
If you use the "-fs" options for losetup, it will select the first available loop device and print which loop device was selected.
 
Old 08-15-2009, 04:18 PM   #7
linus72
LQ Guru
 
Registered: Jan 2009
Location: Gordonsville-AKA Mayberry-Virginia
Distribution: PocketWriter/MinimalX
Posts: 5,087

Rep: Reputation: 338Reputation: 338Reputation: 338Reputation: 338
Unless mistaken

Mustn't the file be formatted ext2 or ext3 before you can mount or use it?
 
Old 08-15-2009, 05:01 PM   #8
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware, Mint
Posts: 1,252

Rep: Reputation: 205Reputation: 205Reputation: 205
Quote:
Originally Posted by linus72 View Post
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.
 
Old 08-15-2009, 05:55 PM   #9
linus72
LQ Guru
 
Registered: Jan 2009
Location: Gordonsville-AKA Mayberry-Virginia
Distribution: PocketWriter/MinimalX
Posts: 5,087

Rep: Reputation: 338Reputation: 338Reputation: 338Reputation: 338
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
 
Old 08-16-2009, 12:54 AM   #10
judoka
Member
 
Registered: Jul 2009
Distribution: Ubuntu 14.04 LTS, CentOS
Posts: 218

Original Poster
Rep: Reputation: 16
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.
 
Old 08-18-2009, 07:53 AM   #11
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
Quote:
Originally Posted by linus72 View Post
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.

Last edited by jschiwal; 08-19-2009 at 01:49 AM. Reason: fsck -> mkfs
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a mountable disk image of Windows partition tnine9 Linux - Desktop 3 08-10-2008 07:13 PM
How to create a multi-file-image and mount it as a loopback device (on xbox debian) El_Oy Linux - Software 1 06-14-2006 02:05 AM
How do I create a jffs2 loopback image? rjlee Linux - General 0 04-22-2006 12:02 PM
qemu create disk image kpachopoulos Linux - General 3 11-29-2005 10:49 AM
How to create disk image with Linux? zaoka Linux - Software 3 07-14-2005 03:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration