- First, use LVM; it makes resizing filesystems nearly trivial, robust, without any real downsides. Just another way that Ubuntu is not enterprise-worthy. But, we don’t have LVM on these systems’s as they are….
- Second, before doing any operations on your partitions, always perform and test a backup (to a separate system!) of your data. You may make your system unbootable and/or nuke all of your data!
- The system I performed these steps on was partitioned thus:
- /dev/sda – 7GB – /
- /dev/sda2 – remainder – Extended partition
- /dev/sda5 – swap – partition within the extended partition.
- So, to grow “/”, we will become root, delete the swap partition and the extended partition, grow /, and then re-create the swap partition. Adjust the steps below according to the partition numbers and layout of your particular system:
- Disable swap:
- swapoff /dev/sda5
- Delete and re-create partitions as appropriate.
- fdisk /dev/sda
- print out partition information (p)
- Delete partition 5 (d – 5)
- Delete partition 2 (d – 2)
- Delete partition 1 (d)
- Create partition 1 (n – p – 1)
- It must start on the exact same sector as before (as seen in the print command)
- It must end on a sector higher than it did before. Num_GB*1024*1024*2 = ending sector
- Create partition 2 (n – p – 2)
- Change partition 2 to type “Linux Swap” (t – 2 – 82 )
- Activate partition 1 to make it bootable (a - 1)
- Double-check everything.
- Exit (w)
- recreate the swap partition, using a label:
- mkswap -L swap /dev/sda2
- add a label to the root filesystem
- e2label /dev/sda1 / (in centos, it’s e4label)
- Fix up /etc/fstab
- Fix the “swap” line to use LABEL=swap instead of UUID=
- Fix the “/” line to use LABEL=/ instead of UUID=
- swapon /dev/sda2
- Fix up /boot/grub/grub.cfg
- Either: Find the “linux” line for the menu option you will boot, change UUID= to LABEL=/
- Or: update-grub
- Re-create the initrd
- update-initramfs -u -k 3.2.0-38-generic
- Reboot the VM. *Cross your fingers!* This is your moment of truth.
- Grow the root filesystem
- resize2fs /dev/sda1 (resize4fs on CentOS, I believe).
- If it didn't boot, then that's what you get for biting off more than you could chew, and for choosing a distro that doesn't leverage LVM. Boot off your Ubuntu/Mint install disk, and copy off your data to a USB disk, and start over. (...but you DID back up your data anyway, right?)
2013/12/06
Grow root partition and filesystem in Ubuntu and Linux Mint
Here are the steps to grow the root filesystem on an existing system that does NOT use LVM:
2013/11/15
Automatically delete old NetApp snapshots left by backups
Backup software may sometimes leave behind a snapshot. This can increase the space consumption a lot over time.
Here's a script that can be run against NetApp filers to clean up those "stale" backups. Note that in my case, I configured CommVault to name the snapshots with the string "snapshot_for_backup", though the default is just "ndmp". You may change that as needed.
Here's a script that can be run against NetApp filers to clean up those "stale" backups. Note that in my case, I configured CommVault to name the snapshots with the string "snapshot_for_backup", though the default is just "ndmp". You may change that as needed.
#!/bin/bash# This script is to look for snaps that are left over from backups, that # are no longer in use, and delete them.# This script requires two parameters:# snap_cleanup
(list or delete all stale snaps on the specified servers) NasUser="root"SnapshotString="snapshot_for_backup"SshIdentityFile="/root/.ssh/id_rsa_auslxfs00_rsync"SshBinary=/usr/bin/ssh# This function receives a volume name as a parameter, and returns # the number of snaps that are elligible for deletion, defined by being:# 1. Having a certain string in the snapshot name;# 2. Not marked as "busy"function CountStaleSnaps (){local VolToCheck=$1local StaleSnaps=`$SshCmd "snap list $VolToCheck" | grep $SnapshotString | grep -v "busy" | wc -l`if [ $? -ne 0 ]; then{echo "getting count of elligible snapshots returned an error"exit 1} else{echo $StaleSnaps} fi}# Function GetStaleSnapNames# This function creates, given a volume name, an array of snapshots that are # candidates for deletion.# Parameters# 1. volume to checkfunction GetStaleSnapNames (){local Volume=$1StaleSnapNames=( $($SshCmd "snap list $Volume" | grep $SnapshotString| grep -v busy | cut -c 39- | cut -f 1 -d " ") )if [ $? -ne 0 ]; then{echo "getting names of elligible snapshots returned an error"exit 1} else{printf -- '%s\n' "${StaleSnapNames[@]}"} fi}# Function DelStaleSnaps# This function deletes stale snaps for the Volume name passed to it.# Parameters# 1. volume# 2. snapshot_namefunction DelStaleSnaps (){local Volume=$1local SnapToDelete=$2$SshCmd "snap delete $Volume $SnapToDelete"if [ $? -ne 0 ]; then{echo "error deleting snapshot $Volume:$SnapToDelete"exit 1} else{echo "successfully deleted snapshot $Volume:$SnapToDelete"} fi}# Parse command line parameterscase $2 in"")echo "ERROR: you must specify as a second parameter a host name on which you want to delete snapshots.";;*)NasName=$2;;esaccase $1 inlist)Operation=list;;delete)Operation=delete;;*)echo "ERROR: invalid operation specified on command line. Please specify either 'list' or 'delete' followed by the servername on which you want to delete the snapshots."exit 1;;esacSshCmd="/usr/bin/ssh -i $SshIdentityFile $NasUser@$NasName"VolumesToCheck=( `$SshCmd "vol status -b" | cut -f 1 -d " " | egrep -v "Volume|-----"` )for CurrentVol in ${VolumesToCheck[@]}; do {echo -n "checking $NasName:$CurrentVol... "StaleSnaps=`CountStaleSnaps $CurrentVol`echo $StaleSnapsif [ $Operation = list ]; thenif [ $StaleSnaps -ne 0 ]; thenGetStaleSnapNames $CurrentVol | awk '{ print " " $1 }'fielif [ $Operation = delete ]; thenGetStaleSnapNames $CurrentVolArrayOfSnaps=( $(GetStaleSnapNames $CurrentVol) )for TargetSnap in `printf -- '%s\n' "${ArrayOfSnaps[@]}"`; doDelStaleSnaps $CurrentVol $TargetSnapdonefi}; done
2013/07/10
Linux bash shell options parsing
Normally, command line parameters come in as separate, positional values, and may be referenced as:
- $# - the number of command line arguments (positional parameters)
- $* - all positional parameters expressed as a single string
- $@ - all positional parameters, but with each as a quoted string (each positional parameter is intact and presented as a quoted string)
- $0 - (the base name of the script itself)
- $1 - The first positional parameter
- $2 - The second positional parameter, and $3, $4, etc. Starting with 10, they must be expressed as ${10}, ${11}, etc.
Here, we test for that case, and if found, we peel off the first parameter within that group of strings, and assign the remaining parameters in the group of springs:
# from the front, and make the rest of the data be the options passed to rsync.
if [ $# -eq 1 ]; then
{
Params=($1)
PARAM_1=${Params[0]}
unset Params[0]
ChildCommandOpts=${Params[*]}
} fi
2013/07/02
Manipulate windows firewall from CLI
The windows firewall UI is a bit cumbersome. This method will let you set up a host reliably to be secure, and to allow only inbound traffic that you want.
Enable firewall in all profiles (home / domain / public)
netsh advfirewall set allprofiles state on
By default, deny all inbound and allow all outbound traffic
netsh advfirewall set allprofiles firewallpolicy blockinbound,allowoutbound
Add rule to allow SMTP traffic inbound to a specific port from a specific network range
netsh advfirewall firewall add rule name="Allow Inbound TCP/25 from SMTP relay hosts" protocol=TCP dir=in localport=25 action=allow remoteip=10.20.30.0/24
Add rule to allow all HTTP and HTTPS traffic inbound
netsh advfirewall firewall add rule name="Allow Inbound TCP/80 from everywhere" protocol=TCP dir=in localport=80 action=allow
Enable firewall in all profiles (home / domain / public)
netsh advfirewall set allprofiles state on
By default, deny all inbound and allow all outbound traffic
netsh advfirewall set allprofiles firewallpolicy blockinbound,allowoutbound
Add rule to allow SMTP traffic inbound to a specific port from a specific network range
netsh advfirewall firewall add rule name="Allow Inbound TCP/25 from SMTP relay hosts" protocol=TCP dir=in localport=25 action=allow remoteip=10.20.30.0/24
Add rule to allow all HTTP and HTTPS traffic inbound
netsh advfirewall firewall add rule name="Allow Inbound TCP/80 from everywhere" protocol=TCP dir=in localport=80 action=allow
2013/04/08
Upgraded ESXi host has errors, won't permit some operations
I have some ESXi hosts that were 4.x, then upgraded to 5, then 5.1 . As of today, they have errors that complain about the HA agent being broken. They also won't let me enable/disable the SSH service nor modify the firewall configuration.
The error for the SSH service starts with 'Call "HostFirewallSystem.DisableRuleset" for object' .
These two articles provide the answers. After following the first step, I no longer get the error about SSH and firewall.
After following the second article, my HA agent is no longer complaining.
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2037544
http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=1003490
Boiling the steps down, I have
The error for the SSH service starts with 'Call "HostFirewallSystem.DisableRuleset" for object' .
These two articles provide the answers. After following the first step, I no longer get the error about SSH and firewall.
After following the second article, my HA agent is no longer complaining.
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2037544
http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=1003490
Boiling the steps down, I have
- Fix SSH and firewall
- enable ssh on the host (if not already enabled); this is under host --> configuration --> security profile
- ssh to the host
- cd /etc/vmware/service
- cp services.xml service.xml.bak
- vi services.xml (remove the line with "
sshServer ") - esxcli network firewall refresh
- disable ssh on the host (but don't close your connection if you're going to continue with the next process)
- Restart the ESXi host agents
- On the host, run this command: /sbin/services.sh restart
- this step takes a few minutes to complete.
2013/03/15
SNMP OIDs for temperature monitoring
...This is for anyone looking for these things in one place, with the scale and units. ( extracted from http://wleibzon.bol.ucla.edu/nagios/plugins/check_snmp_temperature.pl )
- Dell (10C)
- 1.3.6.1.4.1.674.10892.1.700.
20.1.8 - 1.3.6.1.4.1.674.10892.1.700.
20.1.6 - Cisco (C)
- 1.3.6.1.4.1.9.9.13.1.3.1.2
- 1.3.6.1.4.1.9.9.13.1.3.1.3
- fans: 1.3.6.1.4.1.9.9.13.1.4.1.3
- juniper (C)
- 1.3.6.1.4.1.2636.3.1.13.1.5
- 1.3.6.1.4.1.2636.3.1.13.1.7
- HP (C)
- 1.3.6.1.4.1.232.6.2.6.8.1.3
- 1.3.6.1.4.1.232.6.2.6.8.1.4
- alteon (C)
- Rear Left Sensor - 1.3.6.1.4.1.1872.2.1.1.6.0
- Rear Middle Sensor - 1.3.6.1.4.1.1872.2.1.1.7.0
- Front Middle Sensor - 1.3.6.1.4.1.1872.2.1.1.8.0
- Front Right Sensor - 1.3.6.1.4.1.1872.2.1.1.9.0
- baytech PDU (10C)
- 1.3.6.1.4.1.4779.1.3.5.2.1.2
- 1.3.6.1.4.1.4779.1.3.5.2.1.8
- Linux lmsensors (1000C)
- 1.3.6.1.4.1.2021.13.16.2.1.2
- 1.3.6.1.4.1.2021.13.16.2.1.3
- APC temperature
- 1.3.6.1.4.1.318.1.1.2.1.1.0
- APC humidity
- 1.3.6.1.4.1.318.1.1.2.1.2.0
- HP switch
- temperature: 1.3.6.1.4.1.11.2.14.11.1.2.6.1.4.4
- fan: 1.3.6.1.4.1.11.2.14.11.1.2.6
2013/02/07
Tweaks for Linux Mint
These were started with Linux Mint 14.1 Cinnamon
Menu bar shows up on the wrong screen:
Do this to find out the name of the displays:sudo xrand -qDo this to make the menu show up on one display or the other, for example:sudo xrand --output VGA1 --primary
Sound doesn't come out through the correct device (speaker, headphone, etc.):
run these: sudo apt-get install alsa-base alsa-utils pavucontrol pavumeter pamanalsamixer
...then in alsamixer, select the desired output "card", then ensure that "automute" is set to disabled or some other device.
I want to watch Netflix on Mint:
Run these commands: sudo apt-add-repository ppa:ehoover/compholio
sudo apt-get install netflix-desktop
Display locks up with my NVidia card:
During install, select "compatibility mode".After install, before logging in, select session type "Cinnamon 2D", thensudo apt-get install nvidia-current nvidia-settingssudo reboot
2012/10/26
Open-iscsi initiator
This was done on ubuntu 12.04 . Something similar with work on Red Hat, Fedora, or CentOS, by replacing e.g. apt-get with yum install.
Prep work
Ubuntu/Debian derivatives: apt-get install open-iscsi open-iscsi-utils
RedHat/CentOS derivatives: yum install iscsi-initiator-utils
RedHat/CentOS derivatives: yum install iscsi-initiator-utils
Modify the initiator name if needed (e.g., if this was a cloned VM that already had open-iscsi installed), because each must be unique
(e.g., if we cloned the VM, then we must change the IQN!)
vi /etc/iscsi/iscsid.conf (change “manual” to
“automatic”, set CHAP parameters, etc., if needed)
vi /etc/iscsi/initiatorname.iscsi (put the correct initiator name)
(Probe the SAN so that this will show up as a valid initiator on the SAN)
iscsiadm -m discovery -t sendtargets -p
10.10.10.27
iscsiadm -m discovery -t sendtargets -p
10.10.10.29
(connect to the iSCSI SAN/target, allow this iSCSI initiator)
Our SAN has multiple iSCSI interfaces, so we'll use multipathing
restart iscsi-network-interface
/etc/init.d/open-iscsi restart
iscsiadm -m discovery -t sendtargets -p
10.10.10.27
iscsiadm -m discovery -t sendtargets -p
10.10.10.29
iscsiadm -m node -lapt-get install multipath-tools
multipath -d -l (the two scsi paths should show up and should be recognized as a single block target with multiple paths)
apt-get install sg3-utils
sg_map (the new scsi devices should show up)
Prepare the filesystem for persistent mounting
ls -la /dev/disk/by-id (get the /dev/disk/by-id/dm-uuid-mpath-… for
this new multipath device)
mkdir /mnt/localscratch0
vi /etc/fstab
Add a line like this:
/dev/disk/by-id/dm-uuid-mpath-360060f870104b72e004f3263600000001
/mnt/localscratch0 ext4 defaults,noatime 0 2
Format the filesystem (destroying all existing data; only do this if you do not want to keep your previous data on that LUN), then mount it
mkfs.ext4 -L localscratch0
/dev/disk/by-id/dm-uuid-mpath-360060f870104b72e004f3263600000001
mount -a
That's it, all done. It should auto-mount on the next reboot.
2012/08/31
Ubuntu 12.04 tweaks
Install Some Useful Programs
sudo apt-get install byobu remmina gconf-editor
Dual displays don't come up with a single large virtual workspace.
Run "sudo nvidia-settings" and change both monitors to "Twin view". Save the config. Then log out and back in.
sudo gconf-editor
set
Setting
Fix annoying dual-screen behaviors:
sudo gconf-editor
set
/apps/compiz-1/plugins/unityshell/screen0/options/overcom_pressure=1 to make it possible to pass from one screen to another flawlessly and /apps/compiz-1/plugins/unityshell/screen0/options/stop_velocity=20 to still make it possible to access the hidden launcher on the left screen.Setting
/apps/compiz-1/plugins/unityshell/screen0/options/num_launchers=1 in gconf-editor causes the Unity launcher to be displayed on the primary desktop only. Logitech Z-5 USB speakers don't workout of the box.
Here's one fix:
- "sudo vi /etc/modprobe.d/alsa-base.conf", and add these lines to the bottom:
- alias snd-card-0 snd-usb-audio
alias snd-card-1 snd-hda-intel
options snd-usb-audio index=0
options snd-hda-intel index=1 - To fix the volume, find the line in /etc/pulse/default.pa with "load-module module-udev-detect" and change it to "load-module module-udev-detect ignore_dB=1d"
- apt-get install paman paprefs pavucontrol pavumeter
- http://ubuntuforums.org/showthread.php?t=922860
- Final settings:
- alsamixer:
- Master: 5
- Headphone: --
- Speaker: 0<>0
- PCM: 0<>0
- Line: 87<>87
- Beep: 18<>18
- Aux: 70<>70
- Auto-mute: Speaker only
- sudo alsactl store
- pavucontrol
- Output devices: Built-in Audio Analog Stereo
- Port: Speakers
- Configuration
- Built-in Audio: Analog stereo duplex
- HD Webcam C910: Analog Stereo Input
- Z-5 Speakers: Analog Stereo Output
- System Sound Settings:
- Output: Play sound through: Speakers (built-in Audio)
Focus does not follow mouse, annoying that menus are not in the app window
- apt-get remove appmenu-gtk appmenu-gtk3 appmenu-qt firefox-globalmenu indicator-appmenu thunderbird-globalmenu
- gconf-editor
- /apps/metacity/general/focus-mode --> sloppy
- /apps/metacity/general/auto_raise_delay --> 800
Install Oracle JRE and Mozilla plugin
Download the Oracle JRE from here: http://java.com/en/download/linux_manual.jspsudo apt-get purge openjdk*
sudo mkdir -p /usr/lib/jvm
sudo tar -xvf Downloads/jre-7u7-linux-x64.tar.gz -C /usr/lib/jvm/
cd /usr/lib/jvm
sudo ln -s jre1.7.0_07/ jre1.7.0
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.7.0/bin/java 0
mkdir -p ~/.mozilla/plugins
ln -s /usr/lib/jvm/jre1.7.0/lib/i386/libnpjp2.so ~/.mozilla/plugins/
Some Icons are hidden in the systray
sudo apt-get install dconf-toolsdconf-editor
(go to desktop --> Unity --> Panel)
replace the value in systray-whitelist with 'all'
No more taskbar
sudo apt-get install xfce4-panelRun it. Configure it.
run "Startup Applications", add this to it (/usr/bin/xfce4-panel)
2011/09/27
Uninstall GDM from Ubuntu 10.x and up
If you just uninstall the desktop packages and/or gdm, you will find that your system will hang upon reboot: it's trying to start a gdm that's not there!
First, this is braindead behaviour from Canonical/Ubuntu. Uninstalling GDM should obviously clean up after itself, including setting a new default display manager, or if there is none, then change to boot to text mode.
Here's what you have to do *before* you reboot. (else, you boot into a rescueCD):
edit /etc/default/grub, and change this line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
to
GRUB_CMDLINE_LINUX_DEFAULT="text"
Then, run "sudo update-grub". (If and only if you are in a rescueCD, then you have to edit /boot/grub/grub.cfg so that the default menu option has init=/bin/bash at the end of the kernel load line; reboot, remount / read-write, run "update-grub", and then reboot.
Failing that (or if you want to be sure), verify that the file /etc/X11/default-display-manger is empty (or the one line is commented out).
First, this is braindead behaviour from Canonical/Ubuntu. Uninstalling GDM should obviously clean up after itself, including setting a new default display manager, or if there is none, then change to boot to text mode.
Here's what you have to do *before* you reboot. (else, you boot into a rescueCD):
edit /etc/default/grub, and change this line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
to
GRUB_CMDLINE_LINUX_DEFAULT="text"
Then, run "sudo update-grub". (If and only if you are in a rescueCD, then you have to edit /boot/grub/grub.cfg so that the default menu option has init=/bin/bash at the end of the kernel load line; reboot, remount / read-write, run "update-grub", and then reboot.
Failing that (or if you want to be sure), verify that the file /etc/X11/default-display-manger is empty (or the one line is commented out).
Subscribe to:
Posts (Atom)