Now that my daily work is more focused on Linux I found myself performing the same basic administration tasks in Linux that I’m used to do in HP-UX. Because of that I thought that a post explaining how the same basic file system and volume management operations are done in both operative systems was necessary, hope you like it.
This is going to be a very basic post intended only as a reference for myself and any other Sysadmin coming from either Linux or HP-UX that wants to know how things are done in the other side. Of course this post is no substitute of the official documentation and the corresponding man pages.
I’ve used Red Hat Enterprise Linux 5.5 as the Linux version and 11iv3 as the HP-UX version.
The following topics will covered:
Volume group creation.
Logical volume operations.
File system operations.
Volume group creation
Physical volume and volume group creation are the most basic tasks in LVM, both in Linux and HP-UX, but although command syntax is quite similar in both operative systems the whole process differs in many ways.
The example used is valid to 11iv2 and 11iv3 HP-UX versions, with the exception of the persistent DSFs you will have to substitute them for the corresponding legacy devices used in 11iv2.
First create the physical volumes.
In /dev create a directory named as the new volume group, change the ownership to root:root and the permissions to 755.
Go into the VG subdirectory and create the group device special file. For the Linux guys, in HP-UX each volume group must have a group device special file under its subdirectory in /dev. This group DSF is created with the mknod command, like any other DSFs the group file must have a major and a minor number.
For LVM 1.0 volume groups the major number must be 64 and for the LVM 2.0 one must be 128. Regarding the minor number, the first two digits will uniquely identify the volume group and the remaining digits must be 0000. In the below example we’re creating a 1.0 volume group.
Change the ownership to root:sys and the permissions to 640.
And create the volume group with the vgcreate command, the arguments passed are the two physical volumes previously created and the size in megabytes of the physical extent. The last one is optional and if is not provided the default of 4MB will be automatically set.
Create the physical volumes. Here it is where the first difference appears. In HP-UX a physical volume is composed by a whole disk, with the exception of boot disks in Itanium systems, but in Linux a physical volume can be a whole disk or a partition.
For the whole disk the process is pretty much the same as in HP-UX.
If you decide to use partitions for the PVs the first, and obvious, thing to do is partition the disk. To setup the disk we’ll use the fdisk tool, following is an example session:
To explain the session first a new partition is created with the command n and the size of the partition is set (in this particular case we are using the whole disk); then we must change the partition type, which by default is set to Linux, to Linux LVM and to do that we use the command t and issue 8e as the corresponding hexadecimal code, the available values for the partition types can be shown by typing L.
The changes are written with w.
Once the partitions are correctly created, setup the physical volumes.
Now that the PVs are created we can proceed with the volume group creation.
As you could see the process in Linux is slightly simple than in HP-UX.
Logical volume operations
In this part we will see how to create a logical volume, extend this LV and then remove it from the system.
The logical volume creation can be done with the lvcreate command. With the -L option we can specify the size in MB of the new lvol, if -l is used instead the size must be provided in logical extents.
Extend a volume. Of course the first prerequisite to extend a volume is to have enough free physical extends in the volume group.
The final step of this part is to remove the logical volume.
Create the logical volume with the lvcreate command, the most basic options (-L, -l, -n) are the same as in HP-UX.
Now extend the logical volume to 384 megabytes as we did in HP-UX.
Remove a volume from the system, like creation and extension is a very straight forward process that can be done with one command.
Unlike the volume group section, the basic logical operations are performed in almost the same way in both operative systems. Of course if you want to perform mirroring the differences are bigger, but I will leave that for a future post.
File system operations
The final section of the post is about the basic file system operation, we are going to create a file system on the logical volume of the previous section and later to extend it, including this time the volume group extension.
Creating the file system with the newfs command.
Create the mount point and mount the filesystem.
Filesystem extension, in the current section we are going to suppose that the volume group has not enough physical extension to accommodate the new size of the /data file system.
After we create a new physical volume in the disk12 we are going to extend the vg_new VG.
The next part is to extend the logical volume just as we did in the logical volume operations section.
And finally the most creepy part of the part of the process, extending the file system. To be capable of extending a mounted filesystem in HP-UX the OnlineJFS bundle must be installed.
Use the command fsadm and with the -b option issue the new size in KB as the argument, in the example we want to extend to 512MB, in KB is 524288.
Here in the filesystem part is where the commands are completely different to HP-UX. In Linux the most common file system types are ext2 and ext3, although others like ext4 or reiserfs are supported.
To create an ext3 file system issue the command mkfs.ext3 using the logical volume to create the file system on as the argument.
As in HP-UX create the mount point and mount the file system.
The final part of the section is the file system extension, as we did in the HP-UX part the first task is to extend the volume group.
Extend the logical volume with lvextend.
Finally resize the file system, to do that use the resize2fs tool. Unlike in HP-UX with fsadm, that needs the new size as an argument in order to extend the file system, if you simply issue the logical volume as the argument the resize2fs utility will extend the file system to the maximum size available in the LV.
And at this point we are done. Courteous comments are welcome as always.