|
|
slmingol posted this in tips & tricks on January 26th, 2010, @ 8:34 pm
Background
Recently I was trying to create a Ubuntu 9.04 vmware image using Vmware Server 1.08, but I was doing it remotely from my Fedora 10 laptop which was running Vmware Server 1.06. This can normally be done by using Vmware Server’s ability to remotely connect to other Vmware Servers.
 VMware Server Console
Here’s my work flow. NOTE: Ubuntu 9.04 will be running on the vmware server on CentOS 5.4.
 VMware Workflow
Problem
While going through the setup I encountered a problem I hadn’t seen before where the arrow keys didn’t appear to be working within GRUB while I was installing Ubuntu 9.04.
 broken arrow keys
Solution
Turns out there is an option you can enable (i.e. set to TRUE) in the $HOME/.vmware/preferences file which fixes this.
1
| xkeymap.nokeycodeMap = "TRUE" |
NOTE: This change was made to the Vmware Server that was running on the Fedora 10 box.
…. Continue reading → Broken Arrow Keys during an Ubuntu 9.04 install on Vmware Server 1.X »»
slmingol posted this in tips & tricks on October 1st, 2009, @ 10:35 am
Problem
Recently at my day job I’ve been having to go through some pretty old Bash scripts that I’ve basically inherited. As I’ve been going through them I’ve been seeing a lot of confusion as to the proper use of Bash’s export command. The major offense? Not really understand whether a particular variables needs to be exported, or not. So I thought I’d take a moment just to clarify when and when not to use export.
The export command has really only one true purpose. To mark and/or unmark variables (and functions) that you want to have automatically exported to environments of subsequently executed commands. So if you create a script that calls other commands, and you want to push variables into the environment of these commands, then you’ll want to use export.
Example #1 (without export)
For example, let’s say we have the following 2 scripts:
1
2
3
4
5
6
7
| #!/bin/bash
# script #1: parent.bash
var1="this was set by the parent shell script"
echo "inside $0 script: $var1"
./child.bash |
1
2
3
4
| #!/bin/bash
# script #2: child.bash
echo "inside $0 script: $var1" |
And when I run the script parent.bash I get this output:
1
2
3
4
5
| # output from parent.bash & child.bash (without export)
% ./parent.bash
inside ./parent.bash script: this was set by the parent shell script
inside ./child.bash script: |
Notice how the variable $var1, which was set in the parent.bash script, didn’t get displayed by the child.bash script? Now watch this example with the variable $var1 exported in the parent.bash script.
Example #2 (with export)
1
2
3
4
5
6
7
| #!/bin/bash
# script #1: parent.bash
export var1="this was set by the parent shell script"
echo "inside $0 script: $var1"
./child.bash |
1
2
3
4
| #!/bin/bash
# script #2: child.bash
echo "inside $0 script: $var1" |
And when we run parent.bash
1
2
3
4
5
| # output from parent.bash & child.bash (with export)
% ./parent.bash
inside ./parent.bash script: this was set my the parent shell script
inside ./child.bash script: this was set my the parent shell script |
Example #3 (un-exporting)
Export isn’t just a one trick pony. It can also unmark a previously exported variable.
…. Continue reading → [one-liner]: How to Use the Bash Shell’s export Command »»
slmingol posted this in tips & tricks on September 28th, 2009, @ 11:00 am
Background
A while back I was trying to get the vim textile plugin installed and ran into a problem. Apparently the vim that’s included with Fedora 10, 11, and CentOS 5 doesn’t include ruby support. This bug report explains what’s wrong with vim and how it’s missing ruby support. The problem is visible with this command:
1
2
3
4
| % vim --version | grep ruby
+printer +profile +python +quickfix +reltime +rightleft -ruby +scrollbind
...
... |
The –ruby tells us that ruby support isn’t enabled. The only solution I’ve seen thus far is to rebuild vim. Not really a huge deal but it’s work non the less 8-).
Rebuilding vim with ruby support
Here’s how I fixed it.
download vim Source RPM (SRPM)
1
| % wget http://mirrors.xmission.com/fedora/updates/10/SRPMS/vim-7.2.148-1.fc10.src.rpm |
confirm that ruby is installed
1
2
3
4
5
6
| % yum list installed ruby*|column -t|grep ruby
ruby.i386 1.8.6.287-2.fc10 installed
ruby-devel.i386 1.8.6.287-2.fc10 installed
ruby-irb.i386 1.8.6.287-2.fc10 installed
ruby-libs.i386 1.8.6.287-2.fc10 installed
ruby-rdoc.i386 1.8.6.287-2.fc10 installed |
make sure you have your own rpmbuild directory
1
2
3
4
| % mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
# caution with this second command if you already have your own .rpmmacros, this will overwrite!
% echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros |
rebuild vim / re-install vim
1
2
| rpmbuild --rebuild vim-7.2.148-1.fc10.src.rpm
rpm --force -Uvh /root/rpmbuild/RPMS/i386/vim-{c,e,m,X}* |
check that vim now has ruby support
1
2
3
4
| % vim --version | grep ruby
+printer +profile +python +quickfix +reltime +rightleft +ruby +scrollbind
...
... |
Ahh. a +ruby means it worked.
Textile Plugin for vim
Now onto installing the vim textile plugin.
First things first, we need to install rubygems
Next we need to install the RedCloth gem, it’s required by the textile plugin
1
2
3
4
5
6
| % gem install RedCloth
Building native extensions. This could take a while...
Successfully installed RedCloth-4.2.2
1 gem installed
Installing ri documentation for RedCloth-4.2.2...
Installing RDoc documentation for RedCloth-4.2.2... |
Finally, install the textile plugin
Downloading the textile plugin from here,
…. Continue reading → Fixing Ruby Support in Vim on Fedora 10, 11, and CentOS 5 & Installing the Vim Textile plugin »»
slmingol posted this in tips & tricks on September 27th, 2009, @ 3:17 am
Now that I’ve been using OpenVZ for several months I’d gotten to the point where I wanted/needed to “yum update” all my VEs. I currently have 11 images running on my OpenVZ Server. I thought I could just vzctl exec … yum -y update all the VEs, but quickly ran into some issues with this brute force approach. Doing the yum -y update broke several of my VEs so I opted to restore the unrecoverable ones from backups.
For my second attempt, I opted to do each VE independently, to get a better understanding of what the best approach would be for doing mass upgrades like this now, and in the future. The first hurdle to overcome had to do with some of the VEs running out of memory (RAM) during the upgrade process.
NOTE: A VE = Virtual Environment (aka. a virtual host), while HN = Host Node
Issue #1, not enough RAM for yum to run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| # RAM budgets for VEs
# NOTE: values are in # of pages (1 pg. = 4K)
% (printf "vm feature held maxheld barrier limit failcnt\n"; grep privvm /proc/bc/1*/resources)|column -t
vm feature held maxheld barrier limit failcnt
/proc/bc/101/resources: privvmpages 31904 82215 65536 69632 2
/proc/bc/102/resources: privvmpages 119803 196620 166400 179200 9517
/proc/bc/103/resources: privvmpages 27125 35974 65536 69632 0
/proc/bc/104/resources: privvmpages 56251 107250 104960 115200 0
/proc/bc/105/resources: privvmpages 73559 82926 98304 103304 0
/proc/bc/106/resources: privvmpages 30219 68097 65536 69632 0
/proc/bc/108/resources: privvmpages 30081 84291 65536 69632 1
/proc/bc/109/resources: privvmpages 32790 74199 98304 103304 0
/proc/bc/110/resources: privvmpages 40497 69408 65536 69632 1
/proc/bc/111/resources: privvmpages 26990 35371 65536 67840 0
# NOTE: converted the columns to megabytes (MB), it's just easier to read
(printf "vm feature held maxheld barrier limit failcnt\n"; grep privvm /proc/bc/1*/resources|awk '{sub($3,$3*4096/2^20) sub($4,$4*4096/2^20) sub($5,$5*4096/2^20) sub($6,$6*4096/2^20)}1')|column -t
vm feature held maxheld barrier limit failcnt
/proc/bc/101/resources: privvmpages 124.625 321.152 256 272 2
/proc/bc/102/resources: privvmpages 467.98 768.047 650 700 9517
/proc/bc/103/resources: privvmpages 105.957 140.523 256 272 0
/proc/bc/104/resources: privvmpages 219.73 418.945 410 450 0
/proc/bc/105/resources: privvmpages 287.34 323.93 384 403.531 0
/proc/bc/106/resources: privvmpages 118.043 266.004 256 272 0
/proc/bc/108/resources: privvmpages 117.504 329.262 256 272 1
/proc/bc/109/resources: privvmpages 128.086 289.84 384 403.531 0
/proc/bc/110/resources: privvmpages 158.191 271.125 256 272 1
/proc/bc/111/resources: privvmpages 105.43 138.168 256 265 0 |
According to this data 4 of the 11 images had gone over their allocation of RAM. So I tried restarting these and re-running yum update within the problem VEs. Again the update failed and so I needed to increase their allocation of memory. I didn’t want to devote more memory permanently, just a enough temporarily to do the upgrade. So I used this trick to temporarily bump up a VEs allocated memory.
1
2
3
4
5
6
7
8
9
| # increase the RAM by 100MB
vzctl set 101 --privvmpages $((256+100))m:$((272+100))m --save
# ...
# do the upgrade (yum update)
# ...
# decrease the RAM back to the original value
vzctl set 101 --privvmpages 256m:272m --save |
For the remaining 3 VEs that needed additional memory I used these commands to increase their allocations of RAM
1
2
3
4
5
6
7
8
9
| # cmds. to increase RAM by 100MB
vzctl set 102 --privvmpages $((650+100))m:$((700+100))m --save
vzctl set 108 --privvmpages $((256+100))m:$((272+100))m --save
vzctl set 110 --privvmpages $((256+100))m:$((272+100))m --save
# cmds. to decrease
vzctl set 102 --privvmpages 650m:700m --save
vzctl set 108 --privvmpages 256m:272m --save
vzctl set 110 --privvmpages 256m:272m --save |
Issue #2, not enough diskspace for yum to run
The next snag I ran into had to do with a couple of the VEs running out of diskspace. And here’s the commands I used to reconfigure more diskspace.
…. Continue reading → Keeping CentOS 5 OpenVZ images up to Date with Yum »»
slmingol posted this in tips & tricks on September 21st, 2009, @ 10:13 am
Background
I recently saw a post over on Linux Journal that discussed how to glean information about a system’s hard drive, such as its serial number, without having to actually open up the case and physically check it. So I thought I’d take the opportunity to write up a blog post with the specifics of how to do this under Fedora & CentOS, just so I’d have this info handy for future use.
BTW, I was able to accomplish this task several different ways, so this post will cover all the different ways that I could get this info.
Command #1: lshw
This is probably the best tool for getting at a system’s internals. First make sure it’s installed.
For our example you would run the command lshw -class disk:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| % lshw -class disk
*-disk
description: ATA Disk
product: HTS726060M9AT00
vendor: Hitachi
physical id: 0
bus info: scsi@0:0.0.0
logical name: /dev/sda
version: MH4O
serial: MRH403M4GS551Y
size: 55GiB (60GB)
capabilities: partitioned partitioned:dos
configuration: ansiversion=5 signature=cccdcccd
*-cdrom
description: DVD reader
product: UJDA755yDVD/CDRW
vendor: MATSHITA
physical id: 1
bus info: scsi@1:0.0.0
logical name: /dev/cdrom
logical name: /dev/cdrw
logical name: /dev/dvd
logical name: /dev/scd0
logical name: /dev/sr0
version: 1.71
capabilities: removable audio cd-r cd-rw dvd
configuration: ansiversion=5 status=nodisc |
The first section that’s returned is called -disk. Here’s you’ll see the vendor: Hitachi, the product number, HTS726060M9AT00, and my serial number: MRH403M4GS551Y.
Command #2: smartctl
The next tool that would give this type of info is called smartctl. It’s a tool that’s part of the smartmontool package. You may be familiar with the acronym S.M.A.R.T.. The acronym stands for: Self-Monitoring, Analysis, and Reporting Technology. This is a standard that most modern disks have in which vital statistics about a disk drive are provided through a standard API. Here’s how to install it.
1
| yum install smartmontools |
…and once installed you can use the bundled in tool smartctl like so:
…. Continue reading → [one-liner]: Determining a Hard Drive’s Manufaturer Under Fedora 10 & CentOS 5 »»
slmingol posted this in tips & tricks on September 9th, 2009, @ 1:27 am
I’m a vim guy through and through. Always have been. But I’m no zealot. I say you use the tool that does the job. So for example, I’ve used xemacs on occasion, and it definitely has its strengths. But for day to day I’ve always come back to using vim. So when I setup this blog, I knew early on that if I was going to post at any sort of meaningful frequency, I would have to figure out how to do it through vim. Additionally I’ve grown accustom to mark up languages such as markdown & textile, so I knew I’d want to mix this capability in to both my blog & vim, as well.
NOTE: refer to these Wikipedia pages if you’re unfamiliar with vim, xemacs, markdown or textile.
Preliminary Step
Before we get started, make sure that your blog is configured to accept XML-RPC. This is a remote procedure call mechanism that allows external tools to submit posts to your blog. The option is underneath the site admin section of Wordpress. You can get to the option under Settings –> Writing. The option looks like this:
 XML-RPC Option
Getting Started
After googling a bit I came across a plugin for vim called Blogit. The main developers page for Blogit is here, while the primary vim.org plugin page is here. The latest version at the time of this article was 1.3. Installation couldn’t have been simpler.
Installation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| # get into vim's dot directory
% cd ~/.vim
# download Blogit
% wget http://symlink.me/attachments/download/16/blogit-1.3.tar.bz2
# install blogit
% tar jxvf blogit-1.3.tar.bz2
# ~/.vim directory should look similar to this
% tree -A
.
└── plugin
├── blogit.vim
└── mock_vim.py
1 directory, 2 files |
Configuration
The only other thing you need to do to setup the Blogit plugin is to create the following file: ~/.vim/plugin/passwords.vim. In it you’ll need to add 3 pieces of information about your blog. A username & password along with the URL to your blog’s xmlrpc.php file. Here’s an example:
1
2
3
4
| " login credentials for blog
let blogit_username='user1'
let blogit_password='password1'
let blogit_url='http://www.lamolabs.org/blog/xmlrpc.php' |
Blogit’s Interface
…. Continue reading → Managing WordPress Posts with vim »»
Page 1 of 612345»...Last »
|