LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Can a Linux OS be copied or moved from one partition to another ? (https://www.linuxquestions.org/questions/linux-general-1/can-a-linux-os-be-copied-or-moved-from-one-partition-to-another-570136/)

brjoon1021 07-17-2007 12:38 PM

Can a Linux OS be copied or moved from one partition to another ?
 
Hi,

I would like to move a couple of working Linuxes, namely Mandriva and OpenSUSE to partitions other than the the ones that they reside on now. Mandriva and SUSE have all parts (/home,/var ,etc...) of the OS within the partitions in which they are now installed except that the swap is on another partion of another disk for speed.

1. I would like to know if I can move or copy the OS to an existing partition on a different hard drive without destroying the OS. Also, how to do it, if it can be done...

2. The disks are partitioned on this computer. My purpose is to move all of the /mnt partitions for the Linuxes to one disk and all of the /home to another disk and shared swap to a third disk so that I can open up the last disk just for storage as a FAT32 for Windows and Linuxes.

Once I have moved the Mandriva, Suse and possible other Linuxes, I will want to make several smaller partitions out of three larger ones that I have now.
- a. Can I delete partitions AFTER the last partition on a disk that has an OS on it without wrecking the OS's on the first partitions of the disk ? For example, let's say I have Mandriva and Suse on hda1 and hda2, and hda3, 4, 5, 6 are vacant ext3 partitions. I would like to make 9 smaller ext3 partitons out these larger ones. I am concerned about whether that will have an effect on the OS's on the first two partitions. I don't think that this will mess up SUSE and Mandriva. Do you know ?


Thanks,

B.

slackbat 07-17-2007 01:34 PM

Hi brjoon1021

Quote:

1. I would like to know if I can move or copy the OS to an existing partition on a different hard drive without destroying the OS. Also, how to do it, if it can be done...
Yes. Once moved you need to alter /etc/fstab and /etc/mtab to reflect the different partition numbers. I tend to use partimage to backup the partitions to a spare partition before placing onto the new partitions - again using partimage for this. You will probably need a live cd such as knoppix to alter fstab and mtab to reflect the difference. cfdisk is good for creating the partitons.

Quote:

I am concerned about whether that will have an effect on the OS's on the first two partitions. I don't think that this will mess up SUSE and Mandriva. Do you know ?
If those last partitions you mention are indeed vacant and unused, there should be no problem. But it might be an idea to edit /etc/fstab - if the partitions are listed at all - and remove/comment their entries.

Good luck

saikee 07-17-2007 01:35 PM

The answer is yes but probably not the way you have in mind.

General steps are, say you have a Linux in sda7 and want to move it to sdc2

Boot up a Linux not related to the one you want to migrate, in terminal

Code:

mke2fs /dev/sdc2
mkdir /mnt/sdc2
mount /dev/sdc2 /mnt/sdc2
mount /dev/sda7 /mnt/sda7
cd /mnt/sda7
tar cf - . | (cd /mnt/sdc2; tar xf -)

go into /mnt/sdc2 and change
(1) boot loader reference from sda7 to sdc2
(2) /etc/fstab same alteration
(3) Restore the boot loader (only if you boot by chainloading)

All Linux should use a common swap.

/mnt cannot be shared.

Sharing a /home between Linux may upset the desktop setting.

Yes you can move Linux around. I do it all the time.

michaelk 07-17-2007 01:38 PM

BTW the mtab file is automatically updated by the mount command, one should never need to manually edit this file.

theYinYeti 07-17-2007 02:18 PM

I did such a thing recently. This CD was a big help:
http://www.sysresccd.org/

Yves.

ComputerBob 07-17-2007 02:21 PM

Quote:

Originally Posted by michaelk
BTW the mtab file is automatically updated by the mount command, one should never need to manually edit this file.

Whew! That's a relief! As I read through this thread, I thought to myself, "Uh-oh -- I've edited /etc/fstab many times in the past year, but I've never even looked at /etc/mtab."

When I read your post, I finally realized why that is. :D


All times are GMT -5. The time now is 08:51 AM.