PDA

View Full Version : 8GB CF Cards May Be Possible


rbsfou
01-14-2008, 10:27 AM
I've managed to squeeze the last few Kb from my 4GB CF card (and i've got an 8GB CF card on order to see whether this trick will work with that).

To start with my "Lifedrive" showed up as 3815.5mb in Card Info, but after applying this hack i get 3830.3mb. Ok, not a great deal of difference, but at least i've managed to get more than the bog standard.

It's all about the entry for Partition number 3 in the (raw) MBR, you just need to change this to fill up the card (and keep everything else the same!).

However, it's the "keeping everything else the same" bit that's tricky (OSX fdisk wipes entries with unknown partition types, linux fdisk throws a wobbly if your partitions don't fit the geometry of the disk - stupid, i don't care if my partition starts when a new cylinder does!, etc...).

So here's how i did it. Please note that you will need to know your card's raw device id (Linux users look in dmesg, Mac users can use Disk Utility.app).

As usual there is NO WARRANTY for this working on your particular setup. I can only say it worked for me. My method will erase your Lifedrive partition - it may be possible to do this without erasing, but i did not try this.

1. Back up your card's MBR (and KEEP A COPY SOMEWHERE!)


dd if=/dev/rdisk1 of=table.sct bs=512 count=1
cp table.sct orginal.sct


2. Now use a partition utility to extend partition 3 to the end of the card (here's a sample session with the OSX fdisk program):


pteranodon:~/LifeDrive/custom-rom rbsfou$ fdisk /dev/rdisk1
Disk: /dev/rdisk1 geometry: 995/128/63 [8027712 sectors]
Signature: 0xAA55
Starting Ending
#: id cyl hd sec - cyl hd sec [ start - size]
------------------------------------------------------------------------
1: 06 0 1 1 - 16 80 15 [ 63 - 134016] DOS > 32MB
2: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
3: 0B 22 29 29 - 991 94 29 [ 179263 - 7818112] Win95 FAT-32
4: 00 0 0 0 - 0 0 0 [ 0 - 0] unused


And now we want to extend partition 3:


pteranodon:~/LD-Part-Tables rbsfou$ fdisk -e /dev/rdisk1
fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory
Enter 'help' for information
fdisk: 1> edit 3
Starting Ending
#: id cyl hd sec - cyl hd sec [ start - size]
------------------------------------------------------------------------
3: 0B 22 29 29 - 991 94 29 [ 179263 - 7818112] Win95 FAT-32
Partition id ('0' to disable) [0 - FF]: [B] (? for help)
Do you wish to edit in CHS mode? [n] n
Partition offset [0 - 8027712]: [179263]
Partition size [1 - 7848449]: [7848449]
fdisk: 1> w
Writing MBR at offset 0.
fdisk: 1> exit


In this particular case, OSX fdisk assumed (correctly) that we want the partition to end on the last sector of the disk.

3. The CF card will now NOT BOOT in the LD in it's current state (at least with OSX fdisk, as entry 2 has been erased by re-writing the MBR), so we want to merge the values for partition 3 from this new MBR into the old one.

So to start with, we take a copy of this new MBR:


dd if=/dev/rdisk1 of=new.sct bs=512 count=1


4. Now what we need to do is get a decent HEX editor (i used 0xED.app), and make sure it is in "Overwrite" not "Insert" mode (it needs to stay at 512 bytes and end in 0x55AA).

5. Open both new.sct, and table.sct in the hex editor. Now copy the 16 bytes starting from offset 478 decimal / 0x1DE hex (this is the partition table entry for partition 3) from new.sct into table.sct (the exact means of doing this will of course vary depending on the hex editor you are using).

FYI The standard one looks like this:

00281D0B0BCF5DF13FBC0200804B7700

6. Now save table.sct (this is the original MBR with these 16 bytes changed), and write it back to the CF card:


sudo dd if=table.sct of=if=/dev/rdisk1 bs=512 count=1


7. Now pop the card back in your LD, boot, and re-format with Card Info. You should have more space in your Lifedrive now :D

The 3rd Partition

You might have noticed that you cannot mount /dev/disk1s3 or /dev/sdc3 (whatever!) directly on a machine. This is because the FAT32 filesystem does NOT start at sector 179263 (as indicated in the MBR), rather it is 63 bytes beyond that, at sector 179326.

I can only conclude that this is something to do with Drive Mode, whereby the first (0th) sector is a "pseudo-MBR" containing one FAT32 partition (which is somehow faked by the USB mass-storage code in Drive Mode.prc), and the first 62 sectors of the partition are left blank as is the convention (probably something archaic to do with cylinder boundaries; tho at least on a PC it leaves room for GRUB :) ).

I sucessfully changed Partition 3 to start at 179326, and it mounted straight away on my mac. YMMV. This means (in theory) you could edit the start to be here (keeping the end as it is), then use some kind of FAT32 filesystem and partition resizer util to non-destructively make the filesystem fit the physical disk. But you would then need to set the start back to sector 179263 (for the benefit of the palm os) before you copied the parition entry into the MBR (Step 3 onwards).

I have NOT done this as my LD isn't "Production" yet with data i want to preserve (as i'm still fiddling with it!).

Also if anyone knows what these 16-bytes mean and how to fiddle with them, then they could probably bypass much of this process.

I'd be interested to know if anyone else makes this work; as i said i'll be getting an 8gb card soon, so i'll post my results to this thread.

UPDATE : Initial tests with drive mode are successful, and a "secure erase" kept the partition table the same with Card Info still reporting 3830.3mib. Secure Erase did hang however when it was near completion.

Furball
01-14-2008, 10:41 PM
Sweet! Another reason to keep my LifeFlash -- 8GBs!!!

Hopefully this will work out well :D

James_Screech
01-15-2008, 02:54 AM
PalmOS uses 32bit addressing for memory. So it can't address more than 4GB, you might be able to gain a small amount of memory this way but no-way near the full 8GB.

dmitrygr
01-15-2008, 03:08 AM
untrue...you CAN get 8gb, but requesting volume size or free space will return values MOD 4G, so if you have 7.8 GB partition with 3.9GB free it will be reported as a 3.8 GB partition with 3.9 GB free. As you might imagine this will confuse quite a lot of apps :-)

rbsfou
01-15-2008, 09:32 AM
PalmOS uses 32bit addressing for memory. So it can't address more than 4GB, you might be able to gain a small amount of memory this way but no-way near the full 8GB.

This would be true if we were talking about the 32-bits being used to address individual bytes in memory (the physical address lines on the processor).

However we are talking about these 32-bits being used to index disk sectors. If palmos treats disk sectors as 512 bytes each, then

(2^32) = total number of disk sectors addressable
* 512 = total number of bytes available
/ 1024 / 1024 / 1024 = total number of GiB adressable (just over 2TB).

I guess the problem lies elsewhere then - dmitry; do you know what files in the ROM are responsible for implementing VFS (and so therefore i guess functions for reporting capacities to other apps)?

Perhaps we could steal them from a 5.4.9.something device like one of those new phones....

rbsfou
01-24-2008, 05:35 PM
I just got my 8GB card, and it didn't work...at all. I've tried with the standard MBR, and a hacked MBR with partition 3 at 7.6GB and it didn't work. In both cases i've tried a custom rom partition as well as the original one, and neither have worked, grrr....

So this means so far i've got these cards working (the geometry is as reported by OSX) :

Sandisk 4.0GB (995/128/63)
Transcend 4.0GB (1018/128/63)

And this one failed :

"AData Speedy CompactFlash 8GB" (987/255/63)
(no other model numbers, but it was a cheapo from ebay, so i didn't expect that much)

So it appears the card has to have "128 heads"....I'm going to look for one now, but marketing NEVER seems to mention stuff like that!!

If i hooked it up to a linux PC using IDE i could try and figure out if anything else is going wrong using hdparm, but i can't be bothered at the moment (maybe it doesn't support a certain PIO or DMA mode or something)

rbsfou
01-24-2008, 06:04 PM
Ok, now i'm REALLY confused - i thought i would double check the geometry of my three cards using Linux - and the values were different! Check this out:


SANDISK

Disk /dev/sdc: 4110 MB, 4110188544 bytes
127 heads, 62 sectors/track, 1019 cylinders
Units = cylinders of 7874 * 512 = 4031488 bytes

TRANSCEND

Disk /dev/sdc: 4206 MB, 4206182400 bytes
130 heads, 62 sectors/track, 1019 cylinders
Units = cylinders of 8060 * 512 = 4126720 bytes

ADATA (8GB, not working)

Disk /dev/sdc: 8119 MB, 8119738368 bytes
250 heads, 62 sectors/track, 1023 cylinders
Units = cylinders of 15500 * 512 = 7936000 bytes


The common factor with the cards that work is that they have 62 sectors / track and 1019 cylinders. The amount of heads is different in both cases.

I'm now confused as to what i believe, as OSX and Linux give me different geometry values (although my gut instinct tells me to go with linux). It couldn't be anything to do with using a different card reader on each machine could it?

I might just install FreeBSD on another machine for a third opinion (i noticed once from three "identical" disks i had that linux seemed to think one had different geometry to the other two, yet FreeBSD was convinced the geometry was the same on all three).

potter
01-24-2008, 09:07 PM
I cannot say for sure as to what is going on. However, in general some tools report the geometry by reading the information from the partition table, and some read the information directly from the device. Since you have attempted to the LD conversion on this 8MB CF, the information in the partition table may be not incorrect.

lifedriveUser
02-14-2008, 11:33 PM
All,

Dimitry is looking for support to buy a 16GB CF card for testing purposes...his paypal id is dmitrygr@gmail.com

He already has a 1GB card working...and altered the 64Mb partition...

Contributions being accepted...check out this thread if you want to help make this happen...

http://www.1src.com/forums/showthre...033060&posted=1

Let's help make this happen....

dmitrygr
02-22-2008, 12:40 PM
ok....16GB card works! 128MB nvfs RAM, 4 internal drives at 4BG, 4GB, 4GB and 3.3 GB

aspenboy
02-22-2008, 05:21 PM
Holy cow! that's awesome dimitry. I would love this in my lifedrive! we should start another wiki to get the instructions out in a clear way.

looking forward to hearing more about this.

dmitrygr
02-22-2008, 06:27 PM
there is no instructions. there will be a utility that will do it all right on the device

JavaJiveJump
02-22-2008, 06:50 PM
Sweetness!