LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-18-2005, 11:24 PM   #1
Ken3939
LQ Newbie
 
Registered: Oct 2005
Posts: 3

Rep: Reputation: 0
Copying A Linux CompactFlash Card ??


First I should say I am not a linux user, but I have a small problem since one piece of equipment we sell now has a PCM-3350F embeded controller with a CF card as hard drive running linux. So I decided to come to the place where linux guru's live to hopefully get some answer.

I've tried to copy the CF card with Windows but can see that about 10 megs are not being seen or copied (plus it will not boot the system).
CF cards very from 32 meg to 128 meg, but i've been told the file system is less than 32 meg on all the cards

Is their any way to copy this card under windows. I've searched the net and found nothing.

If I can not do it under windows, can it be done under linux.

(may be stupid question).


If under linux it can be done can someone point me to a fairly simple linux Version I can setup on my laptop or a boot cd so I can create a duplicate of this card.

Reason I need this is the parent company has a tendency of not informing the field about the latest software updates on the equipment. I usually see it when I install a new unit and check rev numbers. Then have to wait 6 -8 weeks to get cards and go out and update older systems. Would be easier if I could just snag a copy and as I do service calls update systems.

Thanks

Ken
 
Old 10-19-2005, 05:04 AM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
I had a similar problem with fax machines. Might have changed by now but, I didn't have any way to copy it in Windows or Linux.
The easiest thing I found was to wait until a new machine came in and use service mode to backup the firmware onto my spare card. Then I would use that card to restore onto customer machines.
 
Old 10-20-2005, 02:13 AM   #3
gd2shoe
Member
 
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835

Rep: Reputation: 49
Re: Copying A Linux CompactFlash Card ??

If you copied every file on a windows system to a new hard drive, it would not boot either. I am kinda guessing, but it sounds like you want to do a sector-by-sector image of one CF card to another. To make an analogy, this would not be like copying a piece of paper one word at a time, but like making a photo copy. An "image" is an exact byte for byte copy of a filesystem. This is probably what they do when the cards are prepared before they are given to you.

There may be a way to do it from Windows, but you will need a specialized program (and I have no recommendations). From Linux, you can use the "dd" command to read directly from the device (or file) and write directly to a file (or another device).

As for boot CD, I'd recommend knoppix (though there are certainly enough to choose from).

Assuming that your CF card reader gets detected as sda, the command:
dd if=/dev/sda of=/home/knoppix/imageFile bs=1M count=32
should create an image of the disk. Bear in mind that the disk may not be quite 32MB. You will need to know how much is important (just because something on the end is unreadable does not mean that it is unimportant, just probably).
The command:
dd if=/home/knoppix/imageFile of=/dev/sda
Will restore this file to the card reader

The command:
cat /proc/partitions
may or may not help you figure out what your device may be called. Thumb drives show up in there, but CD drives don't. I expect CF disks to, but I'm not sure. hda is usually your hard drive.

I'd give more details, but I'm going to bed.
This is assuming of course that changing the CF disk is all that is needed for this upgrade... (and that there isn't something else that I'm missing or cannot anticipate, quite possible)
 
Old 10-22-2005, 04:14 PM   #4
Ken3939
LQ Newbie
 
Registered: Oct 2005
Posts: 3

Original Poster
Rep: Reputation: 0
gd2shoe. Thanks for the help.
Downloaded and burnt copy of knoppix. When I booted it had to have one of the CF cards in reader and it then came up with Sda1 as the drive. Use your command to copy it to the imagefile. figured out how to umount and mount to change cards (don't know if their is a easier way). Tried to duplicate to the other card and kept getting error "device is full"
Is their a way to erase or completely clean the card.

This is really stretching the memory. Last time I used commands like these was when I play with a unix version call xenix on a radio shack model II system in the mid 80's.
 
Old 10-22-2005, 04:40 PM   #5
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
My suggestion is to get hold of an identical CF card and add it to the computer. Use Linux to clone the CF disk.

Assuming the source is sda and the target is sdb then just duplicate the disk using the command

dd if=/dev/sda of=/dev/sdb

There is no need to mount any of the disks if you copy the whole disk. A disk cannot be mounted. It is passed on from the BIOS. You only mount partitions in Linux.

Windows does not support Linux and will not read a Linux partition.

Norton Ghost and the like can be used to clone a Linux disk or partition if the source and target disks are different in size.

I recommend using dd in Linux in your case.

The dd command is just as quick. The cloning is done sector by sector to mirror the exact binary patterns. I often use Linux to clone 200Gb hard drives with over 40 Windows and Linux partitions inside.
 
Old 10-22-2005, 08:13 PM   #6
gd2shoe
Member
 
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835

Rep: Reputation: 49
saikee, I'm not exactly sure what you mean when you say: "A disk cannot be mounted. It is passed on from the BIOS. You only mount partitions in Linux."

While it is true that there is no need to mount the cards in this case, I don't see your statement as true. Any block device that holds a file system can be mounted. It is the ONLY common way to get data off of any drive. There are some kernel modules that will automatically mount and unmount for you, but the drives are still getting mounted.

And yes, assuming that you have more than one card reader, you can do one dd directly from one card ("if" for input file) to another ("of" for output file). The process may also go faster if you add "bs=1M" on the end (saikee, this helps a lot with hard drives).

What is happening, basically, is that the partition is a really big string of ones and zeros. When it is formated (high level format) some of those bytes are designated to hold special information about the file system. They keep track of which other spots are being used, the file structure, etc. When a disk is mounted, the operating system examines these key spots and determines what file system it is, and what rules it behaves by. It then uses this information and these rules to find where the files and folders are located within that large string of bytes.

Here's what we're doing. We are totally ignoring that file system. We are simply copying the string of bytes from start to finish. When the card does get mounted, you will not only have identical files, but the entire file system that they sit in will be identical. This particularly allows for information to be copied which might be in the partition or disk, but is not actually set up as a file. For example, the boot sector of a disk is not a file. It is data that sits in a specific spot (at the beginning) of a file system. You could copy every file from one file system to another, and the boot sector will not get copied. However, if you copy the file system itself, then it will. I'm also concerned about the space after the end of your file system, but before the end of the disk. It may contain important proprietary information (but most likely not). This is why I would suggest just copying the whole thing.

Oh. and if you want to keep a copy of that image, I'd suggest you find a disk that is formated with the fat32 (sometimes called vfat) filesystem. Linux really shouldn't be allowed to write to an NTFS volume. Last I heard it was safe, but I wouldn't count on it yet.
(fat32 is used by win9x)
 
Old 10-23-2005, 07:45 AM   #7
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
gd2shoe,

I am not sure how much your reply was directed to me.

My statement of Linux mount only the disk is correct and I think the confusion comes in only when people are used to have one partition for one disk. Distros like Mepis, Slax, Knoppix and the like also show up the mounted partitions as a hard disk icons. In my last Knoppix 4 installation my desktop screen has about 56 hard disk icons but I have only 4 hard disks in the box.

As the mount statement has the -t parameter for the partition type it goes without saying that Linux wouldn't be able to cope by knowing one partition type when mounting a disk with multiple Linix and non-Linux (Windows) partitions.

I have omitted the bs parameter in my dd statement because the default size is 512 bytes. Increasing it to 1M or 1024 bytes can hardy improve the operational time. I usually use bs=32256 which is for the whole track of 512 bytes times 63 sectors for cloning a 200Gb hard disk, taking between 2 to 2.5 hours. I didn't think the execution time warrants a careful selection of the bs parameter and have omitted it for simplicity.
 
Old 10-24-2005, 10:13 AM   #8
gd2shoe
Member
 
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835

Rep: Reputation: 49
Most of my post was directed at Ken3939. I felt that he needed a better understanding of what was going on.

I think we have a simple misunderstanding here, but I can't figure out what it is for the life of me.

"A disk cannot be mounted. It is passed on from the BIOS. You only mount partitions in Linux."
...
"My statement of Linux mount only the disk is correct and I think the confusion comes in only when people are used to have one partition for one disk."

Ok, first, Linux only relies on the bios detection during the first part of boot up (If I understand correctly). It then goes and uses it's own code to redetect hardware including the drives. When talking about hard drives, people usually mount partitions. Nevertheless, it IS possible to format an entire hard drive using commands such as mkfs.ext2 -j /dev/hda. This is NOT recommended with a hard drive, but it works. you can mount this just fine: mount /dev/hda /mnt/hda.

When talking about just about any other disk device (floppy and CDROM for examples), you DO mount the entire disk. These devices are not partitioned, but the entire disk is one filesystem. I don't know about card readers. I don't believe that they are commonly partitioned, but I may easily be wrong.

"As the mount statement has the -t parameter for the partition type it goes without saying that Linux wouldn't be able to cope by knowing one partition type when mounting a disk with multiple Linix and non-Linux (Windows) partitions."

I'm not sure what you are referring to here. Of course linux can understand multiple types of filesystems. I referred to that in my post. Usually, though, you do not need to tell it which filesystem is on a disk. The default option for -t is auto, meaning that (as I said before in simplified terms) "When a disk is mounted, the operating system examines these key spots and determines what file system it is, and what rules it behaves by." In other words, Linux is smart enough to figure out what type of file system it's dealing with by examining the disk. Mind you I am talking about block devices generally here, and not hard drive partitions specifically.

I don't know if you were referring to the so called partition type that is stored in the partition table. To my understanding, that is largely completely ignored by Linux. Fdisk can set that in order to help usability on other OS (If a vfat partition type is set wrong, Linux doesn't care, but Windows will refuse to detect it, for example).

I find your choice of bs=32256 to be interesting. I know from experience that leaving the bs=512 default on a hard drive read is MUCH slower than changing it, for example, to bs=1M. I'm interested in finding the optimal size, and will need to try 32256 at some point. Bear in mind too that modern hard disks lie about their geometry. The only way to find the true physical geometry at this point is to ask the manufacturer.

Before this gets out of hand, let me clarify my position. I am not here to argue. I am here to learn and to help. I would like to understand what our misunderstanding is, and can keep at this for a long time. I don't want to argue and will need to force myself to not respond if I think that I am starting to get into an argument. It is very difficult to understand tone of voice on a forum sometimes, so I'm entirely unsure of how combative you feel about this. Let's just keep this on a friendly level. (not making any accusation, but there are a few posters on any forum who are belligerent at the drop of a hat)
 
Old 10-24-2005, 11:16 AM   #9
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
gd2shoe,

You are too nervous in thinking I am putting a magifying glass in everything you write. We talk about our understanding of the same subject and align our information to keep abreast of knowledge. We learn from each other by expressing our views.

Sorry if my write-up triggered a combative mode in you. My intention is really offering the knowledge from my end to see if it is of any use to you.

I don't have a problem with what you have written so far. However I always have multiple partitions in a hard disk and so cannot understand how one can mount one location for a filing system to address multiple partitions.

I accept mounting the whole disk with one partition would not create such confusion.

A modern Linux does have intelligence to know the type of the partition required to be mounted and seldom asks for the type. It will however ask for the type if Linux finds something illogical.

A good example is one can partition a 10Gb Fat16 partition at the end of a 200Gb disk in Linux but that will cause confusion as FAT16 does not support partition larger than 2Gb and has no ability to answer address beyond 2Gb. Thus it will ask for the partition type in such circumstance and work with it, even though the partition is totally useless to DOS/Windows.

Also I happen to believe the partition type in the partition table is actively used by Linux. The Vfat could be an exception because it is a generalisation.

Whenever Grub is asked to book a partition the first thing it reports back is the partition type. Without the prior warning of the partition type a Linux will be in trouble of coming up with the correct method to diagnose the filing structure and damage is liable as a result. From my experience self-inflicted damage to a hard disk is done unually this way.
 
Old 10-24-2005, 02:36 PM   #10
gd2shoe
Member
 
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835

Rep: Reputation: 49
"Sorry if my write-up triggered a combative mode in you. My intention is really offering the knowledge from my end to see if it is of any use to you."

It didn't really, and I'm sorry if I came across that way. The reason for my last paragraph was that I could not determine your demeanor. Sometimes I'm a little too straight forward, and others may have trouble guessing what my mood is too.

Now that we're on the same page there, let's see if we can learn something from each other (yes, that means I'm trying to learn from your knowledge and superior experience).

"...I always have multiple partitions in a hard disk and so cannot understand how one can mount one location for a filing system to address multiple partitions."

Although I don't think that grub relies on the type either, I'm more inclined to believe that it does than the kernel. I'm trying to understand the problems that you've faced. When you say "reports back" are you talking about grub stage 1 or 1.5 reporting to stage 2, or are you implying that stage 2 reports to the kernel that it has loaded? Even still, I'm having trouble understanding how a message such as "83" (standing for linux) in the partition table is helpful to the boot loader or kernel in understanding which file system is present. There is no information there to help determine which linux acceptable file system is present (ext2, ext3, reiserfs, jfs, xfs, minux, etc.). All or most of them use the same number. Personally, I don't think that the kernel terribly cares what the partition type is set to be, only the size and the file system type (auto detected or manually set).
I have no idea what you just said. If you could tell me what you think I said and where, I think we can resolve this.
 
Old 10-24-2005, 03:07 PM   #11
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
One can boot a system up manually in Grub using these 3 lines

root (hdi,j)
chainloader +1
boot

The partition type is reported every time after the first line is entered. The above 3 lines boot every one of the 50+ systems in my box, regardless if it is a DOS, a Windows, a Linux a BSD or a solaris, but the reported partition type gives out the clue.

In the above Grub chainloads the correct partition first, then the 2nd statement loads its boot loader which could be a second Grub.

The bootloader will have arranged the matching of the partition type automatically.

For example if a Linux is booted its boot loader will load the kernel by the kernel statement whereas in a DOS, Windows, BSD or Solaris Grub simply "cut and paste" its stage1 with the target bootloader and boot the combined system.
 
Old 10-26-2005, 12:02 AM   #12
Ken3939
LQ Newbie
 
Registered: Oct 2005
Posts: 3

Original Poster
Rep: Reputation: 0
Gentlemen

To all those that made suggestions Thank you for you help.

After doing some hunting I found that the Knoppix I downloaded had a program on it called "partimage".
This did it exactly what I want very easily. (Also found out from enginering that all software will be larger then 32 megs and will be supplied on 128 m CF cards. ) Partimage makes a perfect copy that I have tested on two working units.


as a side note I have to wonder about software developers. Why would they make a 63M partition on a 128M Card.



Again thanks for the help. The knoppix suggestion worked the best for me.




Ken


now I have the bug to learn more about linux. another project to fit into my 28 hour work day excluding sleep.
 
  


Reply



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
Can't boot from CompactFlash card TSloth DamnSmallLinux 2 01-06-2006 11:56 PM
CompactFlash PC Card Adapter juyce Ubuntu 2 07-22-2005 04:50 PM
How do you access compactflash drive when card doesn't automount? Cinematography Linux - Hardware 11 05-31-2005 09:18 PM
CompactFlash PCMCIA Card reader problems kirillka Linux - Newbie 2 09-29-2004 11:34 PM
PNY CompactFlash Card Reader - 2.6.4rc2 matthurne Linux - Hardware 1 03-07-2004 09:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:16 AM.

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