Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy all contents of the logical volume

Status
Not open for further replies.

Janghyegyung

Technical User
Aug 20, 2001
42
0
0
KR
I'd like to copy all the contents(files) of one logical volume to another one. For example, I have a logical volume /oldlv now, this is mounted filesystem, /oldfs, and I want to make a new logical volume, /newlv and to mount this to new filesystem /newfs. I hope this new filesystem, /newfs, has all the files that /oldlv(/oldfs) has already.

I can use command, cplv.. By this command can I do what I want? If I can, and next, what shall I gonna do?

Thanks in advance.
 
hiho,

i would create the newlv and mount it at /newfs, then

cd /oldfs
find . -print|cpio -dumpv /newfs

fertig. you can now unmount /oldfs and delete it and its lv, if you want to.
all files and dirs in the /newfs will have same permissions and timestamp as their originals. works perfect, i use it often to copy big diretories recursive with all it's contents.
 
Because you will lose all your links. In the destiny directory there will be no links, but files, just tried it.
I don't know how cp -pr behaves when copying special files like character/block device files, maybe you can get serius problems.

root@hvxxs99:/home/reusch/test/1> ll
total 3
drwxr-xr-x 3 root system 512 Nov 14 12:45 .
drwxr-xr-x 4 root system 512 Nov 14 12:45 ..
-rw-r--r-- 1 root system 0 Nov 14 12:45 lala
lrwxrwxrwx 1 root system 6 Nov 14 12:45 link -> ./lala
drwxr-xr-x 2 root system 512 Nov 14 12:45 ugug
root@hvxxs99:/home/reusch/test/1> echo auwhdiauwhdiawuhdawd >> lala
root@hvxxs99:/home/reusch/test/1> ll
total 4
drwxr-xr-x 3 root system 512 Nov 14 12:45 .
drwxr-xr-x 4 root system 512 Nov 14 12:45 ..
-rw-r--r-- 1 root system 21 Nov 14 12:45 lala
lrwxrwxrwx 1 root system 6 Nov 14 12:45 link -> ./lala
drwxr-xr-x 2 root system 512 Nov 14 12:45 ugug
root@hvxxs99:/home/reusch/test/1> cp -pr * ../2
root@hvxxs99:/home/reusch/test/1> ll ../2
total 5
drwxr-xr-x 3 root system 512 Nov 14 12:45 .
drwxr-xr-x 4 root system 512 Nov 14 12:45 ..
-rw-r--r-- 1 root system 21 Nov 14 12:45 lala
-rw-r--r-- 1 root system 21 Nov 14 12:45 link
drwxr-xr-x 2 root system 512 Nov 14 12:45 ugug
 
cplv is the best method by which you can move the lv even to a different volume group.But you need your filesystem unmounted. Then create a lv of the same size. Then change type to copy then use cplv command to copy it.Then modify the /etc/filesystems to tell where you want to mount.

For example your new lv name is newlv
then

chlv -t copy newlv
cplv -e newlv oldlv
then modify /etc/filesystems. It works without any problem
 
I regulary use cplv to copy to a new logical volume. You also don't have to have an existing logical volume because it will be created if it doesn't currently exist.

One other thing after doing the cplv is to do a `logform` to initialize a new log device for the new logical volume on the volume group. Also the standard is 4MB for 2GB of data for a log. This is something I need to do on my nodes and keep pushing it aside but it would increase performance by keeping to the correct size.
 
What zaxxon was saying about using the "cp" command is true. Using cp to copy a complete directory structure can (sometimes) be very dangerous (taking some time to realise what a bad idea this was).
Using "cplv" is very quick but...
If you have the new FS and the old FS mounted at the same time, then I prefer to use "cpio" as demonstrated by zaxxon (assuming that you have no files > 2GB).
Using cpio (dumpv or pdumv, whatever) will preserve ownerships, permissions etc AND will do a very tidy reconstruction (better that defrag) of the filesystem.
Just an opinion...
 
if you use cp -Rph /oldfs /newfs it will work fine since the h option will copy the symbolic links across. It is the method I always use.

Dave
 
These are the steps I follow for copying logical volumes:

Step 1: umount [filesystem]

Step 2: cp [oldLV] [newLV]
cplv –v VG(destination) –y [newLV] [sourceLV]

Step 3: chfs to recognize [newLV]
chfs –a dev=/dev/[newLV] –a log=/dev/[logdev] /[filesystem]

Step 4: fsck –p /dev/[newLV]

Step 5: mount [filesystem]

Step 6: rm [oldLV]
rmlv [oldLV]


Then the last step is a `logform`
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top