Rocking ZFS: Recovering from a pkg install gone wrong
I’ve been using OpenSolaris 2008.05 at work since it was made available. I use it as my primary OS on my work laptop (an HP Compaq 6910p My wife refers to this laptop as “the ugliest laptop in the world.” Compared with the Apple products she’s used to working on, the HP is not very attractive.) From the beginning, I’ve had issues installing/updating packages with the new IPS packaging system. I’m not dissing IPS. I just ran into a lot of issues trying to run pkg install and pkg image-update. Other people have reported similar issues with timeouts and such. Anyway, in a recent attempt to update my version of pkg, I managed to hose up my system. Having so much trouble at the command line with pkg, I decided to try out the Package Manager GUI. It allowed me to just select the latest version of pkg and install it. Everything processed successfully. I was excited! I closed the Package Manager GUI and went to the command line to try out my new and improved version of pkg. It didn’t work. Even worse, I started having issues with ls and every other command I tried. Core dumps were running wild on “the ugliest laptop in the world.” From another machine, I went to google and started searching to see if other people had encountered similar issues. I found one post that lead me to believe I had “updated too much.” I couldn’t find any posts that described how to recover from this. Determined not to give up on OpenSolaris, I started trying to get my laptop back in order. I didn’t want to lose my home directory. I have tons of valuable code snippets, settings, documents, and huge subversion checkouts of various projects and branches of those projects (about 80GB of data total). So, I’m including the steps I followed to get my laptop running again (along with all of the data in my home folder) below. There may be a better way to do this, but this worked for me.
Step #1: Boot from an OpenSolaris Live CD Boot up with an OpenSolaris CD. We’re going to use the live CD to help us backup the home directory. Step #2: Backup your home folder Open up a terminal and execute the command:
pfexec zpool import -f -R /tmp/rpool rpoolThen take a snapshot of your important data:
pfexec zfs snapshot rpool/export/home@pre-reinstallI didn’t have an external drive with enough free storage space, so I shipped the backup over to another machine via ssh:
pfexec zfs send rpool/export/home@pre-reinstall | ssh user@myhost.com " \
cat > ~/homedir.snapshot"
Step #3: Use the OpenSolaris Live CD to do a Full install of OpenSolaris
With my home directory safely backed up, I wiped the machine and did a reinstall of OpenSolaris.
Step #4: Boot into single user mode (login as root)
ssh user@myhost.com "cat ~/homedir.snapshot" | \ pfexec zfs recv -F rpool/export/homeYour home directory should be ready to go now. Reboot and enjoy.
Update: I recently used pfexec pkg image-update to update my 2008.05 installation to 2008.11. OpenSolaris 2008.11 is awesome! I’m loving the Time Slider functionality. The pkg image-update worked flawlessly. My upgrade was a complete success. None of my tools or applications were broken during the upgrade. The folks working on OpenSolaris have really been putting in some hard work to resolve a lot of the early issues that I experienced.






Comments