LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-24-2007, 06:30 PM   #1
Githlar
LQ Newbie
 
Registered: Sep 2007
Posts: 9

Rep: Reputation: 0
Create Smaller USB Flash Drive Image?


OK, I have a bootable 2GB USB flash drive. It has one partition that is around 100M and the rest is free space.

I wanted to create an image of the flash drive to use with memdisk. So, I used dd. However, dd copies the entire flash drive, even the free space.

What I want to do is extract the MBR/bootrecord and the first partition into a disk image. Or, in simpler terms - extract everything but the free space. Since the image file is the same size of my USB flash drive, I can't fit it on my flash drive, so I need to cut off all that unneeded free space.

Any suggestions?

I tried using Qemu-img to create a raw image of the size I need and then formatting it right in FreeDOS from Qemu and copying over the files, but the image doesn't seem to want to boot (at least in Qemu).

Last edited by Githlar; 09-24-2007 at 06:31 PM.
 
Old 09-25-2007, 11:41 AM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
You didn’t tell use the dd command you used. You can specify the size to the dd command by using the count and bs flags. E.g.,
Code:
dd if=/dev/sdb of=/path/to/destination/image.img bs=1048576 count=100
Of course you may need to modify the command to adapt to your particular situation.
 
Old 09-25-2007, 11:42 AM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
dd can certainly copy sections of a disk. You only have to use the 'count=BLOCKS' option to specify the number of blocks you want to transfer. You can use this to copy only the boot record, or only the first 100MB, for example.

The only question is determining how many blocks to copy. Unfortunately, I don't know the answer to that offhand.

You can also copy a partition instead of a drive simply by using the partition device as the input instead of the drive device. 'if=/dev/sda1' instead of 'if=/dev/sda', for example.

There's an excellent thread about all the neat things you can do with dd here:
http://www.linuxquestions.org/questi...d.php?t=362506
 
Old 09-25-2007, 12:07 PM   #4
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Why are you copying the entire drive when all you want is one partition? As stated in the previous post, specify if=/dev/sda1 to get a partition.
 
  


Reply

Tags
boot, usb



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
Help removing free space to create Raw free space nightmare55 Linux - Newbie 11 10-01-2009 03:07 AM
Usb thumb drive not reading free space correctly speel Linux - General 7 08-12-2007 10:51 PM
fdisk fails to create partition, but drive has free space whysyn Linux - Software 3 04-17-2007 02:13 PM
Not enough free space on hard drive with 50g of free space??? auoq SUSE / openSUSE 5 10-13-2004 08:21 PM
Formating free space: WinXP pro and RH9 dualboot with free space on 3rd drive Vermicious Linux - General 2 03-22-2004 05:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:42 PM.

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