Log in

No account? Create an account

Previous Entry | Next Entry

Task: Repair a damaged database.

Constraint: The server it's residing on doesn't have enough space to repair it. The Linux partitions on the client are too small; there's an NTFS partition with enough space, but Linux cannot change the size of files on such a partition. SMB is far too slow to simply mount the NTFS partition to the server and use it as scratch space--or even to copy the file over, repair it under Windows, and copy it back.

Solution: Create a big file on the NTFS partition (in Windows), put an ext2 filesystem in it, and use the loopback device to mount it. Then copy the file to the scratch filesystem with NFS, repair it, and copy it back.

Step 1: perl -e "open (TEMP, '> c:\temp.ext2'); for(0..5*1024*1024) { print qq(\r), int($_/1024); print TEMP qq(\0) x 1024 or die $! }" (Generates a 5GB file.)
Step 2: Boot into Gentoo
Step 3: emerge nfs
Step 4: ssh navi, then /etc/init.d/apache stop; /etc/init.d/mysql.server stop; emacs /etc/exports; /etc/init.d/nfs start
Step 5: mount navi:/ /mnt/navi
Step 6: mke2fs /mnt/win/temp.ext2
Step 7: mount -o loop /mnt/win/temp.ext2 /mnt/temp
Step 8: cp /mnt/navi/var/mysql/apache/access_log.* /mnt/temp
Step 9: emerge =mysql-4.0.17
Step 10: myisamchk -r /mnt/temp/access_log
Step 11: cp /mnt/temp/access_log.* /mnt/navi/var/mysql/apache
Step 12: ssh navi, then /etc/init.d/mysql start; /etc/init.d/apache start

And it worked, with only minor problems (mainly relating to NFS configuration). It was almost too easy, once I figured out how to do it.


( Read 1 comment — Leave a comment )
Nov. 1st, 2004 08:05 pm (UTC)
mm.. behold the power of block-access devices =)

Nice solution Brent.
( Read 1 comment — Leave a comment )