On Sat, Sep 02, 2000 at 06:22:54PM -0700, Allen Heinecke wrote:
> I am considering installing a new HD in my computer as the old one is
> running out of space... however the "partition" / location that is running
> out of space is root...
> 
> what is the best way to migrate all of the root files, including the
> bootup files to this new HD?

There are two situations you may be in here. I'll give some hints to
both and then others can flame me.

(A) You are wanting to completely replace the old HD with new one (the
more difficult solution).

        Hook up the new HD to your machine and use something like fdisk or
        disk druid to partition it as you like. Then mount each partition
        under an appropriate directory. For example, suppose the new disk
        will have partitions called '/', '/tmp' and '/usr' (as partitions 1,
        2 and 3), I would make directories under /mnt called 'root', 'tmp',
        'usr' and then use the commands..

                mount -t ext2 /dev/hdd1 /mnt/root
                mount -t ext2 /dev/hdd2 /mnt/tmp
                mount -t ext2 /dev/hdd3 /mnt/user
        
        Then copy everything from your current HD to the new home on the new
        HD. Note that you will not need to copy the contents of /proc (they
        are not real files).

        Adjust /mnt/root/etc/fstab to mount the new partitions in the right
        spots (bearing in mind, that after you swap the new for the old, it
        will be /dev/hdc, so you would mount /dev/hdc1 under /tmp in the
        above example).

        I _think_ you probably need to rerun LILO so that the kernel copy
        that is on the new drive understands where it lives. There may well
        be a way to do this at this point in the plan, but I can't work out
        how to get LILO to write the result to /dev/hdd's MBR in a way that
        will work when you reboot it as /dev/hdc. Somebody else may be able
        to solve this (please?). Instead, I propose a different plan in the
        next paragraph.

        Shutdown the machine, put the new HD in place of the old one and
        reboot using a boot floppy (if you don't have one of these, or can't
        create one, ask again on this list and I, or somebody else, will try
        to help). Run /sbin/lilo on the new HD and it should correctly alter
        the bootup information.

** Caveat Emptor: What I have described is completely untested!!
However, it looks like it will work. Whatever you do, don't do anything
destructive to the old HD until you are sure the swapover worked.
Alternatively, go with plan B (below)...

(B) You want to add in the second HD to the system, but will keep the
first on installed as well (much easier!).

        Partition the new HD as you like and make each partition a "major"
        part of the directory structure, like /usr/local or /tmp or /usr or
        whatever. For the time being, mount these new partitions under
        appropriate directories under /mnt (e.g. /mnt/usr/local) using the
        mount commands I gave above.

        Copy everything from the current /usr directory over to what will be
        the new /usr directory (just an example). So in this example, you do
        something like

                cp -r /usr/ /mnt/usr
        
        Do this for all the directories you want to move across.

        **NOTE: You should leave your kernel image (probably in /boot, so
        leave all of /boot), /etc, /bin and /sbin on the first harddrive,
        otherwise you will have trouble booting!

        Now alter /etc/fstab to mount the new partitions under their new
        directory names. So, for example, if the partition mounted as
        /mnt/usr in the above case is /dev/hdd3, you would add a line to
        /etc/fstab like

                /dev/hdd3       /usr    ext2    defaults        1 2
        
        You can now reboot and verify that the new partition was mounted
        under the right spot.

        To reclaim your disk space, remove the above line from fstab,
        reboot again (this puts the old /usr directory back) and then
        remove all the contents of /usr (which frees up space on the
        first HD). Finally, add the fstab line back and reboot again.
        What could be easier?

OK .. both these methods look pretty involved on the screen, but I have
used the second one successfully. For extra safety, you may wish to wait
a couple of days and see how many people call me an idiot on this list
(or just point out blatant errors I've made).

I hope I've been clear enough without being too verbose, if you need
more information, just holler. :)

Cheers,
Malcolm

-- 
Malcolm Tredinnick            email: [EMAIL PROTECTED]
CommSecure Pty Ltd

PGP signature

Reply via email to