Monday, May 16, 2016

Create new Swap file

The quicker way of getting the same file is by using the fallocate program. This command creates a file of a preallocated size instantly, without actually having to write dummy contents.
We can create a 4 Gigabyte file by typing:
sudo fallocate -l 4G /swapfile
The prompt will be returned to you almost immediately. We can verify that the correct amount of space was reserved by typing:
ls -lh /swapfile
-rw-r--r-- 1 root root 4.0G Apr 28 17:19 /swapfile
As you can see, our file is created with the correct amount of space set aside.

Enabling the Swap File

Right now, our file is created, but our system does not know that this is supposed to be used for swap. We need to tell our system to format this file as swap and then enable it.
Before we do that though, we need to adjust the permissions on our file so that it isn't readable by anyone besides root. Allowing other users to read or write to this file would be a huge security risk. We can lock down the permissions by typing:
sudo chmod 600 /swapfile
Verify that the file has the correct permissions by typing:
ls -lh /swapfile
-rw------- 1 root root 4.0G Apr 28 17:19 /swapfile
As you can see, only the columns for the root user have the read and write flags enabled.
Now that our file is more secure, we can tell our system to set up the swap space by typing:
sudo mkswap /swapfile
Setting up swapspace version 1, size = 4194300 KiB
no label, UUID=e2f1e9cf-c0a9-4ed4-b8ab-714b8a7d6944
Our file is now ready to be used as a swap space. We can enable this by typing:
sudo swapon /swapfile
We can verify that the procedure was successful by checking whether our system reports swap space now:
sudo swapon -s
Filename                Type        Size    Used    Priority
/swapfile               file        4194300 0       -1
We have a new swap file here. We can use the free utility again to corroborate our findings:
free -m
             total       used       free     shared    buffers     cached
Mem:          3953        101       3851          0          5         30
-/+ buffers/cache:         66       3887
Swap:         4095          0       4095
Our swap has been set up successfully and our operating system will begin to use it as necessary.

Make the Swap File Permanent

We have our swap file enabled, but when we reboot, the server will not automatically enable the file. We can change that though by modifying the fstab file.
Edit the file with root privileges in your text editor:
sudo nano /etc/fstab
At the bottom of the file, you need to add a line that will tell the operating system to automatically use the file you created:
/swapfile   none    swap    sw    0   0
Save and close the file when you are finished.

Tuesday, September 15, 2015

Adding a Hard Drive to Solaris 10 (Copas http://utahsysadmin.com/2008/02/07/adding-a-hard-drive-to-solaris-10)

Here’s how you would add a hard drive to Solaris 10, including the format, fdisk, partition, and then creation of the file system. Of course, you first need to actually add the hard drive physically to the machine, I’m not going to cover that – if you don’t know how to do that then the rest of the information isn’t going to help!
If you installed a drive through VMWare while the VM is running, you will need Solaris to recognize the new drive. In this case, run devfsadm, otherwise boot your system and Solaris should recognize the new drive.
First, here’s the original drives (c0t0d0 & c1t0d0):
# ls /dev/rdsk/*s0
/dev/rdsk/c0t0d0s0 /dev/rdsk/c1t0d0s0
Have Solaris check for new hardware:
# devfsadm
Now you can see there is a new disk on another bus (c1t1d0):
# ls /dev/rdsk/*s0
/dev/rdsk/c0t0d0s0 /dev/rdsk/c1t0d0s0 /dev/rdsk/c1t1d0s0
Next, we want to format the drive (which includes creating the partitions):
# format
Searching for disks…done
AVAILABLE DISK SELECTIONS:
0. c1t0d0
/pci@0,0/pci1000,30@10/sd@0,0
1. c1t1d0
/pci@0,0/pci1000,30@10/sd@1,0
Specify disk (enter its number):
Type “1″, the option for the new drive and hit “enter”. Depending on the type of disk it may be preformatted:
selecting c1t1d0
[disk formatted]
If your drive is not formatted, type format at the format prompt to low level format your hard drive. Next, we need to use fdisk to create the partitions, type “y” to create the default Solaris partition:
format> fdisk
No fdisk table exists. The default partition for the disk is:
a 100% “SOLARIS System” partition
Type “y” to accept the default partition, otherwise type “n” to edit the
partition table.
y
Next enter the partition menu, by typing partition:
format> partition
You can print out the current partitioning first if you like:
partition> print
Current partition table (original):
Total disk cylinders available: 1020 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 unassigned wm 0 0 (0/0/0) 0
1 unassigned wm 0 0 (0/0/0) 0
2 backup wu 0 – 1020 1.99GB (1021/0/0) 4182016
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 unassigned wm 0 0 (0/0/0) 0
8 boot wu 0 – 0 2.00MB (1/0/0) 4096
9 unassigned wm 0 0 (0/0/0) 0
In this case, I just want to create one large partition for some extra storage so I will allocate all I can to partition 0. Note that partition 2 is used to reference the entire drive and is not a usable partition. To modify a given partition, just enter the number of the partition at the partition prompt:
partition> 0
Part Tag Flag Cylinders Size Blocks
0 unassigned wm 0 0 (0/0/0) 0
Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:
Enter new starting cyl[0]: 1
Enter partition size[0b, 0c, 1e, 0.00mb, 0.00gb]: 1019c
And now to print the partition table again you can see what has changed:
partition> print
Current partition table (unnamed):
Total disk cylinders available: 1020 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 unassigned wm 1 – 1019 1.99GB (1019/0/0) 4173824
1 unassigned wm 0 0 (0/0/0) 0
2 backup wu 0 – 1020 1.99GB (1021/0/0) 4182016
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 unassigned wm 0 0 (0/0/0) 0
8 boot wu 0 – 0 2.00MB (1/0/0) 4096
9 unassigned wm 0 0 (0/0/0) 0
Save your changes by writing the label to the disk:
partition> label
Ready to label disk, continue? y
Quit out of the partition prompt, and then the format prompt, which takes you back to the command prompt:
partition> quit
format> quit
#
Now we are ready to create a file system on this new partition (in this case UFS).
# newfs /dev/rdsk/c1t1d0s0
newfs: construct a new file system /dev/rdsk/c1t1d0s0: (y/n)? y
/dev/rdsk/c1t1d0s0: 4173824 sectors in 1019 cylinders of 128 tracks, 32 sectors
2038.0MB in 45 cyl groups (23 c/g, 46.00MB/g, 11264 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 94272, 188512, 282752, 376992, 471232, 565472, 659712, 753952, 848192,
3298432, 3392672, 3486912, 3581152, 3675392, 3769632, 3863872, 3958112,
4052352, 4146592
Make sure that the file system is clean:
# fsck /dev/rdsk/c1t1d0s0
** /dev/rdsk/c1t1d0s0
** Last Mounted on
** Phase 1 – Check Blocks and Sizes
** Phase 2 – Check Pathnames
** Phase 3a – Check Connectivity
** Phase 3b – Verify Shadows/ACLs
** Phase 4 – Check Reference Counts
** Phase 5 – Check Cylinder Groups
2 files, 9 used, 2020758 free (14 frags, 252593 blocks, 0.0% fragmentation)
Next, add the proper line to /etc/vfstab:
/dev/dsk/c1t1d0s0 /dev/rdsk/c1t1d0s0 /data ufs 2 yes -
And then mount the partition. In this case, I’m making a /data partition:
# mkdir /data
# mount /data
# df -h /data
Filesystem size used avail capacity Mounted on
/dev/dsk/c1t1d0s0 1.9G 2.0M 1.9G 1% /data

Monday, June 01, 2015

OpenKM 5.1.9 with PostgreSQL 9.3.7

Step:
1. ubuntu 14.04
2. Postgresql9.3.7 > sudo apt-get install postgresql-9.3
3. install jdbc Driver > sudo apt-get install libpostgresql-jdbc-java
4. install Openkm 5.1.9
5. copy file postgresql-jdbc4-9.2.jar > cp /usr/share/java/postgresql-jdbc4-9.2.jar $JBOSS_HOME/server/default/lib/
6 follow this link http://wiki.openkm.com/index.php/PostgreSQL_-_OpenKM_5.0
note: don't forget to create database