LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-08-2010, 06:42 PM   #1
frozenQueue
LQ Newbie
 
Registered: Jul 2010
Posts: 25

Rep: Reputation: 0
create device file for image file?


Everything in Linux is a file, right? And everything can be represented by a file? So, say I create an image file, like so:

dd if=/dev/zero of=/home/me/partition.img bs=512 count=80000

Is there some way I could create a block device file that represents (i.e., provides an interface to) this image file? If so, then I could use fdisk on the device file to split it into partitions, format the partitions, and then mount them as directories. I could create a file system within a file system, which would be fun.
 
Old 09-08-2010, 08:37 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,974

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
You could go the long way around I guess. I use qemu and use the file as -hda. Then I can do what I want. If I use a live cd as -cdrom I boot to tools to work with the drive.

They may be many other ways to turn it into a mountable file too.
 
Old 09-08-2010, 09:34 PM   #3
Chuck56
Member
 
Registered: Dec 2006
Location: Colorado, USA
Distribution: Slackware
Posts: 930

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
I think you're asking about loop devices. I use them all the time.

Create your_file

losetup /dev/loop0 /your_file

You can fdisk the /dev/loop0 and create the file system of your choice. When done

mount -o loop /dev/loop0 /your_mount_point
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
xwd doesn't create image file MrUmunhum Linux - General 1 06-04-2009 03:14 PM
How to create a device file in linux? chaitanya1982 Linux - Newbie 3 09-24-2008 12:42 PM
GD create image from file macabre_sunsets Programming 2 06-12-2007 10:59 AM
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 can we create file device? l_9_l Linux - General 1 01-11-2002 10:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:00 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
Open Source Consulting | Domain Registration