Sunday 30 August 2015

Create Local Repository - Solaris 11.2

Image packaging system(IPS) and important concept from Solaris 11 onwards. I would like to create local repository on the local system by downloading the files from the Oracle website using oracle's automated script.

Download below files and copy to your local Solaris server.
Below are the files copied on my local Solaris server. 

root@solnode1:/var/share/pkg# pwd
/var/share/pkg
root@solnode1:/var/share/pkg# ls -l
total 14373953
-rwx------   1 root     root        5594 Aug 29 20:52 install-repo.ksh
drwxr-xr-x   3 pkg5srv  pkg5srv        7 Aug 30 08:42 repositories
-rw-r--r--   1 root     root     1771800121 Aug 29 15:32 sol-11_2-repo-1of4.zip
-rw-r--r--   1 root     root     1889867782 Aug 29 15:35 sol-11_2-repo-2of4.zip
-rw-r--r--   1 root     root     1902167161 Aug 29 16:46 sol-11_2-repo-3of4.zip
-rw-r--r--   1 root     root     1790358735 Aug 29 16:44 sol-11_2-repo-4of4.zip
-rw-r--r--   1 root     root         227 Aug 29 16:14 sol-11_2-repo-md5sums.txt
root@solnode1:/var/share/pkg#

root@solnode1:/var/share/pkg#./install-repo.ksh -d /var/share/pkg/repositories/ -v -c

The script would compare the checksums of the downloaded files, uncompress and would initiate the repository creation. 

your current publisher would be pointing to "pkg.oracle.com" and it needs to be changed to your local repository. 

root@solnode1:~# pkg publisher
PUBLISHER                   TYPE     STATUS P LOCATION
solaris                     origin   online F http://pkg.oracle.com/solaris/release/
root@solnode1:~#

root@solnode1:~# pkg set-publisher -G '*' -M '*' -g file:///var/share/pkg/repositories solaris
root@solnode1:~#

root@solnode1:~# pkg publisher
PUBLISHER                   TYPE     STATUS P LOCATION
solaris                     origin   online F file:///var/share/pkg/repositories/
root@solnode1:~#

To enable clients to access the local repository via HTTP, enable the application/pkg/server Service Management Facility (SMF) service.

root@solnode1:~# svccfg -s application/pkg/server setprop pkg/inst_root=/var/share/pkg/repositories
root@solnode1:~# 

check does repos work
root@solnode1:~# svcprop -p pkg/inst_root application/pkg/server
/var/share/pkg/repositories
root@solnode1:~#

Reload the pkg.depotd repository service.

root@solnode1:~# svcadm refresh application/pkg/server
root@solnode1:~#

we had successfully created solaris 11.2 local repository.

Saturday 8 August 2015

Contiguous space re-partition - Linux

To recap, root FS has run out of space and data contained on it couldn't be removed or compressed to free up the space. Since there was swap space, so I planned to reclaim from the swap partition without losing the data and would extend the space for root file system. 

Host : susenode2
OS   : SuSE 11 / CentOS / Redhat 
Disk : sda

It could have been easy we could have extended volume using LVM, since our disks are not under LVM, we are here trying to re-create the entire partition without losing data.

Current scenario :

Disk (sda) is been into 3 partitons, of which sda1, sda2 are my data partitions & sda3 swap partition. I would recreate the swap partition and would extend the root file system. It could also be seen that the sector are contiguous between sda2 and sda3 hence I could destroy those two partitions and re-create.

df & fdisk & swap output :

susenode2:~ # df -hT
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/sda2      ext3    13G   12G  570M  96% /
udev           tmpfs  369M  128K  369M   1% /dev
tmpfs          tmpfs  369M     0  369M   0% /dev/shm
/dev/sda1      ext3   1.1G 1015M   18M  99% /application/logs
susenode2:~ #

susenode2:~ # fdisk -l /dev/sda

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cc8af

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048     2265087     1131520   83  Linux
/dev/sda2   *     2265088    31625215    14680064   83  Linux                  <<===  root fs
/dev/sda3        31625216    41943039     5158912   82  Linux swap / Solaris   <<===  swap 
susenode2:~ #

susenode2:~ # swapon -s
Filename                                Type            Size    Used    Priority
/dev/sda3                               partition       5158908 0       -1
susenode2:~ #

Since we are resizing the root file system, we need to get into rescue environment to do so. 
I am using an SuSE DVD or you could also use knoppix and would get into rescue environment and make necessary changes to the partition table. 


I would delete the partition sda2 and sda3 and would recreate the sda2 from the sector which was at the start i..e 2265088 and would end for my required size say 18G which I would add to this file system.

I would later create a new partition for the swap for remaining space. 

snaps are as below :


Once partition are created we need to change the type of the partition to swap for sda3 and since sda2 was bootable, make sure you would toggle boot flag on the partition.


Make sure you now has enough space in the disk where you could resize your root file system and make the swap partition. 


Rescue:~ # mkswap /dev/sda3
Rescue:~ # reboot

After reboot, check your root file system space. It would have been increased and swap space decreased. 

Snap after increasing file system :

susenode2:~ # df -hT
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/sda2      ext3    18G   12G  5.3G  69% /
udev           tmpfs  369M  128K  369M   1% /dev
tmpfs          tmpfs  369M     0  369M   0% /dev/shm
/dev/sda1      ext3   1.1G 1015M   18M  99% /application/logs
susenode2:~ #

susenode2:~ # fdisk -l /dev/sda

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cc8af

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048     2265087     1131520   83  Linux
/dev/sda2   *     2265088    40013823    18874368   83  Linux
/dev/sda3        40013824    41943039      964608   82  Linux swap / Solaris
susenode2:~ #

susenode2:~ # swapon -s
Filename                                Type            Size    Used    Priority
/dev/sda3                               partition       964604  0       -1
susenode2:~ #

Thanks