Showing posts with label archive. Show all posts
Showing posts with label archive. Show all posts

Install Solaris from flash archive

Preamble

This document is created to show how to install Solaris OS from flash archive. This process is helpful in case of need to install many similar machines and/or speedup process of implementation of new system with all required software, patches, applications. Other purpose is to prepare fast recovery of important system(s) in DR plan.


Implementation

1. First step is to create repository for flash archive. For this purpose can be used a local filesystem or NFS share. Be aware that you need enough disk space to holding the archive.
# mkdir -p /export/flash
2. Next we should create flash archive of the system. This can be long process depend of amount of data on the system, speed of disks and processor(s). On average PC system it can take up to 30 minutes (or more)
# flarcreate -n flash_archive_root -c -R / -x /export/flash /export/flash/inst_x86
Full Flash
Checking integrity...
Integrity OK.
Running precreation scripts...
Precreation scripts done.
Determining the size of the archive...
5359636 blocks
The archive will be approximately 1.46GB.
Creating the archive...
5359636 blocks
Archive creation complete.
Running postcreation scripts...
Postcreation scripts done.
Running pre-exit scripts...
Pre-exit scripts done.
3. Let’s check the archive
# flar -i /export/flash/inst_x86
archive_id=3eb5bd4ed799d662b120834f7f4de81e
files_archived_method=cpio
creation_date=20080831081410
creation_master=sol2
content_name=flash_archive_root
creation_node=sol2
creation_hardware_class=i86pc
creation_platform=i86pc
creation_processor=i386
creation_release=5.10
creation_os_name=SunOS
creation_os_version=Generic_127128-11
files_compressed_method=compress
files_archived_size=1574745535
files_unarchived_size=2744133632
content_architectures=i86pc
4. For the purpose of install it’s need to export via NFS the directory, so check if NFS server is started and start if not and export directory
# svcs -va|grep nfs
online         -              8:52:09     45 svc:/network/nfs/cbd:default
online         -              8:52:09     46 svc:/network/nfs/status:default
online         -              8:52:09     47 svc:/network/nfs/mapid:default
online         -              8:52:10     49 svc:/network/nfs/nlockmgr:default
online         -              8:52:43      - svc:/network/nfs/rquota:default
online         -              8:52:43      - svc:/network/nfs/client:default
online         -             12:18:20    115 svc:/network/nfs/server:default 
# share -o ro /export/flash/
5. Then start new system, follow the installation process and at the moment of choose installation media select NFS, then enter the location of archive in form
server:/path/to/directory
and the choose the archive you will use or
server:/path/to/flash/archive
Wait a while and you have freshly installed copy of the system from which we create flash archive


Conclusion

Of course this document show only in brief steps to accomplish the task and do not go in deep in to the details, but give overview of the process. For further information about flash archives, installation process, NFS management, etc. refer to official SUN documentation and related papers.

Tar - the game continue

Sometime, some sysadmins forget one little detail about UNIX tar and make archives with leading slash. This can be helpful when you try to restore fast some files or directories, but in most of the cases is very bad habit. In many cases it's just need to extract somewhere (but not on the original place) file and compare it with the current file. So you have archive with leading slash and want to extract something. Let do it on a little complicated, but safe way:

mkdir -p /tmp/lib
for i in `ldd /usr/bin/tar|awk  '{print $3}'`;
do
cp $i /tmp/lib
done
cp /usr/bin/tar /tmp
mkdir -p /tmp/usr/lib
cp /usr/lib/ld.so.1 /tmp/usr/lib
chroot /tmp ./tar xvf archive.tar


In the man page, I get the idea, (SUN Solaris chroot) was mentioned full list of so libraries, but I am lazy and hate to write. And want to avoid mistakes. BTW in the documentation is not mentioned ld.so library and without this library tar do not want to run :-)

P.S. The script was tested only on Solaris 10, but (depend of format of ldd) will work on other UNIXes and Linux
P.P.S. You can use pax or GNU tar but as they are not a standard in UNIX world I try to make my solution universal

Playing with tar

Every sysadmin know that tar program do not accept wildcards for extract files so if you want to extract only one or few files you should play with construction like this:
 tar xvf archive.tar `tar tvf archive.tar|grep string` 
But on complex requests will be need to do it several times and if archive reside on tape (do not forget from where come the name of utility tar) this can take long time. Instead is much better to deal with files:
tar tvf archive.tar>/tmp/somefilename 
make some filtering on the listing
tar xvf archive.tar `cat /tmp/somefilename` 
P.S. I use cat to make command work independently (almost) of version of tar, UNIX flavour or Linux

Should I trust AI

 Should I trust AI? So far no, sorry.  I tested for the moment (May, 2025) most advanced model for programming and ask very simple question:...