OpenSolaris – Manual Network DNS issue

If you have tried to setup a manual IP on your opensolaris box you may find that DNS is not working as you would expect in some cases. nslookup resolves the name to an ip, but pinging doesnt make it to the box…

How to fix;

Edit your /etc/nsswitch.conf file and add the word “dns to the hosts and ipnodes lines
If you make a backup of /etc/nsswitch.conf you can also just copy /etc/nsswitch.dns over it…

cp /etc/nsswitch.dns /etc/nsswitch.conf

You may also want to check that auto-magic mode has been disabled when setting up your networking manually;

svcs -a | grep nwam

If it is enabled type;

svcadm disable svc:/network/physical:nwam

ZFS – Creating snapshots

There is some funky ways of modifying the default “time slider” services to do the work for you, but i like a bit more hands on. Generally so i know what is happening in the background, but the time slider can be sometimes overkill creating snapshots every 15 mins if not configured properly.

On a side note i’ve yet to get my head around the SMF stuff properly… Anyhow onto creating snapshots.

I”ve decided to snapshot both my unprotected and protected zpools.

I’ve created three scripts,this is what my snapdaily.sh script looks like ;

zfs destroy -r protected@daily

zfs destroy -r unprotected@daily

zfs snapshot -r protected@daily

zfs snapshot -r unprotected@daily

echo “Daily ZFS snapshot done” – output saved as part of the crontab job

The other two are similar, but weekly and monthly.  The name of the snapshot is after the @ symbol as above. the -r switch is recursive, so all zfs file systems beneath the named zfs also have snapshots created.

next I’ve saved this script and added it to crontab (as root since its zfs commands which are usually restricted);

su – enter password, you are now root.

crontab -e – edit roots crontab file (use vi to insert the following line)

0 5 * * * /protected/snapdaily.sh – this will run every day at 5am.

Run the script first to see if it works, then check with this command;

zfs list -t snapshot – you should see the above snapshots.

Repeat for weekly / monthly as above…

I have disabled all the automatic snapshots….

svcs -a | grep “snapshot” – should show you all the zfs snapshot services

svcadm disable svc:/system/filesystem/zfs/auto-snapshot:daily – etc, will disable these snapshots.

You can also turn off time slider via the GUI if you have turned it on.

Linux – crontab

Time to schedule some tasks!

First you need to make sure your in the /etc/cron.d/cron.allow file. If you are not SU to root and add yourself into it.

Now to create your new crontab file;

crontab -e

You are in vi in your newly created crontab file (note if you do not have access to do this it will say so)

Now, i’m no expert at using vi, but if you press i you will go into insert mode. Do this, then type the cron job details. A typical cron job will look like this

0 4 * * * /export/home/user/backup.sh

so there are five slots before the command you want to run. They are: min, hour, day, month, day-week. So my example above will run at 4am every day. See below for more detail.

once you have entered the line press ESC then type :wq to save and quit.

To confirm the job has been saved successfully in cron type this command;

crontab -l  this will show you your current scheduled tasks, it should output the above job.

In OpenSolaris the crontab files are located at /var/spool/cron/crontabs/ they are named after the specific user. Sometimes its easier to go there than to use vi, but make sure your permissions are all set correctly before editing any system files.

In some distros there are folders like /etc/cron.daily/ which run any scripts inside them on a schedule matching the folder name.

This is a bit more on the format of the 5 timings within the crontab file;

*     *   *   *    *  command to be executed

|     |     |     |     |
|     |     |     |     +—– day of week (0 – 6) (Sunday=0)
|     |     |     +——- month (1 – 12)
|     |     +——— day of month (1 – 31)
|     +———– hour (0 – 23)
+————- min (0 – 59)

Update

@reboot is also another very handy cron modifier. I use the following quite a lot…
@reboot /bin/sleep 600 ; /path/to/your/your_program@reboot /bin/sleep 600 ; /path/to/your/your_program

ZFS – Error 16 : Inconsistent filesystem structure

Oh no. I’ve managed to get this error before. And it was right after i applied compression to the rpool zfs filesystem. Upon the next reboot i was greeted with this error message;

Error 16 : Inconsistent filesystem structure

For me it was a show stopper and i had to go into recovery. So i’ve learnt my lesson – Not to touch the rpool zpool.

I was lucky enough to have put my data within a zfs filesystem (rpool/virtual) i created within the default rpool zpool.  I use this spot for my VirtualBox virtual machines.

Recovery for my rpool/virtual zfs filesystem;

  1. Boot the live cd
  2. open terminal, type SU, enter default password as of 2008.11 “opensolaris
  3. zpool import rpool – brings rpool and associated zfs filesystems back online
  4. type nautalis &, copy data from rpool/virtual to another drive (i mounted another disk by also importing another zpool – zpool import will list available zpools)
  5. zpool export rpool, then re-run the installation program. Note: you need to dismount rpool or the install will fail and stop.

Worked for me, usual disclaimer though. Most Guys Want To Get Bigger Muscles, how to get bigger muscles