LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 12-13-2015, 09:28 AM   #1
Da9L
LQ Newbie
 
Registered: Nov 2012
Posts: 9

Rep: Reputation: Disabled
Linux Image from 16gig card to get on 4 gig card


I've created a Linux image on a 16 gig sd card that i want to get on a 4 gig card.

The partitions on the card is only taking up the first sectors to around 3,5 gigabyte, so the rest after this is not used, however when i created the image using win32 disk imager it took the whole cards space.

Can i somehow change the image so that it only uses the actual partition sizes?
 
Old 12-13-2015, 09:43 AM   #2
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Yes, dd can cut it for you. There are plenty of examples how to use it, google.
 
Old 12-13-2015, 07:55 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,771

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
Generally speaking you would reduce the partition to a less than or equal size. Using fdisk or gparted would tell you more exactly to be sure I'd start there just to double check.

Then you'd have to clone it by some program. It may be that you can set dd to copy for only so long but you may find it easier to use clonezilla or redobackup or such to get file by file copy.

It is possible to clone data easily by using gparted too.

As with all clones you may have to fool with some settings either before the clone or after.
 
Old 12-13-2015, 08:05 PM   #4
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
OP stated partitions take first 3.5 GB.
Code:
dd if=16GB_image of=4GB_image bs=1024 count=3732480
This will cut a 3.7 GB chunk from original image, suitable to put on a 4 GB card.
 
Old 12-13-2015, 09:36 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 20,944

Rep: Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070Reputation: 4070
No need to mess with counts if the partition(s) total less than the target device - just use the device nodes for the partitions, and dd will terminate at the end of each partition.
Not that I advocate dd except in something like a forensic backup. It usually does what you ask of it, but you never know if there are (logical) errors on the operation - much better to use a filesystem aware copy IMHO.
 
Old 12-14-2015, 04:12 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,713

Rep: Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593
Quote:
Originally Posted by Emerson View Post
OP stated partitions take first 3.5 GB.
Code:
dd if=16GB_image of=4GB_image bs=1024 count=3732480
This will cut a 3.7 GB chunk from original image, suitable to put on a 4 GB card.
This will not work because the operating system will still think the filesystem is 16GB. As suggested by jefro you need to resize the existing partition(s) to less then 4GB.
 
Old 12-14-2015, 05:30 AM   #7
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
This will not work because the operating system will still think the filesystem is 16GB. As suggested by jefro you need to resize the existing partition(s) to less then 4GB.
One more time, OP stated partitions take no more than 3.5 GB of space.
 
Old 12-14-2015, 06:08 AM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,713

Rep: Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593Reputation: 5593
It depends on how you interpret the OPs question. We do not know how the image was created and it isn't obvious whether the partitions sizes total 3.5GB or the space used is 3.5GB. My guess is that "taking up" means space used is 3.5GB.

To be fair we need more information.
 
Old 12-14-2015, 05:15 PM   #9
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,771

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
I can't say one way will or the other won't. I never know about these things. The OP is welcome to test this dd example. Not sure I'd point a newbie to dd as first choice.

What I meant was a general example to say that yes, you can reduce the partition if needed to move as what most of these questions start off with. I do know the OP stated the current sizes. I knew they were not 16G. I'll try to be more precise.

I wanted to point out to check the partitions, and that they had other options.
 
  


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
SD card reader doesn't recognize 8 gig SDHC card crystaldon Linux - Software 4 07-12-2009 08:05 AM
Installing Slackware 10.2 on a 2 gig SD card alexis101 Slackware 3 06-15-2006 10:46 AM
OpenSuSE 10.0 beta 3 and Farallon 1 Gig ethernet card robertwolfe Linux - Hardware 1 08-31-2005 09:38 PM
Gig Card not working Rak Linux - Networking 1 03-30-2004 05:51 AM
RH 7.0 Adding Promise ATA 100 Card and 160 gig drive lsgko Linux - Newbie 1 08-05-2003 04:33 PM

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

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