LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   possible to switch 2 ext3 partitions between them? (https://www.linuxquestions.org/questions/linux-general-1/possible-to-switch-2-ext3-partitions-between-them-484264/)

blas 09-17-2006 01:44 AM

possible to switch 2 ext3 partitions between them?
 
Hi

Is it possible to switch 2 linux ext3 partitions between them? this is the scenario:

I have 4 partitions on a disk:

Code:

[root@vaiogpg ~]# fdisk -l

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1        2550    20482843+  83  Linux
/dev/sda2            2551        4375    14659312+  83  Linux
/dev/sda3            4376        9482    41021977+  83  Linux
/dev/sda4            9483        9729    1984027+  82  Linux swap / Solaris

I have FC5 installed on /dev/sda1 (20Gb), nothing on /dev/sda2 (15Gb) and some data on /dev/sda3 (40Gb). Now I'd like to change /dev/sda1 to became /dev/sda2 (and /dev/sda2 became /dev/sda1), this way I'll have FC5 installed on /dev/sda2 and /dev/sda1 should be blank.

What I want to do is to keep every data and config on my currently running FC5 but moved to /dev/sda2 (even if I can recreate both partitions to set the correct sizes as they are different (/dev/sda1 should have 15Gb and /dev/sda2 should have 20Gb)). Of course I have to be able to boot FC5 (now in /dev/sda2) using a boot loader (grub).

Is this possible or do I have to reinstall the whole system? If possible, which is the best approach?

Some more info:

Code:

[root@vaiogpg ~]# cat /etc/fstab
LABEL=/1 / ext3 defaults 1 1
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
/dev/sda3 /varios ext3 defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
###LABEL=SWAP-sda4 swap swap defaults 0 0
/dev/sda4 swap swap defaults 0 0

Many thanks
Regards
Blas

fudam 09-17-2006 07:39 AM

Moving the data from sda1 to sda2 can be done using partimage or dd. With dd you have to ensure that you don't try to put more data onto the destination than it cat fit (so you should have less than 15GB of data to move on sda1).

Anecdotaly I have found that resizing ext3 partitions is similar to pulling teeth out of an angry rhino with chopsticks while you're drunk.

bigjohn 09-17-2006 07:42 AM

I suppose it's possible. I'd guess that you'd have to copy the entire contents of sda1 to sda2 and then make sda2 bootable. You'd have to change the mount points so that the system knows that it's got too boot the right partitions etc etc.

I should guess, that if you're not very familiar in doing stuff like that, then it'd be easier to re-install the system, but make sure that you tell the installer NOT to format any partition that you want to retain the data on. Then you should just be able to tell the installer that you want to have sda2 as the / partition with nothing done to sda's 3 and 4.

Note that the fstab you posted, doesn't have any mountpoint for sda2 anyway so it may be worth tidying up you partitions first, then trying to work out what it is that you want to do with them.

regards

john


All times are GMT -5. The time now is 11:23 AM.