[lug] Re: Moving an existing installation to a second hard drive -- solution

BOF bof at pcisys.net
Mon Mar 18 16:02:10 MST 2002


This follows up on how I finally handled the question I asked about 
moving an existing Slackware installation to a new drive. I don't claim 
my solution to be the most elegant, but it worked, so I thought that I 
would post this for other users.

Note that this was done in single-user run level.

1. I created two partitions on the new drive with fdisk, /dev/hdb1 for 
the swap partition, and an extended partition /dev/hdb2, with logical 
partitions 5, 6, 7, 8, 9, and 10, and formatted them as ext2 partitions. 
They were somewhat smaller in size than the original drive, since I was 
moving from a 20 GB disk to a 14 GB disk.

2. Next, I made a swap partition, by issuing

    mkswap /dev/hdb1

Then I created a directory for mounting the partitions, /newsys, and 
mounted onto it the partition (/dev/hdb8) that I had chosen for the / 
directory. I changed to it and created the needed child directories: 
/tmp, /var, /usr/local (after creating /usr), /boot and /home under /newsys.

    mount -t ext2 /dev/hdb8 /newsys
    cd /newsys
    mkdir /tmp /var /usr /usr/local /boot /home
    mount -t ext2 /dev/hdb5 /newsys/tmp
    mount -t ext2 /dev/hdb6 /newsys/var
    mount -t ext2 /dev/hdb7 /newsys/usr/local
    mount -t ext2 /dev/hdb9 /newsys/boot
    mount -t ext2 /dev/hdb10 /newsys/home

3. I then changed to the / directory on the first drive and issued 
commands to copy all the files and directories on it except /cdrom and 
/proc to the new drive, by using the command "cp -a." To first see 
exactly what directories I had on the original drive, I issued ls and got

    bin   cdrom  etc   install  lost+found  opt   root  tmp  var  
    boot  dev    home  lib  mnt proc  sbin  usr  vmlinuz

So I issued

    cp -a /bin /boot /dev /etc /home /install /lib /lost+found /mnt /opt 
/root /sbin /usr /tmp /var

There was no reason to copy /cdrom, since it was empty, and /proc, since 
it was a virtual directory.

Next, since this was Slackware and there were files in the / directory, 
I copied them also

    cp -dp /* /.* /newsys

This copied the kernel, vmlinuz.

Next, I created directories for /proc and /cdrom. Now I had a complete 
copy of my system.

4. Being somewhat leary of this experiment <g>, I decided to continue to 
use the existing Slackware installation and boot off its lilo.conf file. 
If things were not right, I could still boot into it. So I added a 
stanza to the /etc/lilo.conf file

    image=/vmlinuz
            label=bslack
            read-only
            root=/dev/hdb8

and ran /sbin/lilo to add it to the boot menu.

I also modified the /newsys/etc/fstab file as needed to reflect the new 
drive setup by adding to it

    /dev/hdb1       swap        swap         defaults            0   0
    /dev/hdb8       /           ext2         defaults            1   1
    /dev/hdb9       /boot       ext2         defaults            1   1
    /dev/hdb5       /tmp        ext2         defaults            1   1
    /dev/hdb6       /var        ext2         defaults            1   1
    /dev/hdb7       /usr/local  ext2         defaults            1   1
    /dev/hdb10      /home       ext2         defaults            1   1

5. Now I rebooted the system and choose the new installation. Lo, and 
behold! it booted. So I changed the /etc/lilo.conf file to make it the 
default boot selection, reran /sbin/lilo, and made a boot diskette.

So far it is working fine.

And I thank all those who took time to answer my question.

BOF






More information about the LUG mailing list