[Durham] copying files from drive to drive

Richard Mortimer richm at oldelvet.org.uk
Thu Jul 19 16:12:03 UTC 2012



On 19/07/2012 16:42, Andrew Glass wrote:
> Hey
>
> Could you help me please?
>
> Im in the process of building an LVM store however I need to copy every folder from a normal ext4 drive to the LV.  What would you say would be the best way to do this?  Never done it before.

First off make sure that you don't overwrite the old drive. Double check 
your commandlines before you press return!

Method 1
--------

If you know that your new LVM is bigger than the original then you can 
do a full low-level copy of the filesystem.

sudo dd if=/dev/sdorig1 of=/dev/sdnew1 bs=16M

replace sdorig1 with the name of your old partition i.e. sda1
and sdnew1 with the new one i.e. /dev/mapper/blah-newdrive

Once you have copied the whole lot across then use resize2fs (maybe with 
an fsck before you start) to ensure that the disk fills the whole partition.

sudo resize2fs /dev/mapper/blah-newdrive


Method 2
--------

Using rsync at a file by file level.

First off mount both old and new filesystems.

With this method you can mount the old filesystem readonly to stop it 
being mistakenly changed.

Then use

sudo rsync -vau /mnt/oldfs /mnt/newfs

That will copy things across file by file. You can repeat the command as 
often as you like and it will only copy changed files.

Richard




>
> Cheers
>
> Andy
> _______________________________________________
> Durham mailing list   -   Durham at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/durham
> http://www.nelug.org.uk/
>



More information about the Durham mailing list