enterprisemediawiki / meza

Setup an enterprise MediaWiki server with simple commands
MIT License
41 stars 27 forks source link

VM partitions require size reallocation #420

Open darenwelsh opened 8 years ago

darenwelsh commented 8 years ago

Some of the VMs we have used were provided to us with partitions in non-ideal sizes. For example, one server had 50G for root, but an additional 200G for /home. If you'd like to modify the partitions by reducing the amount allocated to /home and increasing root to take the extra space, use the following commands. This might be possible with a script, but I didn't take the time to add in error-checking logic and handling the temporary user creation.

# SSH via su-doer
# sudo su #or run script as root

# make home2 dir
mkdir /home2

# create temp user oscarrogers with home directory /home2/oscarrogers
# ref: https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-centos-quickstart
# ref: https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-users-add.html
adduser oscarrogers -d /home2/oscarrogers

# update password for oscarrogers
passwd oscarrogers

# add oscarrogers to wheel group
usermod -aG wheel oscarrogers

# log out from su-doer
# SSH via oscarrogers
# sudo su

# Potentially required - Update date
date --set="Mmm DD HH:MM:SS YYYY"

# Potentially required - update yum and mirror lists
# Ref: https://github.com/enterprisemediawiki/meza/issues/152
yum clean all
yum -y update

# Potentially required - install fuser
yum install -y psmisc

# check if someone is using /home
# ref: http://unix.stackexchange.com/questions/107885/busy-device-on-umount
fuser -vm /home

# if someone is using /home, kick them out
# kill -9 <PID>

# try to umount /home to make sure no one is using it
umount /home
mount /home

# backup /home contents
tar --create --verbose --file=/homebup.tar.bz2 -C /home .

# check that you can read the file just created
tar tvf /homebup.tar.bz2

# check on which partition /home is mounted and write down
mount

# unmount /home
umount /home

# comment out the entry for /home in /etc/fstab, you might have UUID instead of sdX2
# you can lookup which UUID belongs to sdX by doing: ls -l /dev/disk/by-uuid/ | grep -F sdX2
# vi /etc/fstab

# modify partitions
# ref: http://www.tecmint.com/extend-and-reduce-lvms-in-linux/

# check info on physical volume
pvs

# check info on volume group
vgs

# check info on logical volumes
lvs
lvdisplay

# remove /home logical volume
lvremove /dev/mapper/centos-home
# yes

# create /home logical volume with 1G
lvcreate -L 1G -nhome centos
# wipe it? y, I think

# create xfs on /home
# note that "centos-home" might be something different like "centos_jsc--sma--dkmswiki-home"
mkfs.xfs /dev/mapper/centos-home

# uncomment /home in /etc/fstab
vi /etc/fstab

# mount /home
mount /home

# see that /home is mounted
df -h

# extend / (root) logical volume
lvextend -l +100%FREE /dev/mapper/centos-root

# extend the file system on root
xfs_growfs /dev/mapper/centos-root

# restore backup data to /home
tar xvf /homebup.tar.bz2 -C /home
rm -f /homebup.tar.bz2

# exit as oscarrogers
# SSH as su-doer
# sudo su

# Remove oscarrogers
userdel -r oscarrogers
darenwelsh commented 7 years ago

It seems like the default allocation for / maxes out at 50 GiB and the CentOS installer allocates the excess to /home (after allocating its recommended amounts for /boot and swap). So if you can control the allocation during VM creation, you should consider how large your wiki data will grow. All of the wiki databases, uploaded files, and backup files are stored under /. I'll add some documentation instructing VM creators to do this.