Moving Linux Boot Partition

Jerry Feldman gaf at blu.org
Tue Sep 7 10:48:01 EDT 2004


On Tue, 07 Sep 2004 10:04:26 -0400
greg <greg at kettmann.com> wrote:

> My "home" server is older and running Red Hat 7.3 (AMD 450Mhz, 384MB 
> memory).  Simple stuff, Apache, Samba, FTP, and SSH for the most part.
>  
> It began with an 8GB HD which currently has the /boot and / 
> subdirectories.  The bulk of the storage is on a 120GB drive with a 
> /shared subdirectory.  I'd like to "add" another 120GB drive, which 
> isn't easy based on the physical layout of the machine.  I see three 
> main options:
> 1)  Find a way to add a third drive - possible, but not my first
> choice 2)  "Move" the /boot and / partitions to the current /shared
> drive and replace the 8GB with the 120GB drive - Sounds very
> difficult, is it even possible.  I do have partition magic, if it
> would help. 3)  Reinstall a more "current" release of Linux - arguably
> the easiest but doubtless I have modified this machine in ways I don't
> remember so there will be some migration pain. 
> 
> Is two possible?  Relatively easy or fairly difficult?  What are the 
> basic steps?
I've done similar things. 
First, Linux file systems can be moved anywhere. There are no unmovable
files. 
Let's assume that you can only have 2 physical drives, /dev/hda (primary
master) and /dev/hdc (Secondary Master). For the time being, you'll
probably want to keep your current system.

I personally prefer that the /home and /usr/local directories are
separate file systems so that when you install a new version of Linux,
that you don't clobber the data. Also, I generally do not do a separate
/boot partition, but there are some good reasons to have it.

Next, burn a stand-alone Linux such as Knoppix 3.4.

Here is how I would do it:
1. Power off and install the new drive in place of the existing 8GB
drive. And place the 8 GB drive in place of the old 128GB (This should
be just a cable swap). 
2. Boot Knoppix and run QTParted. The main reason for a standalone is
that copying a root file system is a pain when you are using a running
system.
3. Create your partitions (I prefer to put all Linux partitions in an
extended partition rather than making primaries). You can set up the
partition table any way you prefer. 
For example.
/dev/hda1 - /boot
/dev/hda2 - EXTENDED...
/dev/hda5 - / Root
/dev/hda6 - Linux Swap
/dev/hda7 - /home
/dev/hda8 - /usr/local
etc.

4. Format the partitions either ext2, ext3 or whatever is appropriate. 

5. Create a mount point for the old root and new root file systems.
Mount the old root partition as readonly (for safety). You can mount the
old /boot separately

7. Copy recursively the old root to the new root:
cd /mnt/oldroot;
cp -pR . /newroot


8. Copy recursively the old boot in the same manner. 

9. Now, edit the /newroot/etc/fstab and make the appropriate changes.
Remember that the drive will become the /dev/hda drive after power off.

10. Edit the GRUB menu.lst or the lilo.conf file as appropriate to point
to the appropriate places. (If /boot in your 8GB is /dev/hda1 and your
new /boot is the first partition then there needs to be no changes to
the lilo.conf or menu.lst.

12. chroot to the new root so you can set LILO or GRUB for booting.

13. With lilo, then run /sbin/lilo, or with grub, just run
/usr/sbin/grub. Now your new drive should be bootable. 

14. unmount and power off. 

16. put your old 128GB drive back in its place. 

17 If all done correctly, your new system should boot. 
-- 
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.gnhlug.org/mailman/private/gnhlug-discuss/attachments/20040907/9e7601cb/attachment.bin


More information about the gnhlug-discuss mailing list