skip to main |
skip to sidebar
Auto wake-up and shutdown for the OpenSolaris ZFS NAS Now that you have set up your NAS, here are some tips to save power and switch it on/off remotely.
First, lets change the default wait time for boot that grub takes. From the console, run:
dp@zfs.local:~# bootadm list-menu
The location for the active GRUB menu is: /boot/grub/menu.lst
bootadm: no matching entry found
dp@zfs.local:~# cat /boot/grub/menu.lst
# For zfs root, menu.lst has moved to /rpool/boot/grub/menu.lst.
Interesting. We can use bootadm again to change the timeout or directly edit /rpool/boot/grub/menu.lst. I did the second. Change the timeout parameter (default 30 seconds) to whatever you prefer - I set it to 5 seconds, 0 will boot without querying. First three lines of my file are:
splashimage /boot/grub/splash.xpm.gz
timeout 5
default 0
We can auto shutdown the NAS box for the night and save some power. Use cron to do this.
dp@zfs.local:~# crontab -e
and add the following line to the end of the file.
30 23 * * * shutdown -y -i 5 -g 120 "System coming down for the night"
The 30 23 * * * is minutes, hours, day, week, month : so that statment means at 23:30 hours every day of the week, every week of the month, every month of the year (simply put, every day) shutdown the machine.
You can ofcourse execute the shutdown command from a Putty console on your Windows machine to shutdown the NAS box whenever you want. The crontab entry ensures that the machine is shutdown, if you forget to do it manually.
To wake up the machine automatically, you will need to download one of the many wake on lan freeware from the web. I use this. You can download it here.
Copy this to your windows system directory. C:\Windows\System32 is preferred. We get the mac address of your ZFS NAS box in the next step below.
dp@zfs.local:~# ifconfig -a
lo0: flags=2001000849 mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
rge0: flags=201000843 mtu 1500 index 2
inet 192.168.1.10 netmask ffffff00 broadcast 192.168.1.255
ether 0:1e:8c:15:94:a3
lo0: flags=2002000849 mtu 8252 index 1
inet6 ::1/128
The number after the ether 0:1e:8c:15:94:a3 -> that is my mac address for the ethernet card.
On the windows machine, create a wakeup.bat file in the Windows\System32 directory with the following (Make sure to change the mac address and ip address of the NAS box to what is appropriate for you.
echo off
echo Waking up ZFS server
c:\wol 001e8c1594d3
echo Sent Wake up Packet. Press Control-C to stop ping.
ping -t 192.168.1.10
Create a shortcut to this batch file on your windows Desktop, so you have it handy.
So now you have a NAS that you can fireup when you want and will automatically shutdown.
ZFS NAS for Home : A Mini Howto based on OpenSolaris 2008.5
One of my FreeNAS mirror disks packed up 2 weeks ago. It served me well for over 3 years. If you are looking to back up your home media and laptop files, boot from a small thumb drive and get reasonable support from the community, this FreeBSD based product is a good bet.
I decided to attempt an OpenSolaris NAS instead, motivated by Simons' Blogs here - main reason : ZFS. ZFS is the mother of all file systems, now open sourced by Sun. A dated summary here will give you a good idea.
Steps involved:
1. Check the Hardware compatibility list and ensure you have one of the motherboards listed there. This is going to save you huge amount of time, since if the board is not listed there, chances are high that you will have driver problems. You will also need 2 Large Disks (SATA/IDE) for storing data and one small 20 GB is more than enough or a GB Flash Drive for the operating system.
2. Download OpenSolaris from here. My version is 2005.8
3. Make a CD with the ISO. Need a tool for Windows? Go here
4. Boot with the LiveCD and follow the install process - this is going to take a while. Install on to a small disk or the flash drive. Here is the official install help.
5. Login as the user you created (not root), once the system boots up into the great looking desktop. Btw You will have to su, to become root every time. This is Role Based Access Control RBAC.
6. Do a sanity check on the drivers being ok ; go to System->Administration-> Device Driver Utility Should show Driver Problems : 0
7. At this point I needed to assign a fixed ip address for my box; that needs the following two commands to be executed. (Disable Network Auto Magic nwam and enable the physical network adapter). Get a console from Applications->System Tools -> Terminal.
$ su
Password:
#disable svc:/network/physical:nwam
#enable svc:/network/physical:default
8. Now you can go to System->Administration->Network->Ethernet connection->Properties and fill in the static IP address you want to assign to your NAS.
9. I did not have internet access now. To get to the net edit /etc/resolv.conf (as su) and add the following 2 lines (or whatever is your preferred name servers) and save the file. The following name servers are opendns servers, they are great to keep your home network and kids safe.
nameserver 208.67.222.222
nameserver 208.67.220.220
You also need to edit /etc/nsswitch.conf, look for the line
hosts: files
and change it to
hosts: dns files
Once these two changes are done, you should be able to get on to the internet.
10. Go now to System->Administration->Package Manager and Search for smb and check all except the SUNWsmba and click the Install/Update button. This is to install CIFS so that Windows users can see the shares. Do not be tempted to Update All (See this link on why not), since this will kill your system - which did happen to me. More on recovering from that later.
11. Follow Simon's thread here from the Configuration section on, to set up the zpool and zfs shares. I did not edit the auto_master and auto_smb that the blog suggested.
12. Populate your data now. Once finished, take a snapshot of your stable environment by getting a console and issuing the command
#beadm create NAS-dd-mm-yy
This will ensure that you can always boot into an environement that you know is functional.
13. Just to make sure that you dont get into trouble with the Image Packaging System IPS, follow the instructions here to update package manager.
14. If you did break the system like I did with an Update All from the Package Manager GUI and rebooted to find their system dead; here is what can be done. (Recovery using Opensolaris Live CD)
a. Boot again from live CD and get into console. The username/password is jack/jack ; become su (password is opensolaris)
b. Issue following commands
#zpool import -f rpool
#zfs list
c, See if you can recognize any of the system snapshots that is a good enough starting point to recover. I had none, so I rolled back to the original install time snapshot by:
#zfs rollback -f rpool/ROOT/opensolaris@install
If you had a snapshot opensolaris@NAS-21-July-08 as recommended here, you can roll back to that and all will be well.
d. However if you rolled back to install time stuff, you need to redo steps 7, 8, 9 and 10; edit /etc/pam.conf and add the line as in Simons blog, create new users who were created post install and do a passwd again for all users to renew the passwords and reboot the system.
e. Once it comes up again, import the zpool that is the data pool (tank in my case);
#zpool import -f tank
f. and join the workgroup
#smbadm join -w WORKGROUP
You should be up and running now: Do not forget to execute the beadm given in step 12, so that you have a nice place to roll back from and not just the live CD install time snapshot!