# Upgrade twice (320G -> 1T -> 2T)



## marwatk (Apr 9, 2010)

Hi,

I have a normal Premiere (746320) that I originally upgraded to 1TB. That drive is failing so I got a new 2TB drive. Is there any way to upgrade again without losing my recordings? I'm perfectly comfortable rearranging stuff with dd or editing a partition table with hex, so even if there's no automated way to do it I'd love pointers on structure that I could tweak myself.

[I think] I know JMFS adds a single MFS partition to the end of the drive, is it possible to expand that partition or add another MFS partition?

Thanks!


----------



## marwatk (Apr 9, 2010)

I'm actually going to try for a 3GB drive I think. I found the DIY 4TB thread and the MFS Structure thread which I think will give me enough to go on, but any quick pointers would be greatly appreciated (it's a lot of information to digest).

One question, is is possible to simply alter the parition table expanding the previously created expansion partition and have it magically work? I can't tell if the mfs header (correct name?) contains starts and ends or just starts (and relies on partition extents for the size).


----------



## ggieseke (May 30, 2008)

The APM partition table only lists the start sector and the number of sectors in the partition (the size), but it gets more complicated when it comes to consolidating partitions due to the way MFS rounds off those values.

Jmbach will probably jump in as soon as he sees this, but get your post count up to 10 and send him a PM anyway. With a little guidance you can get to 3TB.


----------



## marwatk (Apr 9, 2010)

I've been working on it, but the amount of time it takes for trial and error is brutal with partitions this large. Right now I'm transferring the shows I wanted to keep from the un-expanded drive over to a working Tivo, then I'm going to delete all the shows on this one.

From there, can I just delete the last partition, divorce it, then run jmfs again? (I tried jmfs a second time but it added a 16th partition that didn't work, so I deleted it).


----------



## marwatk (Apr 9, 2010)

I haven't seen this mentioned anywhere, but VMWare Player (free) now supports physical disks larger than 2TB. Makes it super easy to switch between live cds by doing it all in VMs.

I have two sata wires dangling out of an empty pci slot in the back of my case and an external drive power cable. Makes it really handy to do all of this on one machine without rebooting all the time.


----------



## marwatk (Apr 9, 2010)

Ok, so all shows are off the Tivo I'm trying to double upgrade. I tried deleting the 15th and 16th partitions with plist and then booting the Tivo to divorce them, but it seems to not care they're missing. Mfslayout in jmfs gives me "Last sector of the Data of the Zone starting at ... does not fall on any known disk!" and won't let me re-expand.

So I still have an image of the original 1TB expanded drive (already had jmfs run on it once), what's the easiest way to get that up to 3TB if I don't need to preserve my shows? (I do need to preserve pairing, though)


----------



## unitron (Apr 28, 2006)

marwatk said:


> Ok, so all shows are off the Tivo I'm trying to double upgrade. I tried deleting the 15th and 16th partitions with plist and then booting the Tivo to divorce them, but it seems to not care they're missing. Mfslayout in jmfs gives me "Last sector of the Data of the Zone starting at ... does not fall on any known disk!" and won't let me re-expand.
> 
> So I still have an image of the original 1TB expanded drive (already had jmfs run on it once), what's the easiest way to get that up to 3TB if I don't need to preserve my shows? (I do need to preserve pairing, though)


When you say you need to preserve pairing, are we talking external drive or cable cards?


----------



## jmbach (Jan 1, 2009)

Well to get to 3TB on the premiere we need to get your 1TB image down to 14 partitions. What I recommend is that we rearrange the partitions on your drive. Although in the 4TB DIY, the quick and dirty method swaps partitions 10 and 12 and then coalesces 10 and 11 into 10, I prefer a method that leaves partition 10 alone and coalesces other partitions. In order to do that, partitions 11 and 13 need to be swapped. However, that will require you to move all the partitions. Of course by doing that, you can also 4K align the drive. So here is what I recommend.

Copy the source drive blocks 0 to 63 inclusive over to the 3TB drive. This copies over "partition 1" which is the APM to the 3TB drive. Then you will need to edit the 3TB drive APM to reorder the partition layout on the drive. The partition layout I recommend is 1,11,12,13,15,2,3,4,5,6,7,8,9,14,10. Since MFS only uses the space in any of the partitions in multiple of 1024 blocks, reduce the size of partitions 11,13,15 to the largest multiple of 1024 blocks that can fit in the partition. If you use iBored then the "first partition block" value in partition 11 is 64 and the "partition block count" value is the largest multiple of 1024 blocks that fit in the original value. This is usually a few hundred blocks smaller. Make sure you also change the "data block count" to the same value. Then for the next partition, the "first partition block" is the value of the preceding partition "first partition block" value plus the preceding partitions "partition block count". Keep on doing this for each partition entry until the last partition. 

Once that is done, then copy each partition from the source drive to the target (3TB) drive. In iBored, when you copy the partitions over the start block is the "first partition block" from the source and the number of blocks to copy is the "partition block count" on the target drive. The destination block is the "first partition block" of the destination drive. Do not copy partition 1 over as that will overwrite the APM on the 3TB you just modified. To keep the drive 4k aligned, partitions 2 and 5 should be 8 blocks in size and not 1. So you will change the value in "partition block count" and "data block count" to 8 in each of those partitions. These two partitions are empty meaning they are filled with 0x00. 

Once the partitions are all copied, put it in your TiVo to make sure it works. Once you verify it works, then take it out and coalesce partitions 12 and 13 into 12. You do this by adding the value in "partition block count" in both partitions and replacing that value in partition 12 entry. Also change the value "data block count" to the same number. Then slide the information in APM entry 15 to 13 by copying block 15 to block 13. then erase block 15 which will delete the APM entry for 15. Now change the value "blocks in partition map" to 14 for all APM entries 1 through 14 inclusive. Once this is all done, put the drive back in the TiVo and let it divorce. 

Once that is done, then use JMFS to expand the drive to the full 3TB.


----------



## Cybernut (Oct 1, 2013)

Again thanks to jmbach's perfect method in the above post, I have upgraded my 2nd TiVo Premiere to 3TB...this time from the Premiere 320 gig model (TCD746320). 479 HD hours is sweet. But 640 HD hours is sweeter...4TB upgrade, here I come 

Thank you very much jmbach!!


----------



## Cybernut (Oct 1, 2013)

And again thanks to jmbach, my second TiVo Premiere (this time TCD746320) upgraded to 640 HD Hours (4TB drive)!!


----------



## marwatk (Apr 9, 2010)

Sorry for the late reply, I spent a week and a half trying to get a universal boot cd created with no luck.

At any rate, working with jmbach (thanks so much!) I created a set of linux shell scripts to help copy and coalesce partitions so you don't have to do it manually.

You can download the scripts here. (Or browse them here)

My scripts are in the "coalesce_scripts" folder. I tried to collect all the various Tivo tools into one place, so there are folders for jmfs, mfs-tools and tivo-part as well.

There are two important scripts, the rest are utility scripts.


```
tivo_copy_rearranged.sh <source device> <dest device> <partition order>
```
Example: 

```
./tivo_copy_rearranged.sh /dev/sda /dev/sdb 1 11 12 13 15 2 3 4 5 6 7 8 9 14 10
```
This script will copy the Tivo partitions from one drive to another, rearranging the on-disk order to what you specify for later coalescing.


```
./tivo_coalesce.sh <device> <first partition> <second partition>
```
Example: 

```
./tivo_coalesce.sh /dev/sdb 12 13
```
Merges two adjacent tivo partitions freeing up a slot at the end for expansion by jmfs. After doing this you'll want to insert the drive back into the tivo so it can divorce the [what it thinks is] missing partition.

So, basic order is this:
1. Use tivo_copy_rearranged.sh to copy the partitions to the new disk
1a (optional): Put drive in tivo to make sure the copy worked
2. Use tivo_coalesce.sh to merge partitions 12 and 13 (in this case)
3. Put drive back in tivo to divorce the missing partition
4. Use jmfs tools to expand again

I tested that order and it worked fine twice with two different tivos. Note they require the 'xxd' linux command, which isn't on the jmfs boot cd, so you can't use that to do the transfer (hence why I was trying to create a universal cd)

USE THESE AT YOUR OWN RISK. THEY ARE NOT USER FRIENDLY AT ALL.

Hopefully someone can make them more friendly. I was going to, but I tried to do too much and create a universal ISO image. In my mind that would require 3 or 4 things:

- kernel patches to support Tivo partition tables (see the changes here)
- java for running jmfs
- ddrescue, dd, etc tools
- (optional) networking support for updating the tools via git so we don't have to build a new iso every time tools change

I tried two different distros to get this working (sysresccd and centos) but couldn't get everything working at the same time.

I hope this helps someone else! Thanks again to jmbach for all the help creating these!


----------



## cykotix (May 22, 2014)

I believe I built a universal tool using your scripts, jmfs rev104 and the latest version of Slax 7 that includes the xxd module. I won't know until tonight how well it works though, but it boots and seems I can execute everything just fine. 

I grabbed the latest version of Slax 7, removed the extra modules, grabbed the openjdk6 and xxd modules, recompiled jmfs and converted it to a Slax 7 module while adding your TivoTool scripts to the file structure. Removed the bat scripts, set all the sh files to executable, then built the iso. Dropped the iso on a usb stick and booted.

I'm replacing a 320gb and a 500gb Premiere with new 4TB drives. Fingers crossed it goes well. I'll let you know how it goes.


----------



## cykotix (May 22, 2014)

So far I'm running into a few issues. First, it doesn't look like many (any?) have gone from factory 320/500gb drives straight to 4TB. Everyone uses a 1TB/2TB intermediate. I'd like to avoid that.

Since I'm starting with a factory image (not expanded or supersized), it only has 14 partitions. I was hoping to get some sort of insight on how to proceed after doing the copy. So far I've done (sdf 320gb, sde 4TB):


```
./tivo_copy_rearranged.sh /dev/sdf /dev/sde 1 11 12 13 2 3 4 5 6 7 8 9 14 10
```
This boots and works fine and gives me 47hrs, same as the 320gb as you'd expect. If I expand and supersize, I hit the 2.2TB JMFS limitation. Of course it boots and works but I'm only at 401hrs. Where do I go from here or amend what I've done so far?

I should have 15 partitions after expanding/supersizing to 2.2TB. I imagine I need to coalesce 11 & 12 into 11 to reduce back down to 14 partitions, put the drive back in the tivo to let it divorce. Once that is complete, use JMFS to expand/supersize once more?

I see what is suggested with hdparm -N# in the 4TB DIY thread but that's only possible with a drive that has more sectors than the difference left on the 4TB disk, which a 320gb drive does not. Any thoughts?


----------



## jmbach (Jan 1, 2009)

A couple of thoughts. One is that if you are planning to go to 4TB from a 320GB drive you will have to expand to about 2TB and then coalesce followed by another expansion. You will need to fix JMFS to work on images larger than 1.5TB in order to make it easy and not as convoluted as it is in the 4TB DIY. What you can do to avoid using another drive as an intermediary is to copy the your source drive to a 4TB and use hdparm to temporarily limit the sector count on the drive to about 2TB. Expand with JMFS and then remove the temporary restriction. Coalesce to get the partition count back to 14 followed by expanding again with JMFS(as long as it was patched to handle larger images)


----------

