Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Moving an installation, from one partition to another.

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
edbarx
Posts: 5401
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E
Been thanked: 2 times

Moving an installation, from one partition to another.

#1 Post by edbarx »

So, you have a working installation, and for some reason, you want it transferred to another partition or to another disk possibly before a disk failure. I have done this several times, and the good news is that, it can be done and it should work.

Needless to state the obvious, if you are doing this due to an impending disk failure, the first thing is to make a backup of your installation.


The Procedure
  1. Mount the partition containing the backup or the original installation. I will assume it is on /dev/sdb1. Again, for conformity, create a directory named sdb1 under /mnt.

    Code: Select all

    mkdir /mnt/sdb1

    Code: Select all

    mount /dev/sdb1 /mnt/sdb1
  2. Do the preceding step for the destination partition, let us say, /dev/sda2.

    Code: Select all

    mkdir /mnt/sda2

    Code: Select all

    mount /dev/sda2 /mnt/sda2
  3. Do the actual transfer. Some people use rsync, which is OK, however cp -a can do it implying there is no need of rsync for this procedure.

    Code: Select all

    cp -a /mnt/sdb1/* /mnt/sda2/
    This will take some time as it will copy an entire installation.
  4. Unmount the original partition i.e. sdb1.

    Code: Select all

    umount /mnt/sdb1
  5. With the destination partition still mounted, browse its newly copied file hierarchy to open /etc/fstab. Please note that this file needs root rights to be overwritten. In my case, I use vim, but you can choose any tool that can run with root privileges.

    Code: Select all

    vim /mnt/sda2/etc/fstab
  6. Find the line for the '/' directory. On this partitcular installation, it is:

    Code: Select all

    # / was on /dev/sda2 during installation
    UUID=e56156fe-5848-1254-bf93-7132a1e54321   /   ext4    errors=remount-ro      0       1
  7. Use the blkid command as root to determine the UUID of sda2, the destination. Copy it instead of the UUID shown in vim or your text editor. Save and exit.
  8. Update grub-pc to update its menu items.
  9. Unmount the partition.

    Code: Select all

    Umount /mnt/sda2

Note:
If an installation is spanned over several partitions, the copy procedure has to be done for every partition in the installation being transferred. A multi-partition installation can also be transferred to a lesser number of partitions, provided, care is taken to copy the contents of every dropped mapped partition to their respective root folder, say /var, /home, /usr, etc.
Debian == { > 30, 000 packages }; Debian != systemd
The worst infection of all, is a false sense of security!
It is hard to get away from CLI tools.

Post Reply