Removal of Disk Drives That Have Already Been Assigned to an LVM for either an x86 or s390 installed MOI Appliance
search cancel

Removal of Disk Drives That Have Already Been Assigned to an LVM for either an x86 or s390 installed MOI Appliance

book

Article ID: 204211

calendar_today

Updated On:

Products

Mainframe Operational Intelligence

Issue/Introduction

The Resolution process documented below using the attached remove-disks-lvm script can be used to remove disk volumes that have already been assigned to a MOI appliance LVM in either the x86 or s390 Linux environments.   There are also manual steps that accomplish the same disk removal if the script does not work correctly.

Environment

Mainframe Operational Intelligence Release : 2.0 

Service Pack:  2.0.*

Component : MFOPIN

Resolution

Due to an internal DASD migration, customer was able to format new DASD volumes for his zLinux MOI appliance and complete the appliance installation. In addition, the customer was able to remove unwanted DASD volumes that had been incorrectly assigned to LVM's using the following process with the attached script.   There are also manual steps documented after the script process below. 

 

Removing disk storage devices from MOI LVMs

Backups are strongly recommended prior to removing storage. If possible, we recommend you take a VM snapshot.

Automated process for removing storage

  1. Copy the attached script called remove-disks-lvm_1606795749367.sh to the local filesystem of the MOI machine e.g., into /tmp
  2. Make the file executable if necessary

sudo chmod +x remove-disks-lvm_1606795749367.sh

  1. Shutdown MOI
  1. $ cd /opt/moi
  2. $ bin/plex shutdown --bg=wait
  1. Execute it as follows from your machine to remove the disks from your LVMs:

$  ./remove-disks-lvm_1606795749367.sh /lvm1 /dev/sdf1 /dev/sdk1

$  ./remove-disks-lvm_1606795749367.sh /lvm2 /dev/sdg1 /dev/sdj1

$  ./remove-disks-lvm_1606795749367.sh /lvm3 /dev/sdh1 /dev/sdi1

where /dev/sdf1, /dev/sdk1,... are the disks to be removed.

  1. Start MOI
  1. $ cd /opt/moi
  2. $ bin/plex startup -d --bg=wait

Manual process for removing storage

The following process can be used to manually remove disks. For example, you want to remove the disk /dev/dasdg1 from the LVM mounted at /lvm1

Mounted at /lvm1 is the following LVM: /dev/lvm1_vg/lvm1_lv where the LVM name is lvm1_lv and the LVM volume group is lvm1_vg.

  1. Shutdown MOI
  1. $ cd /opt/moi
  2. $ bin/plex shutdown --bg=wait
  1. Unmount the LVM
  1. $ umount /lvm1
  1. Check the filesystem
  1. $ e2fsck -f /dev/lvm1_vg/lvm1_lv
  1. Reduce the size of the filesystem on that LVM by the total size of the disk you are removing plus 10%
  1. $ removeSize=$(pvs --noheadings --nosuffix --units m -o pv_size /dev/dasdg1)
  2. stores the size of the disk in megabytes to removeSize
  3. $ lvmSize=$(lvs --noheadings --nosuffix --units m -o lv_size /dev/lvm1_vg/lvm1_lv)
  4. stores the size of the logical volume in megabytes to lvmSize
  5. $ finalSize=$(( (${lvmSize%.*} - ${removeSize%.*}) * 9 / 10 ))
  6. stores the reduced filesystem size in finalSize
  7. $ resize2fs /dev/lvm1_vg/lvm1_lv "${finalSize}"M
  1. Reduce the allocated physical extents on that LVM by the physical extents on the disk you are removing plus 1
  1. $ extentsToRemove=$(pvs --noheadings -o pv_pe_alloc_count /dev/dasdg1)
  2. stores the number of extents to remove to extentsToRemove
  3. $ (( extentsToRemove++ ))
  4. add one more extent so there is an extent free on the remaining disks, otherwise pvmove will return no free extents
  5. $ lvreduce -l -${extentsToRemove} /dev/lvm1_vg/lvm1_lv
  6. respond with 'y'
  7. reduces the size of the LVM
  1. Move the extents on the disk you are removing to the other disks
  1. $ pvmove /dev/dasdg1
  2. will probably return "No data to move for lvm1_vg" but if not then the data migration may take a while.
  1. Remove the disk from the volume group
  1. $ vgreduce lvm1_vg /dev/dasdg1
  1. Mount the LVM
  1. $ mount -a
  1. Resize the LVM and filesystem to use the entire volume group
  1. lvresize -l +100%free /dev/lvm1_vg/lvm1_lv
  2. resize2fs /dev/lvm1_vg/lvm1_lv
  1. Start MOI
  1. $ cd /opt/moi

$ bin/plex startup -d --bg=wait

Attachments

remove-disks-lvm_1606795749367.sh get_app