Migrating and Moving Unix Filesystems

July 09, 2006
My hard disk fills up at a rapid pace. When that happens, I usually create more space by deleting unwanted / less important files & folders from the hard disk. But for me, this is a problem I have to grapple on a regular basis.

Lots of knowledgeable people prefer using Logical Volumes over traditional partitions to store their data for this very reason. Using logical volumes, it is quite easy to shrink or grow a volume by adding or removing devices from the volume using the LVM tools commonly found in all main stream Linux distributions.

Using LVM will ensure that you can change the size of your volume on the fly without any data loss.

If you want to know more about LVM, do read the time saving guides - How to create an LVM, and How to resize an LVM.


Moving on, it is possible to migrate data from the filled up partition to other partitions on the same disk or an entirely different disk all together but there is a method to the madness.

Martin Brown explains how you can move your data (entire directory structure) from one partition to another. The reasons for doing so could be as mundane as making some space in the partition, to something hoary like side stepping an impending fault in the device containing the data.

The process of moving date can be done in a system running in single user mode, or a live and running system where you need to ensure that the files are available during the move.

And he lists out 8 steps to accomplish the task at hand. They are as follows:

  • Choose the data to be copied
  • Create a new partition
  • Create a new file system on the partition
  • Mount the partition on a temporary directory
  • Copy the data to the temporary directory
  • Rename the original directory
  • Create the new mount point. And finally ...
  • Mount the file system.

Read the article.

1 comments:

  • Ravi

    Moses,
    It is not Logical volumes job to modify the underlying partitions in any way. What happens in LVM is that a layer is created on top of partitions and on top of this layer the file system is created. So if the space in the LVM is fast filling up, you just have to add another partition or a partition on a seperate disk to the logical volume group and you automatically have additional space.

    As far as filesystems is concerned, AFAIK, you have to shrink or enlarge the filesystem using the resize2fs tool manually.