Saturday, February 19, 2011

pkgtrans - Conversion between FileSystem format and Datastream Packages.

Demo of pkgtrans.
Conversion between FileSystem format and Datastream Packages.

MyServer:/var/tmp#
MyServer:/var/tmp# df -k .
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/md/dsk/d103     6193583 3494049 2637599    57%    /var
MyServer:/var/tmp#

Extracting the package creates it a file system format:

MyServer:/var/tmp# mkdir sudotesting
MyServer:/var/tmp# cd sudotesting
MyServer:/var/tmp/sudotesting# cp ../Mysudo-sol9.SPARC.pkg.tar.gz .
MyServer:/var/tmp/sudotesting# ls
Mysudo-sol9.SPARC.pkg.tar.gz
MyServer:/var/tmp/sudotesting#
MyServer:/var/tmp/sudotesting# gunzip Mysudo-sol9.SPARC.pkg.tar.gz
MyServer:/var/tmp/sudotesting#
MyServer:/var/tmp/sudotesting# ls
Mysudo-sol9.SPARC.pkg.tar
MyServer:/var/tmp/sudotesting#
MyServer:/var/tmp/sudotesting# tar -xvf *.tar
x SFWsudo, 0 bytes, 0 tape blocks
x SFWsudo/archive, 0 bytes, 0 tape blocks
x SFWsudo/archive/none.bz2, 77545 bytes, 152 tape blocks
x SFWsudo/install, 0 bytes, 0 tape blocks
x SFWsudo/install/copyright, 3950 bytes, 8 tape blocks
x SFWsudo/install/depend, 875 bytes, 2 tape blocks
x SFWsudo/install/i.none, 2245 bytes, 5 tape blocks
x SFWsudo/pkginfo, 482 bytes, 1 tape blocks
x SFWsudo/pkgmap, 832 bytes, 2 tape blocks
x SFWsudo/reloc, 0 bytes, 0 tape blocks
x SFWsudo/reloc/sfw, 0 bytes, 0 tape blocks
x SFWsudo/reloc/sfw/bin, 0 bytes, 0 tape blocks
x SFWsudo/reloc/sfw/etc, 0 bytes, 0 tape blocks
x SFWsudo/reloc/sfw/man, 0 bytes, 0 tape blocks
x SFWsudo/reloc/sfw/man/man1m, 0 bytes, 0 tape blocks
x SFWsudo/reloc/sfw/man/man4, 0 bytes, 0 tape blocks
x SFWsudo/reloc/sfw/READMEs, 0 bytes, 0 tape blocks
x SFWsudo/reloc/sfw/sbin, 0 bytes, 0 tape blocks

MyServer:/var/tmp/sudotesting#
MyServer:/var/tmp/sudotesting# ls
Mysudo-sol9.SPARC.pkg.tar  SFWsudo
MyServer:/var/tmp/sudotesting# ls -ltr
total 192
drwxr-xr-x   5 buxus    sys          512 Mar  7  2005 SFWsudo
-rw-r--r--   1 root     other      97280 Feb 15 11:16 Mysudo-sol9.SPARC.pkg.tar

MyServer:/var/tmp/sudotesting#

Use pkgtrans to transfer it to datastream format:

MyServer:/var/tmp/sudotesting# pkgtrans . SFWsudo.pkg SFWsudo
Transferring package instance

MyServer:/var/tmp/sudotesting# ls -ltr
total 370
drwxr-xr-x   5 buxus    sys          512 Mar  7  2005 SFWsudo
-rw-r--r--   1 root     other      97280 Feb 15 11:16 Mysudo-sol9.SPARC.pkg.tar
-rw-r--r--   1 root     other      91136 Feb 15 11:17 SFWsudo.pkg


Reverse transformation from filesystem format to datastream format:

MyServer:/var/tmp/sudotesting# rm -rf SFWsudo
MyServer:/var/tmp/sudotesting#
MyServer:/var/tmp/sudotesting# ls -ltr
total 368
-rw-r--r--   1 root     other      97280 Feb 15 11:16 Mysudo-sol9.SPARC.pkg.tar
-rw-r--r--   1 root     other      91136 Feb 15 11:17 SFWsudo.pkg
MyServer:/var/tmp/sudotesting#

MyServer:/var/tmp/sudotesting# pkgtrans . SFWsudo SFWsudo.pkg        //wrong format command
pkgtrans: ERROR: unable to complete package transfer
    - no packages were selected from

MyServer:/var/tmp/sudotesting# pkgtrans . SFWsudo.pkg
pkgtrans: ERROR: unable to complete package transfer
    - no packages were selected from
MyServer:/var/tmp/sudotesting#
MyServer:/var/tmp/sudotesting# pkgtrans . SFWsud
pkgtrans: ERROR: unable to complete package transfer
    - no packages were selected from
MyServer:/var/tmp/sudotesting#
MyServer:/var/tmp/sudotesting# pkgtrans . . SFWsudo.pkg
pkgtrans: ERROR: unable to complete package transfer
    - source and destination represent the same device
MyServer:/var/tmp/sudotesting#

MyServer:/var/tmp/sudotesting# pkgtrans SFWsudo.pkg . all
Transferring package instance

MyServer:/var/tmp/sudotesting#

MyServer:/var/tmp/sudotesting# ls -ltr
total 370
-rw-r--r--   1 root     other      97280 Feb 15 11:16 Mysudo-sol9.SPARC.pkg.tar
-rw-r--r--   1 root     other      91136 Feb 15 11:17 SFWsudo.pkg
drwxr-xr-x   5 root     other        512 Feb 15 11:22 SFWsudo
MyServer:/var/tmp/sudotesting#
MyServer:/var/tmp/sudotesting#

NFS Server - HPUX - exportfs

Sharing directories from a NFS Server in HP-UX.

View the currently shared dir:
root@MyHP-Server:/Application/files/data/var/in# exportfs -v
/Application/files -rw=Server0:Server1:Server2:Server3:Server4:Server5.bc:Server6

The data is in file /etc/exports

root@ MyHP-Server:/Application/files/data/var/in# cat /etc/exports
/Application/files     -rw=Server0:Server1:Server2:Server3:Server4:Server5:Server6

root@MyHP-Server:/Application/files/data/var/in# vi /etc/exports
 
Edit the file and add another host New-Server-To-Share to share

"/etc/exports" 1 line, 117 characters
/Application/files     -rw=Server0:Server1:Server2:Server3:Server4:Server5:Server6:New-Server-To-Share
~
~
~
~
~
~
"/etc/exports" 1 line, 144 characters
root@MyHP-Server:/Application/files/data/var/in#
 
The newly added host has not yet been recognized

root@MyHP-Server:/Application/files/data/var/in# exportfs -v
/Application/files -rw=Server0:Server1:Server2:Server3:Server4:Server5:Server6
root@MyHP-Server:/Application/files/data/var/in#
 
Run exportfs -a to share the dir to all host again. Now the new host will be recognized.

root@MyHP-Server:/Application/files/data/var/in# exportfs -a
exportfs error: Server1: unknown host
exportfs error: Server2: unknown host
exportfs error: Server3: unknown host
root@MyHP-Server:/Application/files/data/var/in#

root@MyHP-Server:/Application/files/data/var/in# exportfs -v
/Application/files -rw=Server0:Server1:Server2:Server3:Server4:Server5.bc:Server6:New-Server-To-Share
root@MyHP-Server:/Application/files/data/var/in#
root@MyHP-Server:/Application/files/data/var/in#

root@MyHP-Server:/Application/files/data/var/in# cat /etc/xtab
/Application/files -rw= Server0:Server1:Server2:Server3:Server4:Server5.bc:Server6:New-Server-To-Share

Some examples from Man pages and files associated with NFS:

List currently exported directories and files:

           exportfs

Export entries in /etc/exports

           exportfs -a

Unexport all exported files and directories:

           exportfs -ua

Unexport all exported files and directories and print each directory or filename as it is unexported:

           exportfs -uav

Export /usr to the world, ignoring options in /etc/exports:

           exportfs -i /usr

Export /usr/bin and /usr/adm read-only to the world:

           exportfs -i -o ro /usr/bin /usr/adm

Export /usr/bin read-write only to systems polk and vanness:

           exportfs -i -o rw=polk:vanness /usr/bin

Export root access on /usr/adm only to the system named pine, and mount access to both pine and geary:

           exportfs -i -o root=pine, access=pine:geary /usr/adm

FILES associated with nfs:

      /etc/exports        static export information
      /etc/xtab           current state of exported directories
      /etc/netgroup       list of network groups

Friday, February 18, 2011

UFS filesystem creation - Veritas Disk

Creationg a new FileSystme on a disk which is under veritas control but FileSystem to be a UFS filesystem.

(MyServer:/)# mkfs -F vxfs /dev/vx/rdsk/MyZone/MyApplication-2
mkfs: FSType vxfs not installed in the kernel


//Check the similar fs(from same volume) to find the FSType
(MyServer:/)# fstyp /dev/vx/dsk/MyZone/MyApplication
Ufs


//wrong syntax as size should be specified at the end
(MyServer:/)# mkfs -F ufs /dev/vx/rdsk/MyZone/MyApplication-2
size not specified
ufs usage: mkfs [-F FSType] [-V] [-m] [-o options] special size(sectors) \
[nsect ntrack bsize fragsize cpg free rps nbpi opt apc gap nrpos maxcontig mtb]
 -m : dump fs cmd line used to make this partition
 -V :print this command line and return
 -o :ufs options: :nsect=32,ntrack=16,bsize=8192,fragsize=1024
 -o :ufs options: :cgsize=0,free=0,rps=60,nbpi=2048,opt=t
 -o :ufs options: :apc=0,gap=0,nrpos=0,maxcontig=0
 -o :ufs options: :mtb=n,calcsb,calcbinsb
NOTE that all -o suboptions: must be separated only by commas so as to
be parsed as a single argument


Size calculation:
The request is for a 3gb filesystem
The file size should be given in blocks of 512 bytes for the mkfs command

3gb = ( * 1024 * 1024 * 1024) / 512 = 6291456 [Reverse = (6291456 * 512) / 1024 / 1024 / 1024 = 3]

(MyServer:/)# mkfs -F ufs /dev/vx/rdsk/MyZone/MyApplication-2 6291456
/dev/vx/rdsk/MyZone/MyApplication-2:       6291456 sectors in 3072 cylinders of 32 tracks, 64 sectors
        3072.0MB in 192 cyl groups (16 c/g, 16.00MB/g, 7680 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 32864, 65696, 98528, 131360, 164192, 197024, 229856, 262688, 295520,
 5965216, 5998048, 6030880, 6063712, 6096544, 6129376, 6162208, 6195040,
 6227872, 6260704

(MyServer:/)#

(MyServer:/)# mkdir /zones/MyZone/MyApplication-2
(MyServer:/)#
(MyServer:/)# mount -F ufs /dev/vx/dsk/MyZone/MyApplication-2 /zones/MyZone/MyApplication-2
(MyServer:/)#

(MyServer:/)# df -h /zones/MyZone/MyApplication-2
Filesystem             size   used  avail capacity  Mounted on
/dev/vx/dsk/MyZone/MyApplication-2
                       2.8G   3.0M   2.5G     1%    /zones/MyZone/MyApplication-2

(MyServer:/)#
(MyServer:/)#

Restricting users from changing ownership

The default for Unix systems is that users can't change the ownership of files. 
To enable "chown" on files for non-root users, rstchown parameter has to be adapted in /etc/system file.

The setting of 1 would not allow non-root users to use chown.
set rstchown=1

The setting of 0 would allow non-root users to use chown.
set rstchown = 0

root@MyServer # vi /etc/system
"/etc/system" 94 lines, 2153 characters
*ident  "@(#)system     1.18    97/06/27 SMI" /* SVR4 1.5 */
*
* SYSTEM SPECIFICATION FILE
*
* moddir:
~



set noexec_user_stack=1
set rstchown = 0
~
~
~
"/etc/system" 95 lines, 2170 characters
root@MyServer #