LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 01-15-2010, 10:55 AM   #1
linus72
LQ Guru
 
Registered: Jan 2009
Location: Gordonsville-AKA Mayberry-Virginia
Distribution: Slack14.2/Many
Posts: 5,573

Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
How do I use DD to make a usb.img?


I was trying to make my usb into a usb.img

basically, I got a 2GB usb witha 350MB debian live distro I made on there

I want to turn that into a usb.img

is that how you do it?

I used DD command:

Code:
503box:/media/disk# dd if=/dev/sda of=503box.img
3905407+0 records in
3905407+0 records out
1999568384 bytes (2.0 GB) copied, 157.118 s, 12.7 MB/s
Code:
503box:/media/disk# file 503box.img
503box.img: x86 boot sector; partition 1: ID=0xb, active, starthead 1, startsector 63, 3903732 sectors
so, it unfortunately made a 2GB img

How do I get it to only make a img of whats on the USB
like when you get/download a regular usb.img??

thanks
 
Old 01-15-2010, 11:24 AM   #2
affinity
Member
 
Registered: Nov 2009
Distribution: Slackware64
Posts: 132

Rep: Reputation: 20
Make a partition the size of the image, then run the dd command again on that partition. You may want to add bs=512 to the end, that's how the Slackware USB image is created. This may not work properly though, with the Slackware USB install image you have to use the entire thumb drive, regardless of how large it is. At least that's how it is done according to the official notes.
 
Old 01-15-2010, 11:25 AM   #3
nileshgr
Member
 
Registered: Aug 2007
Location: Pune, Maharashtra, India
Distribution: Gentoo
Posts: 84

Rep: Reputation: 16
You need to specify the count parameter. Its best if count is expressed in bytes for accuracy.

mount your usb stick and do this -

Code:
du -sb <path-to-mount directory>
It will output you a big number on the left side.

i suggest you keep a 1 M = 1048576 bytes margin to avoid any errors.

Add the above number to the number shown by 'du'.

Then do this -

Code:
dd if=/dev/sda of=out.img count=<the sum of du and 1048576>
 
Old 01-15-2010, 11:38 AM   #4
linus72
LQ Guru
 
Registered: Jan 2009
Location: Gordonsville-AKA Mayberry-Virginia
Distribution: Slack14.2/Many
Posts: 5,573

Original Poster
Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
OK

du gave me

379668590
+
1048576
=
484526190

and so I did
Code:
503box:/media/disk# dd if=/dev/sda of=503box.img count=484526190
but that still makes a 2GB img!?

Code:
503box:/media/disk# dd if=/dev/sda of=503box.img count=484526190
3905407+0 records in
3905407+0 records out
1999568384 bytes (2.0 GB) copied, 156.178 s, 12.8 MB/s
so what now??

it should make a img file of exactly the spce taken up by whats on usb...
how do I do that and have it be bootable?
 
Old 01-15-2010, 11:43 AM   #5
affinity
Member
 
Registered: Nov 2009
Distribution: Slackware64
Posts: 132

Rep: Reputation: 20
I just noticed, you have the if and of backwards. It should be dd if=503box.img of=/dev/sda count={number}
 
Old 01-15-2010, 11:57 AM   #6
linus72
LQ Guru
 
Registered: Jan 2009
Location: Gordonsville-AKA Mayberry-Virginia
Distribution: Slack14.2/Many
Posts: 5,573

Original Poster
Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
what?

I'm not trying to Install a usb.img to my usb

I'm trying to Make a usb.img from my usb
 
Old 01-15-2010, 12:15 PM   #7
affinity
Member
 
Registered: Nov 2009
Distribution: Slackware64
Posts: 132

Rep: Reputation: 20
Ohh, I read that wrong, sorry. You could use partimage to create an image of the usb drive minus the unused space.
 
Old 01-15-2010, 12:22 PM   #8
linus72
LQ Guru
 
Registered: Jan 2009
Location: Gordonsville-AKA Mayberry-Virginia
Distribution: Slack14.2/Many
Posts: 5,573

Original Poster
Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
really?

see, I'm trying to duplicate how a Debian Live usb.img is made
http://cdimage.debian.org/cdimage/re.../i386/usb-hdd/

basically, the Debian Live .img's label your USB "DEBIAN_LIVE"
and it is fat32 inside with syslinux etc

and it only takes up so much space, however big it is

and then you use Gparted to format and label the remainging unallocated space
as live-rw
 
Old 01-15-2010, 01:08 PM   #9
affinity
Member
 
Registered: Nov 2009
Distribution: Slackware64
Posts: 132

Rep: Reputation: 20
Have you tried manually copying the files into a directory outside of the drive, then turning that directory into a .img? I am downloading the small debian.img from the link you gave, I will mount it and take a look at how it's set up, if it's just a standard Linux system converted into a .img you should have no problems doing what I just suggested.

Edit: I did a quick search on Debian live image and found this on the Debian wiki. That goes through making a live image containing whatever parts of the system you want, you can use it to replicate your current image. But I would still try out the partimage method, it creates an image of the drive without the free space, so you would have what you were originally trying to do with dd.

Edit2: I just looked at the file, as long as your current USB image is able to boot you will be able to copy the contents into a directory and then make an image of them and stick it back on a disk.

Last edited by affinity; 01-15-2010 at 01:30 PM.
 
Old 01-15-2010, 05:19 PM   #10
linus72
LQ Guru
 
Registered: Jan 2009
Location: Gordonsville-AKA Mayberry-Virginia
Distribution: Slack14.2/Many
Posts: 5,573

Original Poster
Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
well

you can't create a .img file from a folder
or at least not with dd

it says its a directory and quits

There must be a way right?
 
Old 01-15-2010, 10:30 PM   #11
affinity
Member
 
Registered: Nov 2009
Distribution: Slackware64
Posts: 132

Rep: Reputation: 20
Well you would have to make the image with the lh_{whatever} commands, they are in the Debian wiki on creating live images. I should have probably mentioned that before. Have you tried just using partimage yet?
 
Old 01-16-2010, 10:11 AM   #12
bendib
Member
 
Registered: Feb 2009
Location: I'm the rat in your couch.
Distribution: Fedora on servers, Debian on PPC Mac, custom source-built for desktops
Posts: 174

Rep: Reputation: 40
dd if=/dev/sda of=503box.img bs=387973120 count=1

I gave you around 25MBs extra just in case there is a little more data beyond 350MB.

Hope this helps.
 
  


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
How do i make a .img file into a bootable usb in windows xp so i can install fedora7 cwere4 Linux - Newbie 4 06-25-2007 11:49 AM
make a .img file for custom liveCD, dd?? (Also, how to make your system very small) 1veedo Linux - Newbie 6 05-07-2006 05:52 PM
How do I make initrd.img? zahadumy Slackware 2 11-13-2005 09:05 AM
command to make initrd.img utanja Debian 12 09-06-2004 12:18 PM
how to make boot.img leihsun Linux - General 5 07-15-2002 01:04 AM

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

All times are GMT -5. The time now is 06:17 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