mrabas
Contributor
Contributor

Files on ESXi deleted after each reboot

Is there a place to save files (scripts/logs) on an ESXi 4.1 server that won't get blown away when the box reboots?  Specifically, I want to add a cronjob that calls a shell script which outputs to a log.  Is this possible?

Thanks.

Tags (1)
0 Kudos
12 Replies
DSTAVERT
Immortal
Immortal

You can have the logs written to a different location or to a syslog server.

Syslog
http://kb.vmware.com/kb/1016621
http://kb.vmware.com/kb/1019102

-- David -- VMware Communities Moderator
0 Kudos
DSTAVERT
Immortal
Immortal

The benefits to a syslog server are that you can filter and store your logs using things like date or host. I would store scripts on a datastore. If the datastore is shared and visible on all your hosts you only need to manage one set.

-- David -- VMware Communities Moderator
bulletprooffool
Champion
Champion

You could output to any of your datastores - these are mapped to /vmfs/volumes/<datastore>

One day I will virtualise myself . . .
Generious
Enthusiast
Enthusiast

+1 on output to datastores or if you have a syslog server or a kiwi server sitting out on the lan push it to the syslog or else use the vma.

0 Kudos
mrabas
Contributor
Contributor

Thanks for the replies.  I wish the datastore folder kept the actual name of the datastore instead of a random string of characters, for example:

/vmfs/volumes/4df8cbb2-a29616d2-ec2f-001517eaf6b5

I hacked around the cronjob problem by using rc.local.  Apparently, changes to rc.local will survive a reboot.  I added the following to rc.local and rebooted the server.

echo '0,10,20,30,40,50 * * * * /vmfs/volumes/4df8cbb2-a29616d2-ec2f-001517eaf6b5/somescript.sh' >> /var/spool/cron/crontabs/root
/bin/busybox crond -b
0 Kudos
DSTAVERT
Immortal
Immortal

You can use the name that you use to identify the datastore as well as the 4df8cbb2-a29616d2-ec2f-001517eaf6b5. ESXi uses that random number but creates a link to the name that you use. Since you can change the name ESXi will always use the random number but changes the name of the link.

-- David -- VMware Communities Moderator
0 Kudos
budbeacham
Contributor
Contributor

It appears nobody answered the main question.  I have the same problem.  I create scripts on 5.0 in /sbin, and they are gone after the box reboots.  First, why are they disappearing, and second, how do we fix this so that they remain after reboot?  Thank you.

0 Kudos
snowmizer
Enthusiast
Enthusiast

I also had this happen on vSphere 5. Had a python script that worked in a folder I created and when the server rebooted the script and the folder were gone. VERY frustrating when this happened because now I have to redo my script.

Anyone have a solution?

Thanks.

0 Kudos
Josh26
Virtuoso
Virtuoso

budbeacham wrote:

It appears nobody answered the main question.  I have the same problem.  I create scripts on 5.0 in /sbin, and they are gone after the box reboots.  First, why are they disappearing, and second, how do we fix this so that they remain after reboot?  Thank you.

The main question was "is there a place to store scripts" and the answer is "yes, on a datastore".

Your partition layout is decompressed to a ramdisk each bootup as part of ESXi's "thin" hypervisor. The design goal here is to ensure quality operation off flash drives etc, and ensures significantly higher reliability than traditional systems.

In general, anything you are scripting yourself and leaving on an ESXi installation probably shouldn't be there.

0 Kudos
snowmizer
Enthusiast
Enthusiast

As a general rule I don't script anything on ESXi. What I was doing was testing a kickstart script to build our ESXi5 environment on a VM Workstation environment on my laptop. Part of the script included the creation of a python script to add the ESXi server to AD. That piece wasn't working so I was using the python script locally on the ESXi host to get it working before including it in the kickstart script.

Problem was everytime I shut down my laptop the script would disappear so all my work was gone. I did save it on a datastore as recommended in this post but I was curious if there was something else that needed to be configured or if it was just because I was logged into root and couldn't create a folder and script in the root folder.

Thanks.

0 Kudos
DSTAVERT
Immortal
Immortal

When an ESXi host is started the ESXi software is expanded and loads into a RAM disk. When you log in you are loging into the RAM disk and not to the physical disk. Some files (eg rc.local) and the configuration are backed up once an hour and restored on restart to a fresh RAM disk. Anything not included in the backup is lost simply because the RAM disk is just discarded as part of the reboot. You can use the /etc/rc.local script to restore a file or files from a datastore or create an oem.tgz file that contains the files you want expanded etc at boot time

-- David -- VMware Communities Moderator
0 Kudos
snowmizer
Enthusiast
Enthusiast

Thanks for the information and suggestion. Right now it's not critical that I get this to work as the script was not really going to permanently reside on the ESXi host. I will keep this solution in mind though if we ever do need to save scripts to a host.

Thanks again.

0 Kudos