# How can I manually partition my B drive



## ciper (Nov 4, 2004)

I have two blank drives and a completely stock original 40gb drive from a series 1 (used as a virgin image for the other two drives). I would like to create an extra partition on the B drive.

My plan is to use the MFSLive cd which fixes the swap size bug in MFSTools combined with an LBA48 aware + version 1 swap header kernel.

I would like to place a 512mb swap partition on the B drive and give it higher priority over the 512mb swap partition on the A drive for best performance (since database reads wont have to compete for swap access).

So far I can't figure this out. I've posted it on other forums but no one ever replies. If you have ANY ideas (even dumb ones) please share because it might inspire me in the right direction!

Thanks


----------



## AMc (Mar 22, 2002)

It seems the way you're headed is bound to cause problems at some point - an old drive, a non standard configuration, a second drive (increasing the probability of a failure anyway).

I'm still running my old Fireball  because to upgrade again I'd have to junk my recordings. I know one day the whole thing will go belly up and I'll have to start again but I'm hoping someone will have worked out a way to allow me to do a full backup with recordings from two drives into one large drive by then  If you're starting from nothing I don't understand your reasoning for keeping an old small drive in the mix?

I can't help you directly - but why aren't you just using the original 40GB drive to create a backup and then create a working image on a single large drive?


----------



## mikerr (Jun 2, 2005)

ciper said:


> I would like to place a 512mb swap partition on the B drive and give it higher priority over the 512mb swap partition on the A drive for best performance (since database reads wont have to compete for swap access).


Nice idea but in practice the tivo really isn't being slowed down by its swap access in most things.

A 512MB cachecard hosts the whole database in its RAM, but its really only faster on:

Rearranging season passes using the tivo UI
Opening now-playing when you have 10+ pages of recordings

Also some people have upgraded the tivo RAM on the mainboard (reducing the need for swap) and didn't gain much difference in noticable GUI speed.

The only reason to use two drives is if you want the extra capaity they afford - .e.g. 2x 400GB drives


----------



## ciper (Nov 4, 2004)

I already got a 700MB version 1 swap working on the B drive but the rest of the drive wasn't being used for recordings.



mikerr said:


> Nice idea but in practice the tivo really isn't being slowed down by its swap access in most things.
> Also some people have upgraded the tivo RAM on the mainboard (reducing the need for swap) and didn't gain much difference in noticable GUI speed.
> 
> The only reason to use two drives is if you want the extra capaity they afford - .e.g. 2x 400GB drives


Before my recent A drive crash I had 360gb of recordings and it was excruciatingly slow much of the time. I also plan to upgrade the ram once the system is stable and my ultra fine tip soldering tip comes in. Any suggestion on how to increase the speed? I already have a 512MB cachecard.



AMc said:


> I can't help you directly - but why aren't you just using the original 40GB drive to create a backup and then create a working image on a single large drive?


I wasnt clear in my first post. The 40gb drive is the source of a virgin image which will (has already) been placed on a 500gb A drive and a 200gb B drive.

I have already experiment with a 700mb swap on the A drive as well as a swap file inside of the var partition. 
I'm surprised your original drive is still functioning. My Tivo has already killed two drives - most recently being a 200gb seagate.


----------



## mikerr (Jun 2, 2005)

ciper said:


> Before my recent A drive crash I had 360gb of recordings and it was excruciatingly slow much of the time. I also plan to upgrade the ram once the system is stable and my ultra fine tip soldering tip comes in. Any suggestion on how to increase the speed?.


Install a Cachecard with 512Mb RAM. 

Soldering some ram onto the mainboard (moving tivo from 16Mb to 32Mb)
isn't enough to cache the full database like the cachecard does.

The member that did this saw no real difference IIRC .. can't remember who it was though.


----------



## ciper (Nov 4, 2004)

I already have a 512mb cache card. Still slow as hell when I had 360gb of recordings. Now I have the potential for nearly double that so I want to set this thing up correctly from the get go.


----------



## mikerr (Jun 2, 2005)

A search brings up this thread on adding a partition and swap on B drives:
http://archive.tivocommunity.com/tivo-vb/showthread.php?s=&threadid=151109


----------



## ciper (Nov 4, 2004)

Damn! Thanks for the link. I was on the right track all along. For some reason I couldn't get these steps to work on the MFSLive cd. MFSadd was generating an error which I can't remember at the moment.

If I remember right mkswap and swapon don't function correctly even with byteswapping turned on so I will try to use tpip to format the partition once pdisk has created it. 

Theoretically if I set the priority of both swap partitions to be equal wouldn't the kernel stripe the writes to both?

Ill let you guys know 

edit: BTW guys if you use one of the modified kernels from the TPIP site it will enable version 1 swap files/partitions so you can create swaps of any size (upto 2gb each). The original Tivo kernel can only support version 0 which has the 127mb limit. If you insist on using the stock kernel you can create multiple 127mb swap partitions.


----------



## ciper (Nov 4, 2004)

A small update - I did a non destructive test on my B drive already with some success. My B drive had 13mb of left over unpartitioned space so I created a partition and used mkswap on the tivo to initialize it. Swapon was able to use this swap just fine. The only problem is that the standard mkswap binary on the tivo only creates version 0 swaps...

I tried to use tpip to initialize the swap file but it can only work against the A drive.

Any suggestion on a swap initialization tool that respects byte swapping and will work against the B drive?

edit: I have found an updated version of mkswap for the tivo that will create version 1 swaps!

I just wish there was a utility for the PC that could create version 1 swaps on the B drive.

edit2: Found it! http://www.************.com/forum/showthread.php?p=224882&highlight=mkswap#post224882 replace the stars with you know what


----------



## ciper (Nov 4, 2004)

I wanted to post this for anyone else who finds my post later on.

*The Tivo does NOT support more than one swap entry in the FSTAB!*

I tried for hours every combination of swap layouts/configurations in the fstab. No matter how you form the entries the tivo will never boot if the fstab is edited to list more than one swap entry. Its hard to troubleshoot because no logs are created (since its so early in the boot process). You have no fricking idea how many times I swapped the drives between my PC and the tivo......

There is a workaround though! I didn't want to only list the swap partition on the B drive so instead I did the following -

Modify the fstab swap line options to give /dev/hda8 a priority number

```
/dev/hda8 swap swap    sw,pri=3 0 0
```
Then at the top of your rc.sysinit add the following line (with the appropriate location)

```
swapon -v -p 5 /dev/hdb4
```
This makes the TV add the extra swap an the *-p 5* gives it a higher priority (used first) over the original swap with priority 3

I've tested this on an S1 and verified it works. If you are still using the stock kernel this method allows you to create multiple swap files upto 127mb each and should allow mfsfix GSOD to complete

Can someone verify that the rc.sysinit is started when a GSOD is initiated?

edit: Kernel log entries to prove this from my most recent reboot

```
Jan  1 00:03:18 (none) kernel: Activating swap partitions
Jan  1 00:03:18 (none) kernel: Adding Swap: 716796k swap-space (priority 3)
[i](time passes as other items are loaded)[/i]
Jul 31 06:12:58 (none) kernel: Adding Swap: 13492k swap-space (priority 5)
```


----------



## ciper (Nov 4, 2004)

Deleted, see my next post


----------



## blindlemon (May 12, 2002)

I thought that might happen 

Personally I doubt whether you will see any performance benefit from putting the swap on the B drive. However, you could try doing an MFSadd with a non-LBA48 version of the boot disc (to use 137gb only) then rebooting into a LBA48-aware environment, rebuilding the partition table (to pick up the extra free space) and adding a swap partition with pdisk, then running mfsadd again....


----------



## ciper (Nov 4, 2004)

I THINK I'VE DONE IT
Here are the steps I took -

My drive layout is as follows
/dev/hda - 40gb original unmodified Tivo drive
/dev/hdb - MFSLive CD
/dev/hdc - New A drive for Tivo
/dev/hdd - New B drive for tivo
/dev/sda1 - usb stick for files not included on MFSLive cd (new kernel, modified mkswap etc..)

Previously my backup|restore went at around 1.5mbps. I used "hdparm -a 255 -c 1 -k 1 -m 16 -S 0 -u 1 /dev/hda /dev/hdc /dev/hdd" to speed it up. *Do not enable DMA as it breaks bite swapping*

Create the correct layout on the B drive the long way 

```
backup -qso - /dev/hda | restore -s 700 -r 4 -xzpi - /dev/hdc /dev/hdd
```
Delete the Tivo partitions so the B drive only has 1 partition type "apple_partition_map" name "apple

```
pdisk /dev/hdd
d (delete)
2 (application partition
d (delete)
3 (media partition
```
Reimage A drive without B drive (use the up arrow so you don't have to type it again)

```
backup -qso - /dev/hda | restore -s 700 -r 4 -xzpi - /dev/hdc
```
Create new swap partition on B drive

```
pdisk /dev/hdd
C (upper case - create partition with type)
64 (starting block of free space)
1440000 (length in blocks - tried to get 700mb end up with 713mb)
"Linux Swap" (name of partition and the quotes are necessary!)
Swap (type of partition)
C (create)
1440064 (start of application partition)
2048 (length results in 1mb)
"New MFS Application" (name, don't forget quotes)
MFS (type)
C (create)
1442112 (start of media partition)
389279856 (rest of remaining space on drive)
"New MFS Media" (name with quotes)
MFS (type)
w (save changes)
Y (yes to overwrite)
q (quit)
```
Now you can add the new space

```
mfsadd -r 4 /dev/hdc /dev/hdd3 /dev/hdd4
```
Using a modified version of mkswap which supports bite swapping is the only way to accomplish this on the PC. Otherwise even with byte swapping enabled on the boot cd it WON'T WORK. You can skip this step if you have a modified version of mkswap on the tivo that can create version 1 swap partitions.

```
mkswap -S /dev/hdd2
```
thoughts?
edit: Oh yeah don't forget to copy over a modified kernel that supports both lba48 AND version 1 swaps or none of this will work!


----------



## mikerr (Jun 2, 2005)

Now you need to create a few hundred season passes and entries in now playing

Then we can see benchmarks of say, re-ordering season passes and first entry into now-playing ... with and without the swap on B drive.


----------



## ciper (Nov 4, 2004)

I used to have about 35 season passes before my A drive crapped out.

Is anyone reading this? Anyways here is a printout of my memory information after a fresh reboot of the system

```
bash-2.02# cat /proc/meminfo
        total:    used:    free:  shared: buffers:  cached:
Mem:  14274560 14114816   159744 66727936   487424  4706304
Swap: 1471266816        0 1471266816
MemTotal:     13940 kB
MemFree:        156 kB
MemShared:    65164 kB
Buffers:        476 kB
Cached:        4596 kB
SwapTotal:  1436784 kB
SwapFree:   1436784 kB
```
Yes thats 1.4gb of swap on a series 1 tivo  I know this is completely unnecessary but here is my reasoning. I wanted to have 1mb of swap for every 1gb of disk space. I wanted to move the swap partition to the B drive for better performance and I wanted to have a swap partition on the A drive in case something happens to the B drive. 
Here are the relevant Kernel log entries

```
[i]My custom entrie at the start of rc.sysinit[/i]
Jan  1 00:03:18 (none) kernel: swapon on device /dev/hdb2 
Jan  1 00:03:18 (none) kernel: Adding Swap: 719996k swap-space (priority 5) 
...
[i]The regular swapon -a in the middle of rc.sysinit that reads fstab with /dev/hda8[/i]
Jan  1 00:03:18 (none) kernel: Activating swap partitions 
Jan  1 00:03:18 (none) kernel: Adding Swap: 716796k swap-space (priority 3)
```


----------



## AMc (Mar 22, 2002)

I'm still reading, I don't get most of it as I'm neither a Linux nor MFS nut but I'm interested in your results. When my fireball does give in I will want to upgrade to the fastest and largest possible system so anything you learn will help us all in the long run.
Thanks for taking the time to update the thread even if most of us can't help you


----------



## ciper (Nov 4, 2004)

Does anyone know of a way to benchmark file system reads? Would copying a file to null and timing how long it takes be accurate? I've read about two more changes (noatime and data=writeback) Ill try to make which should further increase performance but I want to test it before writing too much about it.

Also is their anyway to do a graceful shutdown of the system? Even choosing "restart the recorder" essentially crashes it requiring fsck to run at startup against the var partition. Can I sync the discs and remount var as read only before rebooting? Does anyone have a copy of the reboot binary?

AMc: Why not upgrade now and save the drive? The best thing I ever did was to save the original virgin quantum drive. It makes recovering from a mistake (or failed drive) SOOO much easier. The longest part of recovering from my drive failure was trying to find where I stuck the fireball!

Im actually not an MFS or Linux nut either. I probably did this the hardest way possible and hope that eventually someone will come look. One thing I did find out is that if you set the swap priorities to equal numbers it will actually stripe the writes to them which gives the effect of a raid. I almost did this but I thought freeing the database drive from swapping would be the best option.

It was REALLY stupid that DMA breaks byteswapping. I literally spent 2 hours trying to figure out what the hell was happening. Im guessing that Hdparm -d 1 works fine on the tivo because byteswapping is always enabled.

I should point out that the *biggest improvement* of speed on the Tivo by far has been the following addition to the top of rc.sysinit

```
hdparm -a 255 -c 1 -d 1 -k 1 -m 16 -M 1 -S 0 -u 1 /dev/hda /dev/hdb
```
My Tivo is still pretty empty but I can say that with 16 season passes I can reorder them WAY faster than what I was used to be.
BTW Im not in the UK. I use this forum because there is no one helps or listens to S1 users anywhere else.


----------



## mikerr (Jun 2, 2005)

ciper said:


> Does anyone know of a way to benchmark file system reads? Would copying a file to null and timing how long it takes be accurate?


That wouldn't hit the disk though ... would be best copying to /var


> Also is their anyway to do a graceful shutdown of the system? Even choosing "restart the recorder" essentially crashes it requiring fsck to run at startup against the var partition. Can I sync the discs and remount var as read only before rebooting? Does anyone have a copy of the reboot binary?


On the tivo itself? or from telnet?

/sbin/restart instead of /tvbin/reboot ?


----------



## ciper (Nov 4, 2004)

mikerr said:


> That wouldn't hit the disk though ... would be best copying to /var


edit: Deleted old idea. This is better.
To test disk speed. Refer to "real" time and final size of file.

```
echo "start 50mb write"
time dd if=/dev/zero of=/var/hack/testfile bs=50000k count=1
echo "start 50mb read"
time dd if=/var/hack/testfile of=/dev/null bs=1000k
echo "size of file in kilobytes"
ls -k -s testfile | cut -d ' ' -f 1
rm /var/hack/testfile
```
As for testing the speed of the B drive I can only figure out how to do reads without creating another partition in the left over space
time dd if=/dev/hdb2 of=/dev/null bs=1000k count=50

Hehe all this testing and look what I made!
_bash-2.02# ps ax
PID TTY STAT TIME COMMAND
566 p0 TW 0:00 (bash)
568 p0 Z 0:53 (dd <zombie>)
598 p0 RW 0:00 ps ax_
A zombie! If I give it brains will it go away?


mikerr said:


> On the tivo itself? or from telnet?
> /sbin/restart instead of /tvbin/reboot ?


From any place. They all seem to just crash the system. Ill check if the reboot binary does it too.
Edit2: Sigh even the reboot binary you gave me does it. No wonder people keep getting their var partitions erased.


----------



## AMc (Mar 22, 2002)

ciper said:


> AMc: Why not upgrade now and save the drive?


 I have a virgin Tivo image from when I upgraded my folks to a helpful thread on here. The original 30GB drive has been my B for years and the 15GB went off in an old PC - I upgraded to the 120GB +30GB when the 120GB dropped below £100 
The main reasons for running it 'until the wheels fall off' is that I'd definitely lose recordings thanks to the previous upgrade path. I'm hoping that the later MFSLive (?) work will eventually create a method that will allow me to upgrade to a single 500GB and keep my recordings.
In the mean time I watch my Dailymail and keep an eye out for sticking and stuttering recordings...


----------



## ciper (Nov 4, 2004)

I know how you feel. I lost 400gb of recordings recently. I knew my drive was failing and so I tried to find a way to go back to one drive. In the few days afterwards while searching for a method and waiting for my new 500gb drive to come (only 90$ on ebay) the A drive failed completely.

However by now couldn't you have already re recording the shows you've lost?


----------



## ciper (Nov 4, 2004)

Okay for those who are really brave I have experimented with another set of parameters that help improve speed.

The first one can be dangerous if you set the wrong option. I tested against my B drive first so that there was no chance of database corruption. The IDE controller in the Tivo supports upto MDMA2 for disk transfers. You can set the even faster UDMA modes but it will freeze the system. I was able to get MDMA2 working on my drives by adding "-X 34" to the HDPARM line in the rc.sysinit . Here is a description of valid options


```
PIO modes (Programmed IO) (disk mode (above) + 8)
hdparm -X08 -> PIO 0
hdparm -X09 -> PIO 1
hdparm -X10 -> PIO 2
hdparm -X11 -> PIO 3
hdparm -X12 -> PIO 4

SDMA modes (Single-word DMA) (disk mode (above) + 16)
hdparm -X16 -> SDMA 0
hdparm -X17 -> SDMA 1
hdparm -X18 -> SDMA 2

MDMA modes (Multi-word DMA) (disk mode (above) + 32)
hdparm -X32 -> MDMA 0
hdparm -X33 -> MDMA 1
hdparm -X34 -> MDMA 2

UDMA modes (Ultra-DMA) (disk mode (abov) + 64)
hdparm -X64 -> UDMA 0 (ATA16)
hdparm -X65 -> UDMA 1 (ATA 25)
hdparm -X66 -> UDMA 2 (ATA 33)
hdparm -X67 -> UDMA 3 (ATA 44)
hdparm -X68 -> UDMA 4 (ATA 66)
hdparm -X69 -> UDMA 5 (ATA 100)
```
Second setting the noatime option in the fstab helps to speed up access to the var partition. You can test this without rebooting using


```
mount -o noatime,remount /
or
mount -o atime,remount /
```
*Any other suggestions on what to try? My tivo is still pretty much empty so I dont mind to experiment for you guys*


----------



## ciper (Nov 4, 2004)

The Tivo does not support the "nodiratime" option. 
You can set "noatime" on / but it doesn't make a difference since the partition is read only. 
Setting "noatime" on the var partition but the only application I can tell that benefits is MFS_FTP when it runs the update.
The Tivo seems happy with the prioritized swap. I have never seen more than 10MB of swap used but it is respecting the priority settings.
I am currently experimenting with nice'ing different tasks to improve gui performance.


----------



## mrtickle (Aug 26, 2001)

Hmm. Only last week I wound down my hdparm settings because of random corruption of files in my var partition (especially the Tracker module data files - very frustrating).

I did have (tivo's own hdparm):
hdparm -c1 -d1 -m16 -S0 -M1 /dev/hda

I now use (using a later hdparm which doesn't support -M):
/var/hack/bin/hdparm -a0 -A1 -c1 -d1 -S0 -m0 /dev/hda

You may also like to add this line to rc.sysinit.author:
/var/mfs_ftp/setpri fifo 1 $$

Can't remember where I read it but it's supposed to help!

In the days when I used a serial cable running PPP I used to use a Freepages tweak:
echo "128 256 1024" > /proc/sys/vm/freepages

Ultimately though you won't improve GUI performance much. Take an empty TiVo with no thumb settings and no Season Passes and remember how fast it is. Add a cachecard and you can get your TiVo back to almost that speed. (See http://www.silicondust.com/forum/viewtopic.php?t=858 for why).


----------



## Alessan (Feb 23, 2002)

I saw it at one time but can't find it again. Does anyone have the list of the different partitions and what are on those partitions on the tivo drive?


----------



## blindlemon (May 12, 2002)

These are fairly typical layouts:-


```
A Drive
#	type	name
1	Apple_partition_map	Apple
2	Image	Bootstrap 1
3	Image	Kernel 1
4	Ext2	Root 1
5	Image	Bootstrap 2
6	Image	Kernel 2
7	Ext2	Root 2
8	Swap	Linux swap
9	Ext2	/var
10	MFS	MFS application region
11	MFS	MFS media region
12	MFS	New MFS Application
13	MFS	New MFS Media
	Apple_Free	Extra


B Drive	
#	type	name
1	Apple_partition_map	Apple
2	MFS	New MFS Application
3	MFS	New MFS Media
	Apple_Free	Extra
```


----------



## ciper (Nov 4, 2004)

Old thread back to life. Just wanted to pop in and say my tivo has been using 1.4GB of swap ever since with no issues.


----------

