How To Change COS Memory in a Kickstart Script


I got an email from an old friend earlier today asking me how to change ESX4 default COS memory to something else, for instance 800MB, and within a KickStart script!
When you do the change manually through the vCenter client, two files are modified in the background: /etc/vmware/ESX.CONF and /boot/grub/GRUB.CONF

To modify them whilst deploying ESX4 with a KS script, there is a great tool for that called SED (stream editor). It’s an editor used, not interactively on text files (like vi or emacs), but on streams. This allows it to transform text input from a pipe or the command line or a file (if it is piped to sed or given as an argument to sed).

Here is the code to include in your KS script:

#First we need to back up original files:
mv -f /etc/vmware/esx.conf /etc/vmware/esx.conf.orig
mv -f /boot/grub/grub.conf /boot/grub/grub.conf.orig

#Then we can edit the files:
sed -e ’s/boot\/memSize = \”272\”/boot\/memSize = \”800\”/g’ /etc/vmware/esx.conf.orig >> /etc/vmware/esx.conf
sed -e ’s/uppermem 277504/uppermem 819200/g’ -e ’s/mem=272M/mem=800M/g’ /boot/grub/grub.conf.orig >> /boot/grub/grub.conf

So basically SED searches for a certain strings; 272 and 277504, then replaces them with new values; 800 and 819200 et voila.

Happy KS scripting!

Advertisements

About PiroNet

Didier Pironet is an independent blogger and freelancer with +15 years of IT industry experience. Didier is also a former VMware inc. employee where he specialised in Datacenter and Cloud Infrastructure products as well as Infrastructure, Operations and IT Business Management products. Didier is passionate about technologies and he is found to be a creative and a visionary thinker, expressing with passion and excitement, hopefully inspiring and enrolling people to innovation and change.
This entry was posted in Uncategorized. Bookmark the permalink.

9 Responses to How To Change COS Memory in a Kickstart Script

  1. afokkema says:

    you can also use the following commands:

    #############
    # Configure Service Console Memory to 800MB
    #############
    /usr/bin/vmware-vim-cmd /hostsvc/memoryinfo 838860800
    /usr/sbin/esxcfg-boot -b
    /usr/sbin/esxcfg-boot -t

    More ks scripting tips can be found here: http://ict-freak.nl/2010/03/23/vsphere-unattended-esx4-installation-with-a-ks-cfg-file/

  2. deinoscloud says:

    Thx for your comment afokkema. The link to your blog post is full of very useful information :O

  3. Bas says:

    This doesn’t work for all ESX hosts. The default cos memory size is variable and based on the ESX host memory size.
    In those cases sed will not find the ‘272’ value.
    I prefer Arne fokkemas method it can be used for all ESX hosts with different ESX host memory sizes.

    • deinoscloud says:

      Hi Bas, indeed the ‘vim-cmd’ is a more elegant way to achieve our goal. Thx for commenting.

  4. Olu says:

    I think I agreed with Bas, tried the script with “272” value and didn’t work, though the other didn’t work as well!
    Used on blade 680C and DL580G5

    Thanks

    This is what I used
    mv -f /etc/vmware/esx.conf /etc/vmware/esx.conf.orig
    sed -e ‘s/boot\/memSize = \”272\”/boot\/memSize = \”800\”/g’ /etc/vmware/esx.conf.orig >> /etc/vmware/esx.conf
    mv -f /boot/grub/grub.conf /boot/grub/grub.conf.orig
    sed -e ‘s/uppermem 277504/uppermem 819200/g’ -e ‘s/mem=272M/mem=800M/g’ /boot/grub/grub.conf.orig >> /boot/grub/grub.conf

    Also why is this different from each other
    First Script: /uppermem 819200

    second script: /usr/bin/vmware-vim-cmd /hostsvc/memoryinfo 838860800

  5. Olu says:

    Hey Guys,

    I re-run the scripts moving afokkema’s script to the bootom of my scripts see below: after the ESM/Management it works!

    # Set the nics for ESM/Management
    esxcfg-vswitch -L vmnic9 vSwitch3
    esxcfg-vswitch -L vmnic5 vSwitch3
    service mgmt-vmware restart
    sleep 20

    # Service Console memory. Increase to max. 800MB
    /usr/bin/vmware-vim-cmd /hostsvc/memoryinfo 838860800
    /usr/sbin/esxcfg-boot -b
    /usr/sbin/esxcfg-boot -t

    Checking the console value, I got 800.0MB Good job!

    Many thanks to you guys especially My main Man Didier!

    Cheers

    Olu

    • deinoscloud says:

      Hi Olu, good thing it works now! As you can see the VMware Community is very helpful. Thx to afokkema and Bas!

  6. Pingback: Tweets that mention How To Change COS Memory in a Kickstart Script « DeinosCloud -- Topsy.com

  7. HMar says:

    This works for any ESX4 box; even in post section (which saves a reboot in my case):

    sed -i ‘s/^.*memSize.*$/\/boot\/memSize = “800”/g’ /etc/vmware/esx.conf
    sed -i ‘s/uppermem.*$/uppermem 819200/g’ /boot/grub/grub.conf
    sed -i ‘s/mem=.*M/mem=800M/g’ /boot/grub/grub.conf

    Cheerz,

    H.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s