LVM

From ZhoubaWiki
Jump to navigation Jump to search

Scratchpad

lsblk
pvcreate /dev/sdc
pvdisplay
vgcreate vg_prod2 /dev/sdc
vgdisplay
pvdisplay
lvcreate --name lv_var --size 100G vg_prod2
vgdisplay
lvdisplay
pvs && vgs && lvs

mkfs.ext4 /dev/vg_prod2/lv_opt
ls -la /mnt/
mkdir /mnt/lv_temp

/sbin/service wso2gw stop
/sbin/service wso2is stop
cd /opt/gitlab-runner && docker-compose down

mount -t ext4 /dev/mapper/vg_prod2-lv_opt /mnt/lv_temp/
rsync -aX /opt/ /mnt/lv_temp/
cd /opt && ls -lZR > /tmp/opt_orig
cd /mnt/lv_temp && ls -lZR > /tmp/opt_new
vimdiff /tmp/opt_*

lsof +D /opt

/sbin/service wso2is stop
/sbin/service wso2gw stop
/sbin/service omsagent-8ede5cb2-6c8c-44d3-9490-90d485c09176 stop
/sbin/service auditd stop
/sbin/service omid stop

mkfs.ext4 /dev/vg_prod2/lv_tmp
lsof +D /tmp
du -hd 1 /tmp/
rm -rf /tmp/*
chmod 3777 /tmp
mount | awk '$3 == "/tmp"'

mkfs.ext4 /dev/vg_prod2/lv_usr
mount -t ext4 /dev/mapper/vg_prod2-lv_usr /mnt/lv_temp/
rsync -aHX /usr/ /mnt/lv_temp/

cd /usr && ls -lZR > /tmp/usr_orig
cd /mnt/lv_temp && ls -lZR > /tmp/usr_new
vimdiff /tmp/usr_*

vim /etc/fstab
mount -a

Extend

lsblk                                           # show block devices
pvdisplay                                       # show LVM physical volumes
vgdisplay                                       # show LVM volume groups

# start with /opt

lvextend --size 20G /dev/mapper/rootvg-optlv    # extend LVM logical volume

lvdisplay /dev/mapper/rootvg-optlv              # verify the extension
resize2fs /dev/mapper/rootvg-optlv              # resize the FS located at the partition

df -h |grep optlv                               # verify everything went well

# continue with /var

lvextend --size 50G /dev/mapper/rootvg-varlv

lvdisplay /dev/mapper/rootvg-varlv
resize2fs /dev/mapper/rootvg-varlv

df -h |grep varlv

# verify the final outcome
df -h |grep mapper

vgdisplay

# still > 90G left

TODO

Make some order in these!