Operating System - HP-UX
1844834 Members
4454 Online
110233 Solutions
New Discussion

dd with differnt size logical volumes

 
SOLVED
Go to solution
Michael Denney
Valued Contributor

dd with differnt size logical volumes

What would happen if you used dd to copy a logical volume containing a file system to another logical volume that is of larger size?

example:

/dev/vg50/lvol1 is 1gb with vxfs on lvol
/dev/vg50/lvol2 is 2gb empty

dd if=/dev/vg50/lvol1 of=/dev/vg50/lvol2 bs=1024k


I have not had a chance to test anything, but I'm thinking the filesystem would still be valid on lvol2 after the copy. However, 1gb of space would be wasted on lvol2. Would need to use fsadm -B to expand the file system to 2gb after the copy.

Will this work?


Thanks for replies!
5 REPLIES 5
James R. Ferguson
Acclaimed Contributor
Solution

Re: dd with differnt size logical volumes

Hi Michael:

I suspect that this would work, too, but why bother? From what you show, both logical volumes are on the same volume group and the larger one is empty.

Hence, use 'lvremove' to eliminate 'lvol2'. Follow that with an 'lvextend' of 'lvol1' and enlarge the filesystem contained therein with 'fsadm'.

I guarantee that this will be far faster than what you proposed.

Regards!

...JRF...

Bill Hassell
Honored Contributor

Re: dd with differnt size logical volumes

The filesystem only knows how big it was, regardless of how big the current lvol might be. The same thing would happen if you extended an lvol--the filesystem remains the same size. Once you copy the smaller lvol to a larger lvol, you should be able to mount it without any problem. It will show the same filesystem size as the original.

To avoid an fsck pass, always unmount the source volume and always use the raw volume (r in front of the name). Without the 'r', all the data will go through the buffer cache, a waste of space and CPU cycles. Something like this:

dd if=/dev/vg50/rlvol1 of=/dev/vg50/rlvol2 bs=1024k

Once the dd copy is finished, just run extendfs to tell the filesystem about the additional space, then mount the filesystem and you'll see the new size.


Bill Hassell, sysadmin
Sanjay_6
Honored Contributor

Re: dd with differnt size logical volumes

Hi,

The other LV if smaller than the source would become a smaller one. You would have to do a extendfs or a fsadm to increase its size.

In your example if you do a dd from lvol1 to lvol2, lvol2 would become a FS of 1GB after dd and you would need to do a fsadm / extendfs to increase its size back to 2GB.

Hope this helps.

regds
Michael Denney
Valued Contributor

Re: dd with differnt size logical volumes

James,

Thanks for pointing that out about logical volumes being in same volume group. I neglected to specify the logical volumes are in seperate volume groups, so I have to do some means of copy.

I am wanting to use dd instead of cp or cpio because of the large number of files in the source file system.

Thanks for responses all.
Michael Denney
Valued Contributor

Re: dd with differnt size logical volumes

Closed thread. Thanks.