Traditionally, linux systems were installed on disks which usually were partitioned. That is good sometimes, but not always. So, the Linux Volume Manager (LVM) vas created, to overcome the limitations of the traditional partitioned disk usage. Some of the limitations are: inability to mirror or span volumes, a maximum number of partitions which sometimes may be too small. LVM has many advantages, such as ability to create a volume spanning many disk drives, ability to grow a voluume, ability to add more disks to the volume group. But it has a big disadvantage: there aren't too many replication/cloning tools available.The major drawback of LVM is that it doesn't contain a filesystem, but logical volumes and each logical volume may be split across multiple phisical volumes. This is the main reason why cloning applications such as Ghost, Clonezilla or Acronis TrueImage do not copy data stored on LVM as a filesystem, but as a raw data. This process may be much slower than copying a filesystem.
Cloning tools must also be capable of understanding a specific filesystem to copy it. While NTFS, reiserfs, ext2 and ext3 are popular and supported by many cloning tools, ext4 is relatively new and at the time when I wrote this, the only tool able to clone ext4 filesystems is Clonezilla. Other tools may clone an ext4 filesystem, but using the raw copy method.
CentOS is a popular linux distribution, which by default uses LVM for storage devices.If someone wants to make a copy of the disk where the operating system is installed, it must use a disk equal to or larger than the one where the operating system is installed. Also, if the LVM configuration includes multiple disks, the cloning task is no longer an option, and other methods must be used. One of them is to use LVM's mirroring mechanism, but this require strong knowledge of LVM and it's utilities. If the storage requirements are modest, migrating from LVM to the traditional partitioning scheme is a possible option.
This is the scenario below: I have a CentOS Linux 6 installed with default options, and then I migrate it to a partitioning scheme using custom sizes for the partitions and using ext3 filesystem instead of the default ext4. I want to create a supplemental /data partition, where I will store miscellaneous files. At this time, ext4 is not supported by as many tools as ext3.
After installation, I have:
A very important aspect regading /etc/fstab: the volume containing the root filesystem and the swap are referenced by their logical volume name, the boot partition is referenced by it's UUID. Why is this important: on a running system is impossible to have accessible at a specific time two different volumes with a specific volume group name and the same volume name. So, an exact replica of the LVM configuration from one disk to another can't be done on a single system while both disks are accessible. Copying LVM is possible with tools like modorescue, but the entire LVM configuration and data must be migrated from the local LVM to a remote machine or to an intermediate storage medium.
And for the boot loader
The boot loader configuration references the root file system location, which is provided as a kernel parameter. rd_LVM_LV, a kernel parameter which instructs LVM to initialize only the volume names referenced by rd_LVM_LV kernel parameters.
The migration from LVM to partitions procedure isn't quite simple. The target disk must be initialized, partitioned ahd the filesystems and swap partitions to be formatted, the data must be copied from LVM to partitions. A boot loader must be installed on the target, the boot loader configuration must be adjusted. As well, the /etc/fstab contents must be modified according to the new coordinates of the filesystems. an important thing which must not be forgot: on systems running with SeLinux enabled, after copying the data, an automatic relabel must be triggered for the next boot. Otherwise, the system may refuse to boot properly.
Now, in the shell prompt, the first task is to identify the drives. The /mnt/sysimage is mounted with the detected linux installation. The new disk should have an empty partition table. Now it's time to create the partition layout on the target disk. cfdisk is a very nice tool for this purpose.
I used the following layout:
After partitioning, the filesystems must be formatted. I also added labels to the filesystems, so they could be mounted later using the label.
Now it's time to copy the data to the new filesystems:
And it's good to adjust the file modes for some entries:
The data from the old system is located on /mnt/sysimage. Copy the data located on the new mount points:
And the data located on the root filesystem too, but exclude the contents of the special directories /dev, /proc, /selinux and /sys:
Handle the /proc, /dev and /sys:
To make the target disk bootable, it's time to install the grub boot loader on it:
Because on the target disk LVM will not be required to boot, the kernel command line no longer requires the parameters rd_LVM_LV and these can be removed and replaced by rd_NO_LVM. Also, pass on the command line the proper value for 'root=' parameter:
The new /boot/grub/brub.conf file now looks like:
The contents of /etc/fstab from the target disk must be modified too:
And finally, exit the chroot and schedule a complete filesystem selinux relabel, otherwise the new installation won't be bootable:
Now it's time to power off the system, unplug the old disk, power on and boot from the new disk. On the first boot it will take a time for relabel to complete and it may require a reboot. After that, your new partitioned CentOS 6 system will be clonable and resizable with standard imaging tools.
How to >