Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.