Emulate network latency using tc
Use this code:
PATH=$PATH:/sbin
lat=$1 ## desired bandwidth in megabits per sec
destip=$2 ## destination host to limit traffic to
if [[ -z $lat ]]
then
lat=100
fi
if [[ -z $destip ]]
then
echo "using default IP: 192.168.245.21"
destip=192.168.245.21
fi
echo "note this may not work for VMs since it uses eth instead of peth0"
tc qdisc del dev eth0 root
tc qdisc add dev eth0 root handle 1: prio
tc qdisc add dev eth0 parent 1:3 handle 30: netem \
delay ${lat}ms
## add to end of previous line for distribution: 10ms distribution normal
## I think the line below is for bandwidth
#tc qdisc add dev eth0 parent 30:1 tbf rate 20kbit buffer 1600 limit 3000
tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 \
match ip dst $destip/32 flowid 1:3
(Source: linuxfoundation.org)
Resize an LVM disk and FS
Resize the partition using LVM:
sudo lvextend -L30G /dev/mapper/VolGroup00-LogVol05
Unmount the partition (hopefully it isn’t the root!):
sudo umount /dev/mapper/VolGroup00-LogVol05
Check the FS for errors
sudo e2fsck -f /dev/mapper/VolGroup00-LogVol05
Adjust the FS to the new size
sudo resize2fs /dev/mapper/VolGroup00-LogVol05
Remount the disk
sudo mount /dev/mapper/VolGroup00-LogVol05 /home
Adjust number of file descriptors
cat >> /etc/security/limits.conf * hard nofile 32768 * soft nofile 32768Test with: ulimit -n
Crontab start at bootup
To run a script or command at every restart, add this to crontab by running crontab -e
@reboot /path/to/my/program