In many scenarios, the default disk allocation for Monsoon-built Linux partitions is inadequate for installation of larger HANA-based systems. This guide will walk through adding additional disk volumes and extending the Linux Volume Manager (LVM) partitions to include the added space.
In my scenario, I found it necessary to extend both /var and /opt directories when installing Hadoop, which I will walk through below.
- Creating the Volume
- Adding the volume to volume group
- Extending the volume partitions
Creating the Volume
First we need to create a volume in Monsoon and attach it to the instance whose partitions we want to extend. To do this navigate to the project for your instance, click the Volumes tab and New Volume.
In the creation screen, the two necessary fields are Availability Zone, which should match the region and zone where your instance is located, and Capacity, which is the capacity of the disk in gigabytes.
Once the volume is created, click the gear icon for the volume and click Attach. Select the instance and optionally add an alias.
Once created, we can click on the name of the instance to see details, including the device path:
We can see the volume is attached and available and we know it is accessible through the path /dev/monsoon/vol-e338e620
Adding the volume to volume group
Next we need to SSH to the instance we attached the volume to. Once connected log in as root.
We know our volume exists on /dev/monsoon/vol-e338e620. Doing an ls –al we should see this is mapped to /dev/sdb by default:
# ls -al /dev/monsoon/vol-e338e620 lrwxrwxrwx 1 root root 6 Feb 14 20:13 /dev/monsoon/vol-e338e620-> ../sdb
Right now, our connected hard drive is on /dev/sda and is split into two paritions: a boot partition (sda1) and the LVM hard drive partition (sda2). Our attached storage (sdb) is still un-formatted and without a filesystem:
# fdisk -l /dev/sda Disk /dev/sda: 64.4 GB, 64424509440 bytes 255 heads, 63 sectors/track, 7832 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0009dda3 Device Boot Start End Blocks Id System /dev/sda1 * 1 39 307200 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 39 7833 62606336 8e Linux LVM # fdisk -l /dev/sdb Disk /dev/sdb: 268.4 GB, 268435456000 bytes 255 heads, 63 sectors/track, 32635 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
We need to identify the volume group being used as this is what we will need to extend. At time of this writing Monsoon’s default group is vg0 but you can confirm by running vgdisplay like below:
# vgdisplay --- Volume group --- VG Name vg0 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 7 VG Access read/write VG Status resizable MAX LV 0 Cur LV 6 Open LV 6 Max PV 0 Cur PV 1 Act PV 1 VG Size 59.69 GiB PE Size 32.00 MiB Total PE 1910 Alloc PE / Size 1910 / 59.69 GiB Free PE / Size 0 / 0 VG UUID YthGca-Su6c-LgkQ-5Miy-XIOI-heyb-da4nuO
We’ll use fdisk to create a new partition of type 8e (Linux LVM). The order of commands is below:
# fdisk /dev/sdb n - create a new partition p - specify primary [enter] x2 - use the entire disk t - change type 8e - Linux LVM type w - write partition table to disk and exit
Within fdisk, press m at any point to see a list of possible commands. Once written, your new disk should look like this:
Device Boot Start End Blocks Id System /dev/sdb1 1 32635 262140606 8e Linux LVM
Now we create a new Physical Volume (PV) to use this new partition using pvcreate command:
# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created
Next, use pvextend to extend our volume group vg0 to include the new volume:
# vgextend /dev/vg0 /dev/sdb1 Volume group "vg0" successfully extended
Extending the volume partitions
Finally we’ll extend our partitions and then resize the filesystem. You can see a list of all partitions under /dev/vg0/.
First, we’ll use lvextend to extend each logical volume. In this example I am assigning an additional 100GB to each node:
# lvextend -L +100G /dev/vg0/opt Size of logical volume vg0/opt changed from 7.72 GiB (247 extents) to 107.72 GiB (3447 extents). Logical volume opt successfully resized # lvextend -L +100G /dev/vg0/var Size of logical volume vg0/var changed from 5.94 GiB (190 extents) to 105.94 GiB (3390 extents). Logical volume var successfully resized.
Now in order to use the new space, we need to extend the filesystem. The command run will depend on the filesystem in use. Issuing df -T will provide the filesystems for all disks. For ext2, ext3, and ext4 filesystems we can use resize2fs:
# resize2fs /dev/vg0/var resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/vg0/var is mounted on /var; on-line resizing required old desc_blocks = 1, new_desc_blocks = 7 Performing an on-line resize of /dev/vg0/var to 27770880 (4k) blocks. The filesystem on /dev/vg0/var is now 27770880 blocks long. # resize2fs /dev/vg0/opt resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/vg0/opt is mounted on /opt; on-line resizing required old desc_blocks = 1, new_desc_blocks = 7 Performing an on-line resize of /dev/vg0/opt to 28237824 (4k) blocks. The filesystem on /dev/vg0/opt is now 28237824 blocks long.
Your volumes should now be extended! You can confirm by issuing df -h. Below, /var is now 105G and /opt is 106G:
# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg0-root 32G 2.3G 28G 8% / tmpfs 16G 0 16G 0% /dev/shm /dev/sda1 283M 32M 236M 12% /boot /dev/mapper/vg0-home 2.9G 4.6M 2.8G 1% /home /dev/mapper/vg0-opt 106G 4.8G 96G 5% /opt /dev/mapper/vg0-tmp 7.5G 48M 7.1G 1% /tmp /dev/mapper/vg0-var 105G 2.5G 97G 3% /var