views:

57

answers:

3

Computers recognize different file systems. My question is, where exactly does this information get stored in a memory device (the specific location if any). Or does it not get stored anywhere & rather an operating system tests the system (memory device) against a known set of file systems (like ext3, ntfs, etc) ?

With reference to the above, If I copy every bit (first to the last) from a memory device to another one, of the same memory size (say two similar flash drives) will the later one be a total clone? Will the cloned device automatically inherit the file system?

If the clone cannot be obtained by bit-by-bit copying what else is required?

I believe this question is supposed to be somewhere else in SE, but I'm not sure of that place.


EDIT : I am working with a 8085 microprocessor here, so not really looking for softwares on cloning.

+1  A: 

Every time a new block device shows up, the operating system generally tests a bunch of filesystem drivers against it, and when one of them matches, starts it up and hooks it up to whatever internal systems it needs to have to work for the user. In general, if you copy block-by-block from one raw device to another, it will be an exact clone of the original.

Carl Norum
You can even clone the MBR and ALL the partitions of a disk in the clone. But you can copy only partitions to another place and it will work too as filesystems always use relative offset to the begin of its partition.
LatinSuD
isn't file system information stored in partition table? And isn't this the place where OS determines what files system it is?
jjczopek
loxxy
+1  A: 

HDDs include partition table (do google search on this term). Flash cards and Flash USB disks don't usually have partition tables and if this is the case, OS just asks each file system driver "is it your file system?".

As for cloning - if you copy the device to the identical device, you will have a clone. If HDDs have different configuration (different number of cylinders, heads etc.), then cloning is not that easy, but also possible. Flash cards are usually copied block-by-block and cloning is trivial. There exist applications like Acronis Disk Director or Norton Ghost that do such cloning. You can take a trial and play with it.

Eugene Mayevski 'EldoS Corp
I don't think partition table comes into play at this moment of time, or does it? As for the type of memory, they would obviously would have to be identical in all physical aspects. Anyways thank you.
loxxy
Partition table specifies type of the file system used in each partition. As for type of memory - this is not exactly so. The number of heads/cylinders matters only when you copy the HDD in whole (with partition table), because partition table contains certain head/cylinder information. If you copy partition as logical entity (set of clusters), then physical characteristics don't matter at all. So you can copy 2Gb flash card to 4Gb flash card and on destination card you will have the same 2Gb partition.
Eugene Mayevski 'EldoS Corp
The file system specified in the partition is more of a hint to the OS than anything else. There is no guarantee that a partition that claims it has been formatted with X is in reality formatted with X.
Sparky
-1 Every modern OS ignores "CHS" information, even though fdisk/parted and friends may try to enforce "cylinder"-alignment.
tc.
Note that cylinder alignment can do more harm than good; the CHS data typically uses 63 sectors per track, misaligning the partitions on drives with large sectors (2TB ones or larger may have that). However, considering the involvement of an 8085, it's quite possible drive geometry is relevant in this case.
Yann Vernier
A: 

And some more detail you never wanted to know:

Every partition table I know of stores some information about the partition type:

  • "MBR" (IBM/PC) has a "partition type" per partition. 0x00 is free space, and the rest are "allocated" by whoever gets there first (I think there have been some collisions). Linux uses a single partition type (0x83) for all its filesystems, presumably to reduce collisions, and just asks all the filesystem drivers. Microsoft uses a different type for each filesystem type (IIRC there are two different FAT16s or FAT32s; I can't remember).
  • "APM" (Apple_partition_map, a.k.a. "Classic" Mac) stores a partition type string (up to 31 characters or so).
  • "GUID" (EFI's "GUID partition map", used on Intel Macs) stores a partition type GUID. GUIDs are effectively guaranteed to be unique.

A byte-for-byte copy usually works, provided both devices have the same sector size (since a lot of offsets/sizes are specified in sectors instead of bytes). Nearly every hard disk and flash drive use a sector size of 512 bytes, but there are some exceptions:

  • Some iPod Shuffles seem to use 2048 bytes. Apparently you can sometimes boot a CD image from one (CD-ROMs generally have 2048-byte sectors).
  • Some newer hard drives have 4096-byte sectors (with a compatibility jumper to pretend to have 512-byte sectors).
  • Some "enterprise" hard drives support slightly larger sectors (e.g the Barracuda ES.2 has 512, 512+8, 512+12, 512+16). The extra bytes are presumably useful for encrypted disks.
tc.
While there are over a dozen different partition types used for FAT alone, Windows has by now abandoned the model of picking filesystem by partition type (indeed, there is none for UDF). Mac OS X will respect the partition type, but memory devices in general need not be partitioned at all. A byte for byte copy will work unless there's out of band information needed, such as the drive serial number (Xbox does this). Moving a partition may cause problems with bootloaders, that are sometimes stored in fixed positions or even outside partitions.
Yann Vernier
@tc : more Info on anything is always welcome. @Yann : I am trying to copy to similar devices. It's just a itch-to-try thing. Nothing bigger.
loxxy
A byte-for-byte copy of a *partition* will (generally) always work, though NTFS stores things like the block size of the device it was created on. A byte-for-byte copy of an entire disk might not.
tc.