This how-to will assist in migrating Linux filesystems build on partitions to filesystems built on logical volumes. To accomplish this, you will use SBAdmin's Adapatble System Recovery (ASR) features to alter the storage configuration of the system using Logical Volume Management (LVM) and restore the entire system onto this new configuration.
- Linux kernel levels 2.4 and above
- Linux LVM tools 0.9-rc4 and above
- SBAdmin Client/Server installed on the client system
- SBAdmin Network Edition with backup server and device configured
Migrate Linux storage using LVM
Determine Space Requirements
Often times, users want to migrate their storage because the system was originally installed on a single filesystem built onto a partition. In this how-to, we will also break up the root filesystem into multiple filesystems for greater flexibility and performance. This storage configuration also makes the system less vunerable to catastrophic failure.
To ensure we create each filesystem with enough space, we need to document how much space is being taken up.
# cd /
# du -sh *
This will list the amount of space used in each directory in the root filesystem. We are most concerned with /boot /usr /var /home and /opt. The remaining directories will be a part of the root filesystem. In your case, you might want to make the storage more or less granular.
To get the overall size of the root filesystem, use the df command. Then you can determine how much space you want to dedicate to each new filesystem. For this example we will use the following settings based on the space used.
Because the filesystems will be built on logical volumes, you will be able to extend the LVs and grow the filesystems as needed. This will provide more efficient use of your disk space and greater flexibility in case you want to create new filesystems or add additional disks.
Create the backup and boot media
This how-to assumes you already know how to create a backup job. If not, please see the SBAdmin Users Guide for more information.
- Create a backup using a full system backup type profile (ie. FULL_SYSTEM) to tape, remote server, or external disk.
- Create SBAdmin installation boot media. (For more information see the SBAdmin Linux System Recovery Guide)
Boot the system and select the backup
Power-on the system and press the key combination to enter the BIOS or a boot menu to select the device to boot your installation boot media. (CDROM, network adapter, external disk/USB drive)
Once the system is booted you will be presented with the Installation Menu
( Main Menu )
Select the installation device (may require network configuration) and select the backup to restore from. Once you have selected the backup, press F3 or ESC until you are back at the Main Menu.
Update the partition table information
From the Main Menu, select View/Change Installation Settings, and then Change Partition Tables
( Edit Partition Table )
Your configuration may differ, but in this case, there are two partitions. One partition is used for swap and the other partition is used for the root (/) filesystem. The partitions are taking up the entire space on the disk.
When we finish, we will have three partitions - /boot (sda1) swap (sda2) and the physical volume (PV) for the volume group (VG) (sda3).
- The first step is to add two additional partitions to be used by the /boot filesystem.
- Select Add New Partition and add one 54MB partition of type 83 at the beginning of the disk (sda1) and one 54MB at the end of the disk (sda5). This becomes sda5 due to the need for an extented partition. Don't worry, we will still end up with 3 partitions in the end.
- Select the partition currently being used for the root filesystem (sda3).
- Change the parition type from 83 (Linux) to 8e (Linux LVM) and reduce the size by 54MB.
- Press F3/ESC once to return back to the Change Installation Settings Menu. (You can ignore the errors you see regarding the disk space usage - for now)
- We need to move the root filesystem off of its current partition (sda3) and move it to the last partition (sda5).
SBAdmin has a safety precaution that prevents you from removing or repurposing the device the root filesystem is using. We need to move the root filesystem off to another partition temporarily before moving it to a logical volume. We will use the sda5 temporarily, then move it to a logical volume once we have created it.
- Select Add or Change Filesystems
- Select the root filesystem and change the "Device" to the last partition (sda5). Press F3/ESC to save the configuration.
- Select Add New and create a new /boot filesystem on the first partition (sda1). Press F3/ESC to save the configuration.
Now we are ready to set up our LVM environment.
Setup Logical Volume Management
- From the Change Installation Settings Menu, select Logical Volume Management
- Select Add or Remove Physical Volumes
- Use the up/down arrows and press [enter] to select the partition previously used by the root filesystem (sda3). Press F3/ESC once to return to the LVM menu.
- Select Add or Change Volume Groups, select Add New
( Create/Edit Volume Group )
- From this screen you configure your volume group. In this example we will use the name "rootvg". This is the name typically used on AIX and HP-UX systems. Press F3/ESC when finished. Also, we will use the physical volume sda3.
- Select Add or Change Logical Volumes, select Add New
( Create/Edit Logical Volumes )
- From this screen you configure your logical volumes. In this example, create the following logical volumes:
||Size in MB
It is a good idea to name the logical volumes similar to the fileysystems they will contain. For some reason Linux distributions like to name them lv01, lv02, etc. This is harder to keep track.
- Press F3/ESC twice to return to the Change Installation Menu.
- From the Change Installation Settings Menu, select Add/Change Filesystem
- From this screen you can create and configure each new filesystem. You can use the defaults or make changes such as the filesystem type. Create the following filesystems:
- Once you have created each of the above filesystems, select the root filesystem. Edit the device used from the 64M partitions you recently created to the new "rootlv" logical volume. Press F3/ESC twice to return to the Change Installation Settings Menu. (You can ignore the warning about space because we will be spreading the data across multiple filesystems.)
Final Cleanup and Restore
As I stated before, we will remove the temporary partition we created. From the Change Installation Settings Menu, select Change Partition Tables
Select to remove the last partition (sda5). Once it is removed you should have three partitions.
From this point, you are ready to restore your system. Press F3/ESC until you are at the Main Menu. From the Main Menu, select Install the System with Current Settings
We just went through the simple steps of splitting up a single root filesystem into multiple fileysystems using LVM. You can also use this process to spread a system across multiple disks, configure software RAID, change filesystem types, or move from internal disks to SAN attached storage.