LinuxQuestions.org
Visit Jeremy's Blog.
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, 07: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 07:31 PM.
 
Old 09-25-2007, 12:41 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
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, 12:42 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950
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, 01:07 PM   #4
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 115Reputation: 115
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


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


All times are GMT -5. The time now is 06:22 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration