On Sun, Sep 03, 2000 at 12:41:42PM +1100 or so it is rumoured hereabouts, 
Malcolm Tredinnick thought:
> 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'm presuming when you refer to /dev/hdd and /dev/hdc you really mean
/dev/hdb and /dev/hda which would be the more likely arrangement in a 2
disk system and /dev/hda is definitely need if LILO is to be the boot
manager.  (Yes, I know one could have the two disks on seperate
controllers etc and am simplifying here)

>       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.
> 

Yeah, no bother...

A few things to do though...

LILO, by default uses /etc/lilo.conf for its configuration.  Let's have a
look at a typical /etc/lilo.conf

########## lilo.conf #########

boot=/dev/hda                   #This is where lilo will write to
map=/boot/map                   #I don't know what the map is for :-)
install=/boot/boot.b            #Similarly
prompt                          
timeout=50
default=linux

image=/boot/vmlinuz-2.2.14-5.0  #This is the kernel to boot
        label=linux
        read-only
        root=/dev/hda7          #This is the root partition

######## end ################
  
Now, since you have the new disk installed as /dev/hdd at present and have
its various partitions mounted under /mnt/<blah> You need to modify
lilo.conf to reflect these changes.  This is a once off modification so it
would be worth copying lilo.conf to lilo.conf.hdd and changing that
instead.  Here's the modified lilo.conf.hdd:

########## lilo.conf.hdd #########

boot=/dev/hdd                   #This will be the primary MBR when the
                                #disk is installed as the primary
map=/mnt/root/boot/map          #I don't know what the map is for :-)
install=/mnt/root/boot/boot.b   #But you need to add the /mnt/root bit
                                #anyhow
prompt
timeout=50
default=linux

image=/mnt/root/boot/vmlinuz-2.2.14-5.0  #This is the kernel to boot
        label=linux
        read-only
        root=/dev/hda7          #This is the root partition to be mounted
                                #on boot, don't change this

######## end ################

Now, do a:

/mnt/root/sbin/lilo -C /mnt/root/etc/lilo.conf.hdd

to install.

This info is derived from the Hard-Disk-Upgrade-(mini-?)HOWTO

############ now you can skip this bit ###########
>       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

This should read:

                cp -dpR /usr/ /mnt/usr

to ensure permissions and attributes get copied also.  Otherwise, you find
that root owns everything which is a bit embarassing when you move /home !

>       
>       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. :)

You *have* to be verbose to treat this subject properly!

> 
> Cheers,
> Malcolm

Cheers yourself..

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



-- 
Conor Daly <[EMAIL PROTECTED]>

Domestic Sysadmin :-)


_______________________________________________
techtalk mailing list
[EMAIL PROTECTED]
http://www.linux.org.uk/mailman/listinfo/techtalk

Reply via email to