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

References: [1] [2]


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!


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

Use Sun Java plugin in Firefox for Ubuntu 12.04

Technical, Technology
  1. Download and expand a JRE or JDK using root account.  Record the path, e.g. /usr/lib/jvm/jdk1.6.0_23 (we call it <java path>).
  2. sudo update-alternatives --install "/usr/bin/java" "java" "<java path>/bin/java" 1
  3. mkdir -v ~/.mozilla/plugins (skip this if the directory already exists)
  4. cd ~/.mozilla/plugins
  5. ln -s <java path>/jre/lib/amd64/