MRKAVANA (mrkavana@gmail.com) - www.facebook.com/kavanathai
Showing posts with label disk. Show all posts
Showing posts with label disk. Show all posts

Oct 12, 2011

Mount SAN's Partition over Fiber cable for Linux

multipath -ll
fdisk -l
echo "1" > /sys/class/fc_host/host0/issue_lip
echo "1" > /sys/class/fc_host/host1/issue_lip
multipath -ll
fdisk -l
multipath -ll
pvcreate /dev/mapper/mpath4
pvdisplay
vgcreate vglog_file /dev/mapper/mpath4
lvcreate -L 100G vglog_file -n lvlog_file
lvcreate -L 99G vglog_file -n lvlog_file
mkfs.ext3 /dev/mapper/vglog_file-lvlog_file
mkdir logfile
mount -t ext3 /dev/mapper/vglog_file-lvlog_file /logfile/
chown sysadmin:root logfile/
echo "/dev/mapper/vglog_file-lvlog_file /logfile/ ext3 defaults 1 2">>/etc/fstab

Aug 25, 2011

How to secure the /tmp partition on a VPS with noexec,nosuid option?


How to secure the /tmp and /var/tmp partition on a VPS?
On a VPS, there are 2 ways to mount OR secure /tmp and /var/tmp partitions with the noexec,nosuid option. One way is to mount these partitions from the Node the VPS resides on.
1) Login to the Node server and execute the following command:
# vzctl set VEID --bindmount_add /tmp,noexec,nosuid,nodev --save
# vzctl set VEID --bindmount_add /var/tmp,noexec,nosuid,nodev --save
The “bindmount_add” option is use to mount the partition inside the VPS. The ‘VEID’ is the VPS ID you are working on.
2) The second option is to mount these partition from within the VPS itself. It is useful incase you don’t have access to the Node server. To mount /tmp and /var/tmp from within the VPS, execute:
# mount -t tmpfs -o noexec,nosuid,nodev tmpfs /tmp
# mount -t tmpfs -o noexec,nosuid,nodev tmpfs /var/tmp
To check the mounted ‘tmp’ partitions, execute
root@server [~]# mount | grep tmp
tmpfs on /tmp type tmpfs (rw,noexec,nosuid)
tmpfs on /var/tmp type tmpfs (rw,noexec,nosuid,nodev)

Jul 18, 2011

How to configure disk qouta in rhel5 linux /centos5

Quota is used for limiting the disk usage for users or groups.

###To verify that the quota is enabled in the kernel###
#grep CONFIG_QUOTA /boot/config-`uname -r`

CONFIG_QUOTA=y -enables limit on usage
CONFIQ_QUOTACTL=y -associated with disk quota manipulation.

If you have custom or upgraded kernel
#make menuconfig
#make gconfig
#make xconfig

###The quota package###
#rpm -q quota

For using Quotas the partition we are using for quota [quota can only be used per partition.] should be mounted with quota options. For that go to /etc/fstab and edit the partition mount options.

#vi /etc/fstab
LABEL=home /home ext3 defaults,usrquota,grpquota 1 1
:wq

If the partition is already mounted remount it for affecting changes in mount options.
#mount -o remount /home

Check the filesystem is mounted with changed options. If not, you may have to umount and mount again or u've to restart the system.
#mount -to check

###Create quota database###
#quotacheck -mcug /home
[ If you are using quotacheck -cug, it will throw an error that it cannot remount the filesystem mounted on m_point so counted values might not be right. Please stop all the programs writing to filesystem or use -m flag to force checking. This will happen when we use the filesystems like "/". Many processes are writing into "/" that time. Thats why it is throwing this error.] 

-c option specifies that the quota files should be created for each file system with quotas enabled.
-u option specifies to check for user quotas.
-g option specifies to check for group quotas.
If not, those files will be created.

quotacheck -mcug /home -will create following files in /home
aquota.group
aquota.user

###Assign quota policies for user###
#edquota username
#quota username -shows the quota for set for that user

###Assign quota policies for group###
#edquota -g groupname -think a user should exist with that group
#quota -g groupname -shows the quota for set for that group

###Defining prototypical users###
edquota -p user1 user2

###To see all user qoutas###
#repquota -a

###To see the user quotas in /home###
#repquota -u /home

###To see the group quotas in /home###
#repquota -g /home

###To see the quotas in appropriate size###
#repquota -s /home -shows used space and hard limit in MB

###To check the quota is on or not###
#quotaon -v /home

###To update the usage###
#quotacheck -mavug -execute this often for knowing latest usage info. Put it in cronjob. may need -f option.
[This will check all the files and directories in all partitions which is mounted with quota options.]
-a Check all mounted non-NFS filesystems in /etc/mtab
-v Verbose. Displays the information as it proceeds.
-u Checks for the user quotas.
-g Checks for the group quotas.

###Setting grace period###
#edquota -t
10days not 10 days.

###To enable and disable the qoutas###
#quotaon -vaug with -m if needed. For only one partition; quotaon -vug /home
#quotaon -vaug -will turn on all the quotas [group and user]
#quotaoff -vaug -will turn off all the quotas [gruop and user]