Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome. |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
11-20-2011, 08:44 AM
|
#1
|
LQ Newbie
Registered: Nov 2011
Distribution: WindRiver, RedHat
Posts: 17
Rep: 
|
Problem reducing size for CF Card image using USB
Hi,
I am having an existing CF card image of size 512M, which I wish to unpack to a 4GB USB Stick, upgrade the kernel and initrd on the image and pack it again. So basically here is what I'm doing:
_1. I dd out the existing 512M image to the usb stick, mounted on /dev/sdb
dd if=cf_image.img of=/dev/sdb bs=16384
I observe, the size of the USB is now shown as 512M.
_2. I upgrade the kernel and the initrd on the USB stick.
_3. When I pack the usb back, the size of the image file i get is 4GB and not 512M.
dd if=/dev/zero of=/dev/sdb/zero bs=16384
rm -f zero
dd if=/dev/sdb of=./new_cf.img bs=16384
What am I doing wrong?
Will a sync help?
BTW my img file has two partitions, one small linux partition containing grub to boot up, and a FAT16 partition containing the kernel and the initrd image.
|
|
|
Click here to see the post LQ members have rated as the most helpful post in this thread.
|
11-21-2011, 11:51 AM
|
#2
|
Moderator
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
|
Don't copy the image to the USB stick. Just mount it (or better a copy of it, if something goes wrong), make your changes and use dd to copy it back to the CF card.
|
|
2 members found this post helpful.
|
11-22-2011, 11:44 AM
|
#3
|
LQ Newbie
Registered: Nov 2011
Distribution: WindRiver, RedHat
Posts: 17
Original Poster
Rep: 
|
Hi Tobi,
Thanks for the reply.
But I'm not able to mount the CF card image. The image consists of a small linux partition (containing grub for booting up) and a windows partition (have the kernel and the initrd). It asks for the file system type while mounting.
Mantis
|
|
|
11-22-2011, 12:05 PM
|
#4
|
Moderator
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
|
When it contains partitions you have to mount it with an offset. To get the right offset value just use
Code:
fdisk -l YOURIMAGEFILE
It will show something like this:
Code:
tobi@monster ~ :) % fdisk -l test.img
Disk test.img: 536 MB, 536870912 bytes
255 heads, 63 sectors/track, 65 cylinders, total 1048576 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x7b36c16a
Device Boot Start End Blocks Id System
test.img1 2048 43007 20480 83 Linux
test.img2 43008 1048575 502784 83 Linux
As you can see, the first partition begins with sector 2048 and the sector size is 512 bytes, so the correct offset is 2048*512 = 1048576. To mount the first partition of my image file to /mnt you would launch the mount command this way:
Code:
mount -o loop,offset=1048576 test.img /mnt
In this example the offset for the second partition would be 43008*512 = 22020096.
|
|
1 members found this post helpful.
|
11-23-2011, 09:22 AM
|
#5
|
LQ Newbie
Registered: Nov 2011
Distribution: WindRiver, RedHat
Posts: 17
Original Poster
Rep: 
|
Hi Tobi,
It works.. !! I have mounted the image file and made changes.
Thank you very much..
Mantis
|
|
|
All times are GMT -5. The time now is 06:11 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|