From Unix Wiki
Jump to: navigation, search


LVM filter

in /etc/lvm/lvm.conf

filter = [ "a/sda[1-9]$/", "r/sd.*/", "r/disk.*/", "a/.*/" ]

First part "a/sda[1-9]$/" should be repeated for other local drives like sdb sdc etc

Run SPcollect on Celerra

./navicli -h spcollect -messner
./navicli -h spcollect -messner

./navicli -h managefiles -list 
./navicli -h managefiles -list 

./navicli -h managefiles -retrieve
./navicli -h managefiles -retrieve


Recommended showvv

showvv -showcols Id,Name,Prov,Type,CopyOf,BsId,Rd,CreationTime,VV_WWN,VSize_MB


Delete device:

echo 1 > /sys/block/$SDDEV1/device/delete

Fix pvscsi issues on VMWARE guest

This simple script should fix kernel panic at boot after kernel update:

# Get the latest kernel installed
NEW_VERSION=`ls -tA1 /lib/modules | head -n 1`
# Check if the module is already present, if not- continue
if [ ! -e /lib/modules/$NEW_VERSION/misc/pvscsi.ko ]; then
   # Log output to show version we're fixing
   /bin/logger "Fixing VMware Paravirtual Drivers for reboot. Kernel: $NEW_VERSION"
   # Create the misc directory that VMware tools would
   mkdir /lib/modules/$NEW_VERSION/misc > /dev/null 2>&1
   # Find the current running kernel
   OLD_VERSION=`uname -r`
   # Copy the existing module to new kernel tree
   cp /lib/modules/$OLD_VERSION/misc/pvscsi.ko /lib/modules/$NEW_VERSION/misc > /dev/null 2>&1
   # Rebuild our modules cache
   depmod -a $NEW_VERSION > /dev/null 2>&1
   # Create a new initrd, including the new pvscsi module
   mkinitrd -f --with=pvscsi /boot/initrd-$NEW_VERSION.img $NEW_VERSION > /dev/null 2>&1
   # This would occur when module is already present
   /bin/logger "VMware Paravirtual Drivers Fix Installed"
exit 0

This will create new boot image and fix drivers for paravirtual SCSI, after reboot run this: -d --clobber-kernel-modules=pvscsi

Original article:

Rescan scsi bus

echo "- - -" > /sys/class/scsi_host/$SCSIHOST1/scan


# ls /sys/class/scsi_host
# echo "- - -" > /sys/class/scsi_host/host0/scan

If that doesn't reveal any change, then try

# find /dev/disk -ls|grep sdb
# echo 1 > /sys/bus/scsi/devices/2\:0\:1\:0/rescan



Link to script ql-dynamic-tgt-lun-disc-2.16.tgz


Lun rescan scrip

iSCSI tips and tricks

Install iSCSI target and initiator binaries

CentOS 6/Oracle Linux 6 (or even RHEL 6)

iSCSI target (server)

# yum -y install scsi-target-utils

and iSCSI initiator (client)

# yum -y install iscsi-initiator-utils


For example both services can be installed by:

# zypper in open-iscsi

Necessary /etc/fstab options to iSCSI devices

It's good to use following options in fstab to properly mount iSCSI devices

RHEL, CentOS, Oracle Linux

/dev/sdc1 _netdev,$OTHER_OPTIONS 0 0


/dev/sdc1 nofail,$OTHER_OPTIONS 0 0


/dev/sdc1 hotplug,$OTHER_OPTIONS 0 0

Automatic iSCSI target discovery and login

1. Set iscsi init daemon to start connections automatically

Look into:


and change following line to:

node.startup = automatic

2. Change discovered target to connect after reboot (two ways)

good way

create the SendTargets record:

# iscsiadm --mode node --target <IQN> --portal 192.0.2.*:3260 -o new

set the use_discoveryd setting for SendTargets record:

# iscsiadm --mode node --target <IQN> --portal 192.0.2.*:3260 -n discovery.sendtargets.use_discoveryd -v Yes

set the polling interval:

# iscsiadm --mode node --target IQN --portal 192.0.2.*:3260  -n discovery.sendtargets.discoveryd_poll_inval -v 30  

To make the new settings take effect, restart the iscsi service.

In Red Hat Enterprise Linux:

# /etc/init.d/iscsi restart 

In SUSE Linux Enterprise Server:

# rcopen-iscsi restart

best way

Look into /etc/iscsi/send_targets/,3260/st_config

discovery.startup = manual
discovery.type = sendtargets
discovery.sendtargets.address =
discovery.sendtargets.port = 3260
discovery.sendtargets.auth.authmethod = None
discovery.sendtargets.timeo.login_timeout = 15
discovery.sendtargets.use_discoveryd = Yes
discovery.sendtargets.discoveryd_poll_inval = 30
discovery.sendtargets.reopen_max = 5
discovery.sendtargets.timeo.auth_timeout = 45
discovery.sendtargets.timeo.active_timeout = 30
discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768

and change all that you need manualy.


All paths can be different on different distro's

For example in CentOS 6 it may be /var/lib/iscsi/send_targets/,3260/st_config

Good articles:

Manage Raw Disk/Image File System

To create a blank image file run:

dd if=/dev/zero bs=1M count=X > image.img

Where X is the size of the file in MB

To enlarge an image file run:

dd if=/dev/zero bs=1M count=X >> image.img

Where X is the amount of space you want to add in MB.

To create a sparse file run:

dd if=/dev/zero of=image.img seek=X bs=1M count=0

Where X is the size of the image in MB.

To enlarge a sparse file run:

dd if=/dev/zero of=image.img seek=X bs=1M count=0

Where seek=8 should be the current size of the sparse file plus the amount of space you wish to grow the image by in MB.

To enlarge an ext2 or ext3 file system to fill an expanded disk image run:

e2fsck -f image.img
e2resizefs image.img
e2fsck -f image.img

To create an ext2 file system on an image file run:

mke2fs image.img

To create an ext3 file system on an image file run:

mke2fs -j image.img

mke2fs’ defaults for file systems between 2 and 6 gigs often are not efficient for full linux installs, make sure you have enough inodes and to really save on space reduce the block size to 1KB. Optionally you can force the defaults for a “small” file system by using the -T flag. This helps clip off a lot of the wasted space created by the (Gentoo in particular but any given flavour’s) large number of small files.

mke2fs -j -T small image.img

To mount an image file run:

mount -o loop image.img /mnt/image

Remember not to perform any operations (like DD) on an image file while it is mounted.

To chroot into an image file with a working linux installation after mounting run:

mount -o bind /dev /mnt/image/dev
mount -t proc none /mnt/image/proc
chroot /mnt/image /bin/bash

To copy a file system’s contents verbatim to another file system mount both then run:

cp -ax /mnt/image1/* /mnt/image2/

You should do this to a freshly created sparse or regular file to increase the effectiveness of compression when redistributing an image. In a regular file, the empty space that would otherwise be completely zeroed out instead contains remnants of deleted files.

Resize of LVM root filesystem

Actions below are performing after resize appropriate disk on VM host side.

Take a note that 'X' here, e.g. in /dev/sdaX is number of last partition on disk.

Remove last partition on device:

	[root@vm ~]# fdisk /dev/sda

	"d" for delete
	"X" for last partition
Command (m for help): d
Selected partition X

	"X" for last partition
	"n" for new partition
	"p" for primary
	"X" for partition X
	"enter twice" for defaults sizes
	"w" to write new larger partion	

Restarting system to apply new partition table:

[root@vm ~]# shutdown -r now

After restart resizing change physical volume:

 [root@vm ~]# pvresize /dev/sdaX

Checking free extents on Volume Group:

[root@vm ~]# vgdisplay

Extending logical volume to maximum:

[root@vm ~]# lvextend /dev/VolGroup00/LogVol00 -l+100%FREE

Resizing file system (RHEL 5):

[root@vm ~]# resize2fs /dev/VolGroup00/LogVol00

On RHEL 4 instead of resize2fs using:

[root@vm ~]# ext2online /dev/VolGroup00/LogVol00

Checking changes:

[root@vm ~]# df -hP


Check status of LUN paths

for i in `luxadm probe | grep Path | cut -f 2 -d ':'`; do echo "Processing $i:"; sleep 1; luxadm display $i | egrep -i '(status|state)'; echo; done