Shrink an LVM volume

Technical, Technology

First, boot your machine up using a SystemRescueCD.  Then follow the command sequence below.

# Make any logical volume available to Linux
vgchange -a y
# Force a filesystem check for the target volume
e2fsck -f /dev/mapper/vg_server1-lv_root
# Resize the filesystem (a safer measure is to resize it to 10% less than your target size)
resize2fs /dev/mapper/vg_server1-lv_root 90G
# Reduce the LV size (to your target size)
lvreduce -L 100G /dev/mapper/vg_server1-lv_root
# Resize the inner filesystem to fit the LV
resize2fs /dev/mapper/vg_server1-lv_root
# If you have a few LVs and you do the above for all, chances are you are left with a PV having a few fragmented LVs
# The command below sees how the LVs are arranged
pvs -v --segments /dev/sda2
# Move the fragmented LVs back to the front
pvmove --alloc anywhere /dev/sda2:<src-from>-<src-to> /dev/sda2:<dest-from>-<dest-to>
# Shrink the PV
pvresize --setphysicalvolumesize 64G /dev/sda2
# Then use GPartEd in X-windows to resize the partition
startx

References: [1] [2]

Advertisements

Nice tool to control Linux service startup – sysv-rc-conf

Technical, Technology

The tool should come with the standard repos.  So, just do:
sudo apt-get update
sudo apt-get install sysv-rc-conf

Run it by:
sudo sysv-rc-conf

It gives you a nice UI that you could see all service setting vs. rc levels. You could also simply move by cursor to whatever service you would like to change the startup setting. Hitting space bar toggles the setting.

Good tool!

c.f. http://superuser.com/questions/266040/how-do-you-disable-an-upstart-service-in-ubuntu-10-10

Install hddtemp in CentOS – to check harddisk temperature in Linux

Technical, Technology

Assuming you are now logged in as root.

  1. Add repository
  2. yum update
  3. yum install hddtemp