LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-10-2005, 05:16 PM   #1
astrowill
Member
 
Registered: Aug 2003
Posts: 32

Rep: Reputation: 15
cloning logical volume with dd


I'm aware that I can clone my hard drive using 'dd if=/dev/hda of=/dev/hdb.' However, my system (FC3) is set up with a logical volume, like this:

/dev/mapper/VolGroup00-LogVol00 -- 146G 32G 108G 23% /
/dev/hda1 -- 99M 31M 64M 33% /boot
none -- 252M 0 252M 0% /dev/shm

So how can I clone this drive? Any help would be greatly appreciated.
 
Old 07-10-2005, 10:18 PM   #2
uberNUT69
Member
 
Registered: Jan 2005
Location: Tasmania
Distribution: Xen Debian Lenny/Sid
Posts: 578

Rep: Reputation: 30
You can use exactly the same method.
dd if=/dev/VolGroup00/LogVol00 of=...etc
or
dd if=/dev/mapper/VolGroup00-LogVol00 of=...etc

However, if this is a running system, you might like to investigate one of the fantastic features of LVM == snapshotting!
You need a bit of empty space in the volume group. (If there's none free at the moment you need to resize the logical volume AND the filesystem using a rescue/live cd).
The you just do something like:
#lvcreate -s -L 64M -n LogVol00-snapshot /dev/VolGroup00/LogVol00
(as the snapshot is 'copy-on-write' the -L size needs only be as big as the changes that occur while using the snapshot ... plus a bit )
This creates a snapshot at /dev/VolGroup00/LogVol00-snapshot that looks the same size as the original.
Then you can use your dd method for imaging.
To remove after:
#lvremove /dev/VolGroup00/LogVol00-snapshot
 
Old 07-11-2005, 12:03 AM   #3
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151

Rep: Reputation: 46
astrowill: You can clone a drive with LVMs the same way as you usually do (e.g., dd if=/dev/hda of=/dev/hdb bs=64M).

The only catch comes after you have finished cloning and want to look at your handiwork. Since the LMV identifiers are identical on both drives, you will get error messages when you attempt to activate, scan for or access the logical volumes on either disk and will only be able to access one disk. If you really just want to clone the disk for use in another system, that isn't a big deal, since you will only be running one disk at a time.

If you are trying to make something like a backup, then what uberNUT69 is suggesting is one way to do it. The other way is to create a new volume group and logical volume(s) on the second drive using a different volume group name, and to dd somewhat like you are suggesting:

dd if=/dev/VG00/LV00 of=/dev/VG01/LV00 bs=64M

And as long as the underlying filesystems are the same size, you can even copy a logical volume to a traditional partitions. When you select a partition or a logical volume to copy from/to, you are really just coping the contents of the partition (i.e., the filesystem), unlike when you copy one entire drive to another.
 
Old 07-13-2005, 09:59 AM   #4
astrowill
Member
 
Registered: Aug 2003
Posts: 32

Original Poster
Rep: Reputation: 15
Thanks very much for the replies. What I'd like to do is clone my drive before it goes bad (hypothetically) so I'd need to include /boot and the swap partition as well. How can I copy the whole thing?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to reduce logical volume LinuxLover Linux - Enterprise 2 10-29-2005 08:26 AM
swapping on a logical volume garba Linux - General 1 06-28-2005 06:36 PM
resizing a logical volume nicentral AIX 2 06-11-2005 04:03 PM
cloning both partitions, dual boot system, master boot record, logical volume manager saranga2000 Linux - Hardware 3 01-10-2005 11:04 AM
Logical Volume Manager sidmark-2850 Linux - General 3 01-02-2004 01:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration