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
- Copy the attached script called remove-disks-lvm_1606795749367.sh to the local filesystem of the MOI machine e.g., into /tmp
- Make the file executable if necessary
- sudo chmod +x remove-disks-lvm_1606795749367.sh
- Shutdown MOI
- $ cd /opt/moi
- $ bin/plex shutdown --bg=wait
- 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.
- Start MOI
- $ cd /opt/moi
- $ 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.
- Shutdown MOI
- $ cd /opt/moi
- $ bin/plex shutdown --bg=wait
- Unmount the LVM
- Check the filesystem
- $ e2fsck -f /dev/lvm1_vg/lvm1_lv
- Reduce the size of the filesystem on that LVM by the total size of the disk you are removing plus 10%
- $ removeSize=$(pvs --noheadings --nosuffix --units m -o pv_size /dev/dasdg1)
- stores the size of the disk in megabytes to removeSize
- $ lvmSize=$(lvs --noheadings --nosuffix --units m -o lv_size /dev/lvm1_vg/lvm1_lv)
- stores the size of the logical volume in megabytes to lvmSize
- $ finalSize=$(( (${lvmSize%.*} - ${removeSize%.*}) * 9 / 10 ))
- stores the reduced filesystem size in finalSize
- $ resize2fs /dev/lvm1_vg/lvm1_lv "${finalSize}"M
- Reduce the allocated physical extents on that LVM by the physical extents on the disk you are removing plus 1
- $ extentsToRemove=$(pvs --noheadings -o pv_pe_alloc_count /dev/dasdg1)
- stores the number of extents to remove to extentsToRemove
- $ (( extentsToRemove++ ))
- add one more extent so there is an extent free on the remaining disks, otherwise pvmove will return no free extents
- $ lvreduce -l -${extentsToRemove} /dev/lvm1_vg/lvm1_lv
- respond with 'y'
- reduces the size of the LVM
- Move the extents on the disk you are removing to the other disks
- $ pvmove /dev/dasdg1
- will probably return "No data to move for lvm1_vg" but if not then the data migration may take a while.
- Remove the disk from the volume group
- $ vgreduce lvm1_vg /dev/dasdg1
- Mount the LVM
- Resize the LVM and filesystem to use the entire volume group
- lvresize -l +100%free /dev/lvm1_vg/lvm1_lv
- resize2fs /dev/lvm1_vg/lvm1_lv
- Start MOI
- $ cd /opt/moi
- $ bin/plex startup -d --bg=wait