[solved] Merging Partitions from 2 disk into 1

Topics about disk partitioning (fdisk, parted, gparted, partimage), Volumes Management (lvm, evms, dmraid), Storage, file systems, ...
Post Reply
nicknack
Posts: 7
Joined: 27 Feb 2011, 17:46

[solved] Merging Partitions from 2 disk into 1

Post by nicknack » 27 Feb 2011, 18:04

Currently, I have these partitions mounted like the following :
/ --> /dev/sdb1
/usr --> /dev/sdb2

/home --> /dev/sdc1
/var --> /dev/sdc2

sdb & sdc = SCSI disk,
and i got 1 SATA connected as backup.

( it was sda & sdb btw, but since i updated `linux-base`, they changed to sdb & sdc,
( sda was taken by the SATA disk )

Is it possible to create backup of sda & sdb partitions and make them as one disk in sda ?
so sda ( as backup SATA disk ) hold all four partitions ?

I know it will requires minor changes to /etc/fstab in sda after restore, and tunning all
those mount --bind of proc,sys,dev, etc then reinstall grub.
Also, would dumping sfdisk of part. table needed with partimage ?

Thanks in advance !
Last edited by nicknack on 01 Mar 2011, 02:37, edited 2 times in total.

gernot
Posts: 1131
Joined: 07 Apr 2010, 16:19

Re: Merging Partitions from 2 disk into 1

Post by gernot » 27 Feb 2011, 19:59

Yes its possible, but its a bit manual work.

first make the Targetpartition on sda using gparted , cfdisk or fdisk and activate the bootflag.
Make sure the kernel reread the Partitiontable (reboot or sdfisk -R /dev/sda)
Use mkfs.xxxx to make the filesystem you want on /dev/sda1 if you not used gparted.

#mount the targetpartition
mkdir /mnt/target
mount /dev/sda1 /mnt/target

#mount the complete sourcetree
mkdir /mnt/sroot
mount /dev/sdb1 /mnt/sroot
mount /dev/sdb2 /mnt/sroot/usr
mount /dev/sdc1 /mnt/sroot/home
mount /dev/sdc2 /mnt/sroot/var

#cd sourcetree, find all files and copy them to the target
cd /mnt/sroot
find . |cpio -p /mnt/target

Now edit /mnt/target/etc/fstab
Then you need to install the Bootloader.

In case of grub:

grub-install --root-directory /mnt/target /dev/sda
If that fail boot the new system using supergrubdisk and reinstall the bootloader from the running system

nicknack
Posts: 7
Joined: 27 Feb 2011, 17:46

Re: Merging Partitions from 2 disk into 1 ( with partimage )

Post by nicknack » 28 Feb 2011, 02:25

hi gernot, thanks for the reply,
in this case, I already have these four partitions in image file created with partimage.
( Sorry for not being clear in my previous post ).

So now I got 4 image files from these 4 partitions from different drive.
Can i just dump them all in to this one SATA disk ?

gernot
Posts: 1131
Joined: 07 Apr 2010, 16:19

Re: Merging Partitions from 2 disk into 1 ( with partimage )

Post by gernot » 28 Feb 2011, 04:52

If you want the 4 partitions on one drive like tey are use a partitioneditor and create 4 partitions big enough to hold the images.
Then use partimage. You can use parted or gparted to fit the partitionsize exact after restoring.

Its not possible to merge partimagefiles.
If you want one big partition the only option is to extract root first, grow it using gparted but keep space to extract the next image.
Extract the next imagefile to this space.
Then copy the Files to root, extracht the next partimage...

Gernot

nicknack
Posts: 7
Joined: 27 Feb 2011, 17:46

Re: Merging Partitions from 2 disk into 1 ( with partimage )

Post by nicknack » 28 Feb 2011, 05:39

Yes I want to dump them in 1 disk.. but keep them in separated partitions, so 1 disk still have 4 partitions.

I have the idea of using gparted too, but rite now the situation is like this :

Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 9.2G 1.2G 7.6G 13% /
/dev/sdb2 19G 2.0G 16G 12% /usr
/dev/sdc1 19G 9.5G 8.0G 55% /home
/dev/sdc2 16G 4.1G 11G 29% /var

So
Total allocated partition size = 60+ GB
Total Used size = 17+ GB
All 2 SCSI drive physical size = 120 GB
( sdb = SCSI0 = 80GB and sdc = SCSI1 = 40 GB )

If i want to dump all 4 partitions to 1 Disk with partimage, and KEEP the 4 separated partitions,
Do I have to use 1 Disk that has the same physical size combined ( 120 GB ),
Or I can just use one 80 GB Disk ?

excuse for my slow digestion of the concepts :D

gernot
Posts: 1131
Joined: 07 Apr 2010, 16:19

Re: Merging Partitions from 2 disk into 1 ( with partimage )

Post by gernot » 28 Feb 2011, 15:18

80GB is ok.
Just make a primy partition with 10GB for /dev/sdb1
Make a extended partition /dev/sda2 with the remaining space.
Then add logical drives with 20, 20 and 17 GB.

Restore the 4 partitions to sda1 ,sda5,6 and 7.
Use gparted to fit the Filesystems to the partitionsize and activate boot for /dev/sda1

Gernot

nicknack
Posts: 7
Joined: 27 Feb 2011, 17:46

Re: Merging Partitions from 2 disk into 1 ( with partimage )

Post by nicknack » 01 Mar 2011, 02:35

That explains everything now :D

Thank you very much Sir !

Post Reply