Computing.Net > Forums > Linux > To clone a partition

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

To clone a partition

Reply to Message Icon

Name: satimis
Date: October 11, 2005 at 05:10:09 Pacific
OS: FC3
CPU/Ram: Athlon1.4/512MB
Comment:

Hi folks,

On a FC3 box it has following partitions;

FC3
/root on /dev/hda5
/swap on /dev/hda3
/home on /dev/hda5

BLFS
/root on /dev/hda6 (size=5G only taking up 1.5G)
/swap sharring with FC3 on /dev/hda3

/dev/hda7 with ext3 not occupied (size=2G)

Now I want to duplicate another BLFS on /dev/hda7

To my knowledge following command
dd if=/dev/hda6 of=/dev/hda7 bs=4096 conv=notrunc,noerror

only works on equal size partitions. I have been searching on Internet to confirm it without result. Please advise. TIA

If the abovementioned command does not work then can I apply following method to clone /dev/hda6 on /dev/hda7 ???

1) Boot up FC3
2) # dd if=/dev/hda6 of=/home/myimage.img
(can I use /home for keeping myimage.img? It has sufficient spare space)
3) # dd if=myimage.img of=/dev/hda7
4) Modify the Bootloader (grub) of the FC3 as follow;

/boot/grub/menu.lst
title Fedora Core (2.6.12-1.1378_FC3)
root (hd0,0)
kernel /vmlinuz-2.6.12-1.1378_FC3 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.12-1.1378_FC3.img
title Fedora Core (2.6.12-1.1376_FC3)
root (hd0,0)
kernel /vmlinuz-2.6.12-1.1376_FC3 ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.12-1.1376_FC3.img
title LFS 6.1 (2.6.11.12)
root (hd0,5)
kernel /boot/lfskernel-2.6.11.12 ro root=/dev/hda6 vga=795
title LFS 6.1 (2.6.11.12-sound)
root (hd0,5)
kernel /boot/bzImage-2.6.11.12-sound ro root=/dev/hda6 vga=795

adding: -
title LFS 6.1 (for LiveCD) (2.6.11.12-sound)
root (hd0,6)
kernel /boot/bzImage-2.6.11.12-sound ro root=/dev/hda7 vga=795

OR are there any better methods? TIA

BR
satimis




Sponsored Link
Ads by Google

Response Number 1
Name: linux-amateur
Date: October 12, 2005 at 04:16:22 Pacific
Reply:

Be Careful: The option “notrunc” seems to order all 5G to be continued after the end of 2G. I thought I was the onlyone doing such mistakes.

You are copying a full 5G into a 2G-partition. If you add e.g. count=480000, only the first 480000x4096 bytes will be copied, i.e less than 2G. But DD does not choose the important blocks, so you must be certain that all important data is included in the copied part of hda6. But “notrunc” seems to be inconsistent with “count=”.

The simple way is, of course, to tarball all folders and files and untar them into the new partition, with careful options, so the pointer-files are “tarred” correctly as they are. You might lose some irreal files like socks, but it has not been any problem for me (as far as I know) .

Linux-Amateur


0

Response Number 2
Name: Dlonra
Date: October 12, 2005 at 06:15:42 Pacific
Reply:

Assuming /dev/hda7 is mounted on /mnt/hda7

cd /

find root -depth -xdev|cpio -pdvm /mnt/hda7

this copies everyhing except symolically linked directories.



0

Response Number 3
Name: satimis
Date: October 12, 2005 at 16:48:00 Pacific
Reply:

Hi folks,

Tks for your advice.

I need to duplicate the complete OS (BLFS) on /dev/hda7 making it working there.


Linux Amateur,
Can following tar command work for me?
tar -C / -lcpvf- | tar -C /mnt/livecd -xf -
are the flags correct? /mnt/livecd=/dev/hda7

dlonra (by Dlonra)
To include copying all symolically linked directories, which additional flags should be up as well. Otherwise it won't be a working OS on /dev/hda7

TIA

B.R.
satimis



0

Response Number 4
Name: linux-amateur
Date: October 13, 2005 at 12:46:20 Pacific
Reply:

You must boot in the FC3 system. In the FC3-system you must mount both involved partitions
e.g. as /tmp/hda6 and /tmp/hda7

I suppose FC:s GUI – partitionmanager can do this,

otherwise: mkdir /tmp/hda6
mount /dev/hda6 /tmp/hda6
mkdir /tmp/hda7
mount [-t ext3] /dev/hda7 /tmp/hda7

As root:
copy all of the topfolders /bin, /boot, /dev, /etc, /home....... from BLFS to the new partition hda7.

In order to copy the /home folder, for example:

move yourself into the BLFS-root
tarball the /home folder (dont worry about the warning of missing “/” )
move the tarball to the new partition
move yourself into the new partitions root-
folder (so you get back the missing “/” )
untar the tarball

that is: cd /tmp/hda6
tar -cf home.tar home
mv home.tar /tmp/hda7
cd /tmp/hda7
tar -xf home.tar

and the same for the other folders.

With this method you have control over each step. But it can certainly be done more elegantly.


Linux-Amateur


0

Response Number 5
Name: Dlonra
Date: October 13, 2005 at 18:18:40 Pacific
Reply:

my description on symbolically linked directories was misleading -
the links are copied, but the contents are not- in almost all cases, this is what you want when you do a partition copy.

check the copied /etc/fstab for explicit references to /dev/hda5. If present, change to hda7. Also check that swap is where you want it.



0

Related Posts

See More



Response Number 6
Name: linux-amateur
Date: October 14, 2005 at 07:21:13 Pacific
Reply:

Question to Dlonra

Am I right to assume, that your commands are run from the system that is copied ? (in this case BLFS)

Does your elegant solution move all sockets ?

My solution drops the empty sockets, and I have a nagging feeling that I might get future problems, although it seems to work without them.


Linux-Amateur


0

Response Number 7
Name: satimis
Date: October 17, 2005 at 07:03:05 Pacific
Reply:

Hi linux-amateur,

Tks for your detail advice.

> I suppose FC:s GUI – partitionmanager can do
> this,

# yum search "GUI - partitionmanager"
# yum search "GUI partitionmanager"
# yum search partitionmanager
could not find it.

After mounting both /dev/hda6 and /dev/hda7 starting Konqueror can do the job with drag-and-drop action.

Why it is necessary to tar /home of /dev/hda6 (BLFS)? Copy the rest directories straight to /dev/hda7 without compressing them? What will be the advantage of this arrangement.

B.R.
satimis


0

Response Number 8
Name: satimis
Date: October 17, 2005 at 07:12:47 Pacific
Reply:

Hi dlonra,

Your further advice noted with thanks.

> the links are copied, but the contents are
> not- in almost all cases, this is what you
> want when you do a partition copy.

Please explain what does it mean "but the contents are not- in almost all cases".

TIA

B.R
satimis



0

Response Number 9
Name: linux-amateur
Date: October 17, 2005 at 10:21:17 Pacific
Reply:

I worked from outside the moving rootpartition, because it was necessary in MS-windows. I don't know if it is needed in Linux, but it is less trouble than finding out if it is needed.

I copied tarballs instead of the directories directly, to avoid that some files might get copied in place of their links, including the mounted DVD-rom.

But the superior method is the one suggested by Dlora. I tried Dlora's method this morning and it seemed to give a perfect copy. But it has a writing error. You must write the “/” (slash) (or the full address of the mounted source-partition), instead of the word “root”. Otherways you only get the /root directory copied.

Many thanks to Dlora, and to you. This has been most valuable for me also.

Linux-Amateur


0

Response Number 10
Name: linux-amateur
Date: October 17, 2005 at 11:55:29 Pacific
Reply:

Don´t forget to edit your /mnt/livecd/etc/fstab before logging out after the copying.

The /dev/hda5 (or /dev/hda6 ), on the line of the rootpartition, must of course be changed to /dev/hda7.

P.S. I write this, having logged into the trial-partition that I copied this morning. I had some minor problems because I had been sloppy with the fstab, but now it works exactly as the original.

Linux-Amateur


0

Response Number 11
Name: satimis
Date: October 18, 2005 at 19:17:34 Pacific
Reply:

Hi Linux-Amateur,

> You must write the “/” (slash) (or the full
> address of the mounted source-partition)

You meant the command line should read;

# find / -depth -xdev|cpio -pdvm /mnt/hda7

???

Others noted with tks.

BR
satimis


0

Response Number 12
Name: linux-amateur
Date: October 19, 2005 at 11:41:41 Pacific
Reply:

Yes

In the /etc/fstab:
If you change the line of the rootpartition from /dev/hda6 to /dev/hda7, you also need to remove or change the line with the /mnt/hda7 ( or /mnt/livecd.)

If the KDE gets crazy, or if it refuses to mount your home-partition, it is probably due to the fstab-file.

Linux-Amateur


0

Response Number 13
Name: satimis
Date: October 20, 2005 at 00:31:41 Pacific
Reply:

Hi linux-amateur,

Your advice noted with tks.

BR
satimis


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: To clone a partition

how to use script to clone linux system www.computing.net/answers/linux/how-to-use-script-to-clone-linux-system-/6356.html

Is a partition recommended for RH 7.1? www.computing.net/answers/linux/is-a-partition-recommended-for-rh-71-/3937.html

How to rename a filesystem www.computing.net/answers/linux/how-to-rename-a-filesystem/29473.html