You are on page 1of 88

storage Questions.

1. difference between SAS and SATA


SAS is designed for mission-critical enterprise applications whereas SATA is a general-purpose interface
common in the consumer market.
- SAS supports multiple initiators, while SATA has no such provision.
- SAS is dual ported where as SATA is single ported. SAS is therefore capable of multi path I/O without
additional hardware. Moreover, SAS can make use of both ports to scale performance.
- SATA transfers data at half duplex while SAS can transfer data at full duplex. Thus, for SAS, each port can
read and write data at the same time whereas SATA cannot.
- SAS uses SCSI commands for error recovery and error reporting, which have more functionality than the ATA
command set used by SATA.
- SAS can support cables up to 8m long, while maximum cable length for SATA is 1m.

SCSI
(sku4ze) Short for small computer system interface, a parallel interface standard used by Apple Macintosh
computers, PCs and many UNIX systems for attaching peripheral devices to computers. Nearly all Apple Macintosh
computers, excluding only the earliest Macs and the recent iMac, come with a SCSI port for attaching devices such
as disk drives and printers. SCSI interfaces provide for data transmission rates (up to 80 megabytes per second). In
addition, you can attach multiple devices to a single SCSI port, so that SCSI is really an I/O bus rather than simply an
interface.

ATA
(Also known as IDE) is a disk drive implementation that integrates the controller on the disk drive itself. ATA is used to
connect hard disk drives, CD-ROM drives and similar peripherals and supports 8/16-bit interface that transfer up to
8.3MB/s for ATA-2 and up to 100MB/s (ATA-6).

A Remedy For It Complexity And Sprawl: Standardization


Download Now
So, what do parallel interfaces have to do with SAS (Serial Attached SCSI) and SATA (Serial ATA)? A lot, actually. It is
the architectural limitations of the parallel interfaces that serial technologies like SAS and SATA address. In contrast
to multiple parallel data stream, data is transmitted serially, that is in a single steam, by wrapping multiple bits into
packets and it is able to move that single stream faster than parallel technology.

Serial Attached SCSI (SAS)


Abbreviated as SAS, Serial Attached SCSI, an evolution of parallel SCSI into a point-to-point serial peripheral
interface in which controllers are linked directly to disk drives. SAS is a performance improvement over traditional
SCSI because SAS enables multiple devices (up to 128) of different sizes and types to be connected simultaneously

with thinner and longer cables; its full-duplex signal transmission supports 3.0Gb/s. In addition, SAS drives can be
hot-plugged.

Serial ATA (SATA)


Often abbreviated as SATA, Serial ATA is an evolution of the Parallel ATA physical storage interface. Serial ATA is a
serial link a single cable with a minimum of four wires creates a point-to-point connection between devices.
Transfer rates for Serial ATA begin at 150MB/s.
Starting with SATA, it extends the capabilities of ATA and offers transfer rates starting at 150MB/s and, after years of
development, has moved to the mainstream of disk interfaces. The successor the SCSI interface is SAS at speeds of
up to 3Gb/s. Additionally, it also addresses parallel interface issues such as drive addressability and limitations on the
number of device per port connection.
SAS devices can communicate with both SATA and SCSI devices (the backplanes of SAS devices are identical to
SATA devices). A key difference between SCSI and SAS devices is the addition in SAS devices of two data ports,
each of which resides in a different SAS domain. This enables complete failover redundancy. If one path fails, there is
still communication along a separate and independent path.

Cables & Connectors


Another big advantage of SATA over ATA is the cabling and connectors. The serial interface reduces the amount of
wires needed to transmit data, making for much smaller cable size and making it easier to route and install SATA
devices. The IDE cables used in parallel ATA systems are bulkier than Serial ATA cables and can only extend to 40cm
long, while Serial ATA cables can extend up to one meter. In addition to the cabling, a new design of connectors is
also used that reduces the amount of crosstalk between the wires, and the connector design also provides easier
routing and better air flow.

StarTech's 26-inch Internal StarTech's External

StarTech's Serial ATA Drive

StarTech's LP4 to 2 SATA Internal

SCSI Cable

Connection Cable

Power Splitter Cable

SCSI4 Cable

Examples of SCSI and Serial ATA cables from StarTech.com

The Benefits of SAS & SATA in Storage


Serial interfaces offer an improvement over older parallel SCSI (with a serial version) in storage applications and
environments. These benefits include better performance, better scalability, and also better reliability as the parallel
interfaces are at their limits of speed with reliable data transfers. SAS and SATA drives can also operate in the same
environment while SCSI and ATA cannot. For example, using faster SAS drives for primary storage and offloading
older data to cheaper SATA disks in the same subsystem, something that could not be achieved with SCSI and ATA.

2. FCP

3. FC classes of services
Fibre Channel offers several connection strategies, called classes of service, for
connecting devices through a Fibre Channel fabric. ("Fabric" is Fibre Channel's term for
the cross-point switch at the heart of a fabric topology Fibre Channel. This is not to be
confused with the Fibre Channel Arbitrated Loop -- FC-AL -- topology, which may or may
not use switches and doesn't use them in quite the same way.)
Class 1 service establishes a dedicated connection through the fabric before transferring
data, much like a virtual private network. Class 2 and 3 services don't require a dedicated
channel. In Class 2 service, the receiving device sends an acknowledgment message to
tell the sending device the data has been received. Class 3 service has no
acknowledgment.
There is also a hybrid service, called Intermix, that allows other devices to use the Class
1 channel's bandwidth when no information is being sent over the Class 1 connection.
Besides these basic services, the Fibre Channel specification lists three other classes of
service: Classes 4, 5 and 6. Class 4 allocates fractional bandwidth of a channel to
establish a virtual circuit between two devices. Thus a single channel may serve many
virtual circuits. Class 5 is not fully defined. Class 6 is multi-cast (one-to-many)
transmission through the fabric.

4. Hard disk architecture...


5. SAS port, PHY, PHY identifier
6. SAS address
7. WWN, WWPN
8. SAS HBA details...for example, check with the server you have been using and
understand the HBA model.. or you can take any LSI SAS HBA model and explain in
detail.
9. how to flash the FW to cisco storage
10. what is canister

11. RAID levels, spares: global, local

Sun StorEdge 3000 Family Configuration Service 2.5 Users Guide

APPENDIX

RAID Basics
This appendix provides background information about RAID including an overview
of RAID terminology and RAID levels. Topics covered include the following:
RAID Terminology Overview
RAID Levels
Local and Global Spare Drives

RAID Terminology Overview


Redundant array of independent disks (RAID) is a storage technology used to improve
the processing capability of storage systems. This technology is designed to provide
reliability in disk array systems and to take advantage of the performance gains
offered by an array of multiple disks over single-disk storage.
RAIDs two primary underlying concepts are:
distributing data over multiple hard drives improves
performance
using multiple drives properly allows for any one drive to fail
without loss of data and without system downtime

In the event of a disk failure, disk access continues normally and the failure is
transparent to the host system.

Logical Drive
A logical drive is an array of independent physical drives. Increased availability,
capacity, and performance are achieved by creating logical drives. The logical drive
appears to the host the same as a local hard disk drive does.

FIGURE A-1

Logical Drive Including Multiple Physical Drives

Logical Volume
A logical volume is composed of two or more logical drives. The logical volume can
be divided into a maximum of 32 partitions for Fibre Channel. During operation, the
host sees a nonpartitioned logical volume or a partition of a logical volume as one
single physical drive.

Local Spare Drive


A local spare drive is a standby drive assigned to serve one specified logical drive.
When a member drive of this specified logical drive fails, the local spare drive
becomes a member drive and automatically starts to rebuild.

Global Spare Drive


A global spare drive does not only serve one specified logical drive. When a member
drive from any of the logical drives fails, the global spare drive joins that logical drive
and automatically starts to rebuild.

Channels
You can connect up to 15 devices (excluding the controller itself) to a SCSI channel
when the Wide function is enabled (16-bit SCSI). You can connect up to 125 devices
to an FC channel in loop mode. Each device has a unique ID that identifies the device
on the SCSI bus or FC loop.
A logical drive consists of a group of SCSI drives, Fibre Channel drives, or SATA
drives. Physical drives in one logical drive do not have to come from the same SCSI
channel. Also, each logical drive can be configured for a different RAID level.
A drive can be assigned as the local spare drive to one specified logical drive, or as a
global spare drive. A spare is not available for logical drives that have no data
redundancy (RAID 0).

FIGURE A-2

Allocation of Drives in Logical Drive Configurations

You can divide a logical drive or logical volume into several partitions or
use the entire logical drive as single partition.

FIGURE A-3

Partitions in Logical Drive Configurations

Each partition is mapped to LUNs under host SCSI IDs or IDs on host channels. Each
SCSI ID/LUN acts as one individual hard drive to the host computer.

FIGURE A-4

Mapping Partitions to Host ID/LUNs

FIGURE A-5

Mapping Partitions to LUNs Under an ID

RAID Levels
There are several ways to implement a RAID array, using a combination of mirroring,
striping, duplexing, and parity technologies. These various techniques are referred to
as RAID levels. Each level offers a mix of performance, reliability, and cost. Each
level uses a distinct algorithm to implement fault tolerance.
There are several RAID level choices: RAID 0, 1, 3, 5, 1+0, 3+0 (30), and 5+0 (50).
RAID levels 1, 3, and 5 are the most commonly used.
The following table provides a brief overview of the RAID levels.

TABLE A-1
RAID
Level

Description

RAID Level Overview


Number of Drives
Supported

Capacity

Redundanc
y

Striping

2-36

No

Mirroring

N/2

Yes

1+0

Mirroring and
striping

4-36 (even number


only)

N/2

Yes

Striping with
dedicated parity

3-31

N-1

Yes

Striping with
distributed parity

3-31

N-1

Yes

TABLE A-1
RAID
Level

Description

RAID Level Overview


Number of Drives
Supported

Capacity

Redundanc
y

3+0 (30) Striping of RAID 3


logical drives

2-8 logical drives

N-# of logical Yes


drives

5+0 (50) Striping of RAID 5


logical drives

2-8 logical drives

N-# of logical Yes


drives

Capacity refers to the total number (N) of physical drives available for data storage.
For example, if the capacity is N-1 and the total number of disk drives in the logical
drive is six 36-Mbyte drives, the disk space available for storage is equal to five disk
drives--(5 x 36 Mbyte or 180 Mbyte. The -1 refers to the amount of striping across six
drives, which provides redundancy of data and is equal to the size of one of the disk
drives.
For RAID 3+0 (30) and 5+0 (50), capacity refers to the total number of physical
drives (N) minus one physical drive (#) for each logical drive in the volume. For
example, if the total number of disk drives in the logical drive is twenty 36-Mbyte
drives and the total number of logical drives is 2, the disk space available for storage
is equal to 18 disk drives--18 x 36 Mbyte (648 Mbyte).

RAID 0
RAID 0 implements block striping, where data is broken into logical blocks and is
striped across several drives. Unlike other RAID levels, there is no facility for
redundancy. In the event of a disk failure, data is lost.

In block striping, the total disk capacity is equivalent to the sum of the capacities of
all drives in the array. This combination of drives appears to the system as a single
logical drive.
RAID 0 provides the highest performance. It is fast because data can be
simultaneously transferred to or from every disk in the array. Furthermore, read/writes
to separate drives can be processed concurrently.

FIGURE A-6

RAID 0 Configuration

RAID 1
RAID 1 implements disk mirroring, where a copy of the same data is recorded onto
two drives. By keeping two copies of data on separate disks, data is protected against
a disk failure. If, at any time, a disk in the RAID 1 array fails, the remaining good disk
(copy) can provide all of the data needed, thus preventing downtime.
In disk mirroring, the total usable capacity is equivalent to the capacity of one drive in
the RAID 1 array. Thus, combining two 1-Gbyte drives, for example, creates a single

logical drive with a total usable capacity of 1 Gbyte. This combination of drives
appears to the system as a single logical drive.

Note - RAID 1 does not allow expansion. RAID levels 3 and 5 permit
expansion by adding drives to an existing array.

FIGURE A-7

RAID 1 Configuration

In addition to the data protection that RAID 1 provides, this RAID level also improves
performance. In cases where multiple concurrent I/O is occurring, that I/O can be
distributed between disk copies, thus reducing total effective data access time.

RAID 1+0
RAID 1+0 combines RAID 0 and RAID 1 to offer mirroring and disk striping. Using
RAID 1+0 is a time-saving feature that enables you to configure a large number of
disks for mirroring in one step. It is not a standard RAID level option that you can
select; it does not appear in the list of RAID level options supported by the controller.
If four or more disk drives are chosen for a RAID 1 logical drive, RAID 1+0 is
performed automatically.

FIGURE A-8

RAID 1+0 Configuration

RAID 3
RAID 3 implements block striping with dedicated parity. This RAID level breaks
data into logical blocks, the size of a disk block, and then stripes these blocks across
several drives. One drive is dedicated to parity. In the event that a disk fails, the

original data can be reconstructed using the parity information and the information on
the remaining disks.
In RAID 3, the total disk capacity is equivalent to the sum of the capacities of all
drives in the combination, excluding the parity drive. Thus, combining four 1-Gbyte
drives, for example, creates a single logical drive with a total usable capacity of 3
Gbyte. This combination appears to the system as a single logical drive.
RAID 3 provides increased data transfer rates when data is being read in small chunks
or sequentially. However, in write operations that do not span every drive,
performance is reduced because the information stored in the parity drive needs to be
recalculated and rewritten every time new data is written, limiting simultaneous I/O.

FIGURE A-9

RAID 3 Configuration

RAID 5
RAID 5 implements multiple-block striping with distributed parity. This RAID level
offers redundancy with the parity information distributed across all disks in the array.
Data and its parity are never stored on the same disk. In the event that a disk fails,
original data can be reconstructed using the parity information and the information on
the remaining disks.

FIGURE A-10

RAID 5 Configuration

RAID 5 offers increased data transfer rates when data is accessed in large chunks, or
randomly and reduced data access time during many simultaneous I/O cycles.

Advanced RAID Levels


Advanced RAID levels require the use of the arrays built-in volume manager. These
combination RAID levels provide the protection benefits of RAID 1, 3, or 5 with the
performance of RAID 1. To use advanced RAID, first create two or more RAID 1, 3,

or 5 arrays, and then join them. The following table provides a description of the
advanced RAID levels.

TABLE A-2
RAID
Level

Advanced RAID Levels

Description

RAID 3+0
(30)

RAID 3 logical drives that have been joined together using the arrays
built-in volume manager.

RAID 5+0
(50)

RAID 5 logical drives that have been joined together using the arrays
volume manager.

Local and Global Spare Drives


The external RAID controllers provide both local spare drive and global spare drive
functions. The local spare drive is used only for one specified drive; the global spare
drive can be used for any logical drive on the array.
The local spare drive always has higher priority than the global spare drive. Therefore,
if a drive fails and both types of spares are available at the same time or a greater size
is needed to replace the failed drive, the local spare is used.
If there is a failed drive in the RAID 5 logical drive, replace the failed drive with a
new drive to keep the logical drive working. To identify a failed drive, refer to the Sun
StorEdge 3000 Family RAID Firmware Users Guide for your array.

Caution - If, when trying to remove a failed drive, you mistakenly


remove the wrong drive, you can no longer access the logical
drive because you have incorrectly failed another drive.

A local spare drive is a standby drive assigned to serve one specified logical drive.
When a member drive of this specified logical drive fails, the local spare drive
becomes a member drive and automatically starts to rebuild.
A local spare drive always has higher priority than a global spare drive; that is, if a
drive fails and there is a local spare and a global spare drive available, the local spare
drive is used.

FIGURE A-11

Local (Dedicated) Spare

A global spare drive is available for all logical drives rather than serving only one
logical drive (see FIGURE A-12). When a member drive from any of the logical
drives fails, the global spare drive joins that logical drive and automatically starts to
rebuild.

A local spare drive always has higher priority than a global spare drive; that is, if a
drive fails and there is a local spare and a global spare drive available, the local spare
drive is used.

FIGURE A-12

Global Spare

Having Both Local and Global Spares


In FIGURE A-13, the member drives in logical drive 0 are 9-Gbyte drives, and the
members in logical drives 1 and 2 are all 4-Gbyte drives.

FIGURE A-13

Mixing Local and Global Spares

A local spare drive always has higher priority than a global spare drive; that is, if a
drive fails and both a local spare and a global spare drive are available, the local spare
drive is used.
In FIGURE A-13, it is not possible for the 4-Gbyte global spare drive to join logical
drive 0 because of its insufficient capacity. The 9-Gbyte local spare drive aids logical
drive 0 once a drive in this logical drive fails. If the failed drive is in logical drive 1 or
2, the 4-Gbyte global spare drive immediately aids the failed drive.

Sun StorEdge 3000 Family Configuration Service 2.5 Users


Guide

817-333718

Copyright 2009 Sun Microsystems, Inc. All rights reserved.

12. Backplane, Power supply Unit ...


13. LED
14. Scsi enclosure services

15. SCSI primary commands


16. SCSI block level commands
17. SCSI phases
18. NAS
19. DAS
20. SAN

1. how to probe the luns in linux....(luns came from storage)


How to scan new FC LUNS and SCSI disks in Linux ?
June 20, 2013 in HOW TO ARTICLES- LINUX

How to scan new FC LUNS and SCSI disks in Redhat Linux without rebooting the server? Most
of the Linux beginners have wondering how to do this and this article will be for them.It may
look like very simple as we perform this in daily operation to scan luns but system has many
work to do in background when you execute storage scanning commands. Redhat says this
type of scan can be distributive,since it can cause delays while I/O operation timeout and
remove devices unexpectedly from OS.So perform this scan when really you want to scan the
disks and LUNS.

Scanning FC-LUNs in Redhat Linux


1.First find out how many disks are visible in fdisk -l .
# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l
2.Find out how many host bus adapter configured in the Linux box.you can use systool
-fc_host -v to verify available FC in the system.

# ls /sys/class/fc_host
host0 host1
In this case,you need to scan host0 & host1 HBA.

3.If the system virtual memory is too low ,then do not proceed further.If you have enough
free virtual memory,then you can proceed with below command to scan new LUNS.
# echo "1" > /sys/class/fc_host/host0/issue_lip
# echo "1" > /sys/class/fc_host/host1/issue_lip
Note: You need to monitor the issue_lip in /var/log/messages to determine when the scan
will complete.This operation is an asynchronous operation.
4.Verify if the new LUN is visible or not by counting the available disks.
# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l
If any new LUNS added ,then you can see more count is more then before scanning the LUNS.

Scanning SCSI DISKS in Redhat Linux


1.Finding the existing disk from fdisk.
[root@mylinz1 ~]# fdisk -l |egrep '^Disk' |egrep -v 'dm-'
Disk /dev/sda: 21.5 GB, 21474836480 bytes
2.Find out how many SCSI controller configured.
[root@mylinz1 ~]# ls /sys/class/scsi_host/host
host0 host1 host2
In this case,you need to scan host0,host1 & host2.
3.Scan the SCSI disks using below command.

[root@mylinz1 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan


[root@mylinz1 ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@mylinz1 ~]# echo "- - -" > /sys/class/scsi_host/host2/scan
4.Verify if the new disks are visible or not.
[root@mylinz1 ~]# fdisk -l |egrep '^Disk' |egrep -v 'dm-'
Disk /dev/sda: 21.5 GB, 21474836480 bytes
Disk /dev/sdb: 1073 MB, 1073741824 bytes
Disk /dev/sdc: 1073 MB, 1073741824 bytes

From Redhat Linux 5.4 onwards, redhat introduced /usr/bin/rescan-scsi-bus.sh script to


scan all the SCSI bus and update the SCSI layer to reflect new devices.

But most of the time,script will not be able to scan new disks and you need go with echo
command.
Here is the step by step guide to scan FC LUNS on Solaris 10.

Thank you for reading this article

How to rescan the SCSI bus in Linux


October 28, 2010 16 Comments
You are in front of a Linux box, a VM really, with a bunch of new disks that must be configured and
suddenly you remember that there is no ioscan in Linux, you will ask yourself who is so stupid to
create an operative system wihtout ioscan? at least I did x-)
Yes it is true, there is no ioscan in Linux and that means that everytime you add a new disk to one of
your virtual machine you have to reboot it, at least technically that is the truth. But dont worry there
is a quick and dirty way to circumvent that.
From a root shell issue the following command:
[root@redhat ~]# echo "- - -" > /sys/class/scsi_host/<host_number>/scan

After that if you do a fdsik -l will see the new disks.


If you want to rescan your box for new fiber channel disks the command is slightly different.
[root@redhat ~# echo "1" > /sys/class/fc_host/host#/issue_lip

For the fiber channel part there are also third party utilities. HP for example
provides hp_rescan which comes with the Proliant Support Pack.
[root@redhat /]# hp_rescan -h
hp_rescan: rescans LUNs on HP supported FC adapters
Usage: hp_rescan -ailh[n]

-a: rescan all adapters


-i: rescan a specific adapter instance. The specific device should be a
SCSI host number such as "0" or "6"
-l: lists all FC adapters
-n: do not perform "scsi remove-single-device" when executing probe-luns
-h: help
[root@redhat /]#

2. Where you will see the lun information in linux


First you would need to know the HBA's on the host, you can check it with this command:
systool -c fc_host -v (will show you if your HBA's are online) if there are two HBA's then run following
command once for each HBA # i.e host0
Then run lip command:echo "1" > /sys/class/fc_host/host0/issue_lip
Then you have to scan for newly added devs:echo "- - -" > /sys/class/scsi_host/host0/scan
Then run multipath and multipath -ll

How To Check LUN or SAN Disk In Linux


April 30, 2011 | By Bobbin Zachariah in HOWTOS, LINUX HOWTO, STORAGE

How to check attached lun from a storage device in Linux is explained with few commands. Its just to
understand better how to manage attached storage.
#cat /proc/scsi/scsi file it wi give you information like below

Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: HP 36.4G Model: MAN3367MC Rev: HP05
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003
Type: Unknown ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 00 Lun: 02
Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 00 Lun: 03
Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 01 Lun: 00
Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003
Type: Unknown ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 01 Lun: 02
Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 01 Lun: 03
Vendor: COMPAQ Model: HSV110 (C)COMPAQ Rev: 2003
Above indicates that HSV110 is a storage disk and it also give the LUN numbers with scsi
information
Like here it shows scsi2 is a san disk
if you want know about SAN partition
#dmesg | grep -i "attached "
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
Attached scsi disk sdb at scsi2, channel 0, id 0, lun 2
Attached scsi disk sdc at scsi2, channel 0, id 0, lun 3
Attached scsi disk sdd at scsi2, channel 0, id 1, lun 2
if you dont have a vendor based software to detect your SAN disk (LUNs), or instead u can use
"multipath" tools which is open source utility. Then, u can see the device names via running:
# multipath -l
- See more at: http://linoxide.com/how-tos/check-lun-san-disk-linux/#sthash.bInXeMPP.dpuf

3. file system creation

Creating an ext4 File System


After installation, it is sometimes necessary to create a new ext4 file system.
For example, if you add a new disk drive to the system, you may want to
partition the drive and use the ext4 file system.
The default options are optimal for most usage scenarios but if you need to
set your ext4 file system in a specific way, see manual pages for
the mke4fs and mkfs.ext4 commands for available options. Also, you may
want to examine and modify the configuration file
of mke4fs, /etc/mke4fs.conf, if you plan to create ext4 file systems more often.
The steps for creating an ext4 file system are as follows:
1.
Format the partition with the ext4 file system using
the mkfs.ext4 or mke4fs command:
~]# mkfs.ext4 block_device
~]# mke4fs -t ext4 block_device

where block_device is a partition which will contain the ext4 filesystem you
wish to create.
2.

Label the partition using the e4label command.


~]# e4label <block_device> new-label

3.

Create a mount point and mount the new file system to that mount
point:

4.

~]# mkdir /mount/point


~]# mount block_device /mount/point

A valid block device could be one of two types of entries:


o A mapped device A logical volume in a volume group, for
example, /dev/mapper/VolGroup00-LogVol02.
o A static device A traditional storage volume, for example, /dev/hdbX,
where hdb is a storage device name and Xis the partition number.

For striped block devices (for example RAID5 arrays), the stripe geometry can
be specified at the time of file system creation. Using proper stripe geometry
greatly enhances performance of an ext4 file system.
When creating file systems on lvm or md volumes, mkfs.ext4 chooses an
optimal geometry. This may also be true on some hardware RAIDs which
export geometry information to the operating system.
To specify stripe geometry, use the -E option of mkfs.ext4 (that is, extended
file system options) with the following sub-options:
stride=value
Specifies the RAID chunk size.
stripe-width=value
Specifies the number of data disks in a RAID device, or the number of
stripe units in the stripe.
For both sub-options, value must be specified in file system block
units. For example, to create a file system with a 64k stride (that is, 16
x 4096) on a 4k-block file system, use the following command:
~]# mkfs.ext4 -E stride=16,stripe-width=64 block_device

For more information about creating file systems, refer to man


mkfs.ext4.

Prev

5. how to create GPT ...

Lesson 4: Understanding Hard Drive Partitioning with Disk Management

In todays edition of Geek School, were going to talk about how to use Disk
Management but were going to go one step further and explain master boot records,
partition tables, and dynamic disks.

SCHOOL NAVIGATION
1.

Understanding Windows Administration Tools

2.

Using Task Scheduler to Run Processes Later

3.

Using Event Viewer to Troubleshoot Problems

4.

Understanding Hard Drive Partitioning with Disk Management

5.

Learning to Use the Registry Editor Like a Pro

6.

Monitoring Your PC with Resource Monitor and Task Manager

7.

Understanding the Advanced System Properties Panel

8.

Understanding and Managing Windows Services

9.

Using Group Policy Editor to Tweak Your PC

The Disk Management utility seems fairly simple at first glance. Theres a list of your
hard drives combined with a graphical representation of the partitions on each one.
You can create and edit partitions but there is a lot more to do. You can create
Spanned, Striped, or Mirrored volumes across multiple disks, or you can create and
attach virtual hard drives.

If you dig a little deeper, you will find that you can switch your hard drives between
MBR (Master Boot Record) and GPT (Guid Partition Table) as the partition scheme, and
then you can specify whether to use Basic (the default) partitions, or to use Dynamic,
which is a special method to allow Windows to handle the partitioning.
Confused? Keep reading and well try to explain it in a way that everybody can
understand.
Understanding the Interface

When you first launch Disk Management (which can be done through right-clicking on
the Start button in Windows 8.1 or the Computer icon in Windows 7 and selecting
Manage), youll be presented with a two-pane interface. The list of volumes is on top,
and the list of physical drives is on the bottom.
The bottom panel shows not just the list of physical drives, but a graphical
representation of the partitions, or volumes, on each drive, including a bunch of useful
information.

In the screenshot above, youll notice that the drives have extra information displayed
you can see that the C: drive is the Boot drive, while the System Reserved partition is
the Active one. Both partitions are Primary. That System Reserved partition actually

contains the boot files, so the BIOS for the computer initially boots from that partition,
and then Windows loads through the C: partition.
If you either select a drive or a partition and use the Action menu, youll see a list of
most of the options, including how to create a spanned, striped, or mirrored volume,
and how to switch between MBR / GPT disk type, or Basic / Dynamic. Well explain that
stuff shortly.

If you right-click on a partition, youll see a different list of actions you can change the
drive letter or path for a drive (more on that later), or you can shrink / extend the
volume, format it, add a mirror, or delete it.

Well mention this again later, but its worth noting right away: Software RAID, as in
mirroring, striping, or spanning, is not something you want to do if you have a choice.
Its always better to go with hardware RAID instead. Its important to understand
partitioning though.

Initializing a Disk and Choosing a Partition Style

Have you ever inserted a drive into your PC only to be presented with a dialog asking
you to Initialize Disk?
Whats actually going on is that Windows didnt detect any partition table format, so it
will ask you to Initialize, which really just means write out a new blank partition table.
In modern versions of Windows, that means youll get a choice between MBR and GPT.
Note: just because Windows didnt recognize any partition information doesnt mean
that your drive is blank. If you know that the drive works, its possible that you are
having a driver issue, or in some cases, if you plugged in an external drive, you can
remove and then plug it back in again. Of course, if you selected GPT as the partition
table, its also possible that the PCs BIOS cant handle it.
Using MBR (Master Boot Record)
If you are formatting a drive that you plan to plug into different computers, it would
generally need to use the MBR partition style because its a really old format that
works everywhere, because any computer with a regular BIOS has support for hard
drives partitioned using MBR.

Modern computers using UEFI are going away from MBR support and switching instead
to the newer and better replacement known as GPT (Guid Partition Table), because
MBR has a number of issues and limitations.
One of these limitations is that MBR only supports up to 4 primary partitions. If you
want to use more than 4 partitions, you need to set the fourth partition as an
Extended primary partition, which can then house Logical partitions within it.
Thankfully all of this happens behind the scenes in Disk Management these days, but
from a technology standpoint, it isnt the best way to handle things, and has some
weird compatibility issues.

Notice the logical partitions in brighter blue, while the extended partition is green.

The next limitation is that partitions using the MBR format have a maximum size of 2
TiB, which is significantly less than what you can get from modern hard drives, and
especially from what you can do with a hardware RAID using a couple of 2 or 3 TB hard
drives.
This limitation stems from the fact that there is a 32-bit list of sectors, and hard drives
typically have 512 bytes per sector. So 512 * 2^32 = 2 TiB, and thus youll always read
that MBR partitions have that limit.
The good news is that there is a workaround should you need one. If you have one of
the newer hard drives that use 4k sectors, the actual theoretical limit is 16 TiB instead,

since 4096 * 2^32 = 16 TiB. Realistically, however, it would be better to just migrate to
GPT partitions instead, which have no such limitations.
Using GPT (Guid Partition Table)
The newer GPT partition table style is required on your boot drive by newer
computers that use UEFI instead of BIOS while some of them support a legacy BIOS
mode to handle booting the older style, you would generally just use GPT instead.
Since Windows Vista, you can generally use GPT partitions on a data drive for a
computer that uses a newer version of BIOS, but you cant use them as a bootable
drive. And 32-bit Windows XP doesnt support it from all the documentation weve ever
read.

None of that Extended or Logical partition nonsense on a GPT drive.

GPT supports up to 128 partitions on the same hard drive, and each partition can be
9.4 zettabytes, which is 1 billion terabytes, which is a somewhat ridiculous number in
todays terms. Rather than just storing a single copy of the partition table the way MBR
does, there is both a primary and backup copy, and they have cyclic redundancy checks
to validate against data corruption.
All GPT disks contain a Protective MBR at the beginning of the drive, which is basically
a fake MBR at the beginning of the drive where an old-school MBR drive would put it
and the fake partition table shows the entire drive as having a single partition. This
protects you against older tools breaking your drive because they dont have GPT
support. It does not, however, make the file system readable on older computers.

Bootable GPT drives require a couple of things. First, youll need an EFI System
Partition, which is at least 100-260 MB depending on your drive, and that partition will
contain the boot loader and other information.
To better understand the difference between MBR and GPT, we found this graphic
buried deep within the Microsoft documentation and decided to display it here for you
as well. Notice the LDM data partition stuff, which we are going to cover in a moment.

You can actually switch back and forth between MBR and GPT partition types by rightclicking on the drive in Disk Management. The problem is that before you do, youll

need to delete all of the partitions on the disk, which does make the feature slightly
less useful.
Choosing a Disk Type: Basic or Dynamic

One of the other concepts in Disk Management is the very confusing Dynamic disk
instead of the default Basic disk. What makes this more confusing is that you can also
choose between MBR and GPT Disk on the same menu.
When you create a disk using either MBR or GPT partition formatting, you can create
regular partitions using the MBR or GPT specification. For MBR that would be a choice
between the Primary and Extended / Logical partitions, and for GPT it would just be
regular Guid partitions. Windows refers to this as a Basic disk.
The other option in Windows is to use a Dynamic Disk, which allows Windows to take
control of your partitioning rather than using the partitioning specifications. These are
called Volumes rather than partitions (in fact, Windows always refers to either type of
partition as a volume).
What happens behind the scenes is that Windows creates a regular MBR or GPT
partition structure that fills the entire drive, and then Windows will allow you to
manage the Volumes on that drive, which act like partitions, and even provide extra
features. Because Dynamic Disks are still reliant on the underlying MBR or GPT
structure, you should choose between them wisely if you need a huge drive, GPT is
probably the way to go.

Windows uses the Logical Disk Manager (LDM) database to store the volume types,
drive letters, and all of the other information, and it even replicates this database to
every dynamic drive on your computer for backup. On an MBR drive, this data is stored
in the last 1 MB on the drive, and in a GPT drive, Windows will create a 1 MB hidden
partition called the LDM metadata partition.
Mirroring Your System Drive
You can easily convert your system drive to a dynamic disk in order to mirror it. All you
have to do is start the mirroring wizard by right-clicking on your system drive and
choosing Add Mirror.

You will be prompted to convert the disks to dynamic instead of Basic, and given a
warning that you cant boot any other operating systems. Thats right, dynamic disks
break dual-booting scenarios.

Once youve configured the mirror, your computer will slow down to a crawl as all of
the data from your system drive is copied over to the other drive. From that moment
on, your data should stay in sync on both drives.

You can right-click on the mirrored drives to either break the mirror, which will stop
mirroring but leave everything alone on each drive, or you can remove the mirror.
Note: You cant mirror an MBR drive to a GPT drive.
Types of Volumes for Dynamic Disks
When you are working with a volume on a Dynamic Disk, you can choose to extend or
span that volume across multiple drives, you can stripe or mirror, or in server editions

you can even use RAID 5. Theres also not a real limit on the number of volumes you
can have, although it wouldnt make sense to have a huge number of them.
Here are the types of volumes you can create on a Dynamic Disk:

Simple Volume this is a regular partition. If the disk type is Basic, this
creates an actual partition.

Striped Volume data is striped across multiple hard drives so that every other
segment of data is staggered between the drives for maximum performance.
There is no redundancy.

Spanned Volume data fills up on one drive and then fills up the next drive as it
gets more full. Two or more drives are basically taped together to make a bigger
disk. There is no redundancy here either.

Mirrored Volume for home users, this is the only form of redundancy that you
will get with software options. Read performance should be faster, but write
performance will possibly be slightly slower, since Windows has to write to both
drives for everything.

RAID5 Volume only works on server editions, but it can stripe across 3 or
more hard drives and include a parity stripe to prevent data loss if a drive was to
fail.

5. linux booting process


6. commands to verify the adapter information

GPT

How to Create Partition on Linux for >2TB Size using Parted

by R AMES H NATA R AJAN on AUGUST 1, 2012

Question: I have a disk that is greater than 2TB size. I cannot create a partition on this >2TB disk
using fdisk. Can you explain me with an example on how to create a partition on a disk that is larger
than 2TB using parted and GPT format?

Answer: If you are using fdisk to create partition on a >2TB disk, youll get the following warning
message.

# fdisk /dev/sdb

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: The size of this disk is 5.9 TB (5908688535552 bytes).

DOS partition table format can not be used on drives for volumes

larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID

partition table format (GPT).

Creating 2TB partition using Fdisk


The size of the disk in this example is roughly 6 TB. You can still create a partition in this disk for 2TB
using fdisk as shown below.

# fdisk /dev/sdb1

Command (m for help): n

Command action

e extended

p primary partition (1-4)

Partition number (1-4): 1

First cylinder (1-718357, default 1):


Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-267349, default 267349):
Using default value 267349

As you see above, even though there are 718357 cylinders available on this disk (this is for total of
roughly 6TB), the last cylinder value it shows is only 267349 (which is roughly close to 2TB in this
example).
So, fdisk has created a partition of 2 TB as shown below (even though the disk size is around 6 TB).

Command (m for help): p

Disk /dev/sdb: 5908.7 GB, 5908688535552 bytes

255 heads, 63 sectors/track, 718357 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x3dffd626

Device Boot

Start

/dev/sdb1

End

Blocks Id System

267349 2147480811 83 Linux

Set Partition Table to GPT using Parted mklabel


In our case, we need to create a partition >2TB. So, we should use parted command.
Before creating the partition command, we should set the disk label to GPT.
GPT stands for GUID partition table format (GPT).

Use parteds mklabel command to set disk label to GPT as shown below.

# parted /dev/sdb

GNU Parted 2.1

Using /dev/sdb

Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) print

Error: /dev/sdb: unrecognised disk label

(parted) mklabel gpt

(parted) print
Model: Unknown (unknown)
Disk /dev/sdb: 5909GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags

Create >2TB Partition using Parted mkpart


Use parteds mkpart command as shown below to create partition that is greater than 2TB. In this
example, we are creating a partition that is roughly of 6TB in size.

# parted /dev/sdb

(parted) mkpart primary 0GB 5909GB

(parted) print
Model: Unknown (unknown)
Disk /dev/sdb: 5909GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End


1

Size

File system Name

1049kB 5909GB 5909GB

Flags

primary

To understand how to use parted command effectively, refer to: 9 Linux Parted Command Examples.

Just for curiosity, let us see how this >2TB partition is displayed in fdisk. As you see below, it still
shows the size as roughly 2TB (under the Blocks columns). However there is a + at the end
indicating that this is greater than 2TB. The System column displays GPT.

# fdisk /dev/sdb

Command (m for help): print

Disk /dev/sdb: 5908.7 GB, 5908688535552 bytes

255 heads, 63 sectors/track, 718357 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Device Boot

/dev/sdb1

Start

End

Blocks Id System

267350 2147483647+ ee GPT

Format and Mount the Partition


Use mkfs to format the partition. This will take some time depending the size of the partition. Youll
see that it is Writing inode tables and the counter will keep increasing. In this example, it roughly
took around 15 minutes to complete the mkfs.

# mkfs /dev/sdb1

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

360644608 inodes, 1442550528 blocks

72127526 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

44024 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,

102400000, 214990848, 512000000, 550731776, 644972544

Writing inode tables: 3955/44024

Writing inode tables: 5022/44024

Writing inode tables: 7218/44024

Writing inode tables: done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 23 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

Finally, mount this >2TB partition.

# mkdir /data

# mount /dev/sdb1 /data

# df -h

Filesystem

Size Used Avail Use% Mounted on

/dev/sda1

127G 1.6G 119G 2% /

/dev/sdb1

5.3T 59M 5.1T 1% /data

> Add your comment

7. how to create boot from the san


8. linux permissions

Understanding Linux File Permissions


Tuesday, 18 May 2010 00:00 mfillpot |

Exclusive

Submit to LinkedinSubmit to Stumbleupon

Although there are already a lot of good security features built into Linux-based systems, one very important potential
vulnerability can exist when local access is granted - - that is file permission based issues resulting from a user not
assigning the correct permissions to files and directories. So based upon the need for proper permissions, I will go over the
ways to assign permissions and show you some examples where modification may be necessary.

Basic File Permissions


Permission Groups
Each file and directory has three user based permission groups:

owner - The Owner permissions apply only the owner of the file or directory, they will not impact the actions of
other users.

group - The Group permissions apply only to the group that has been assigned to the file or directory, they will not
effect the actions of other users.

all users - The All Users permissions apply to all other users on the system, this is the permission group that you
want to watch the most.
Permission Types
Each file or directory has three basic permission types:

read - The Read permission refers to a user's capability to read the contents of the file.

write - The Write permissions refer to a user's capability to write or modify a file or directory.

execute - The Execute permission affects a user's capability to execute a file or view the contents of a directory.
Viewing the Permissions
You can view the permissions by checking the file or directory permissions in your favorite GUI File Manager (which I will not
cover here) or by reviewing the output of the \"ls -l\" command while in the terminal and while working in the directory which
contains the file or folder.
The permission in the command line is displayed as: _rwxrwxrwx 1 owner:group

1.

2.

User rights/Permissions
1.

The first character that I marked with an underscore is the special permission flag that can vary.

2.

The following set of three characters (rwx) is for the owner permissions.

3.

The second set of three characters (rwx) is for the Group permissions.

4.

The third set of three characters (rwx) is for the All Users permissions.
Following that grouping since the integer/number displays the number of hardlinks to the file.

3.

The last piece is the Owner and Group assignment formatted as Owner:Group.
Modifying the Permissions
When in the command line, the permissions are edited by using the command chmod. You can assign the permissions
explicitly or by using a binary reference as described below.
Explicitly Defining Permissions
To explicity define permissions you will need to reference the Permission Group and Permission Types.
The Permission Groups used are:

u - Owner

g - Group

o or a - All Users
The potential Assignment Operators are + (plus) and - (minus); these are used to tell the system whether to add or remove
the specific permissions.
The Permission Types that are used are:

r - Read

w - Write

x - Execute
So for an example, lets say I have a file named file1 that currently has the permissions set to _rw_rw_rw, which means that
the owner, group and all users have read and write permission. Now we want to remove the read and write permissions from
the all users group.
To make this modification you would invoke the command: chmod a-rw file1
To add the permissions above you would invoke the command: chmod a+rw file1
As you can see, if you want to grant those permissions you would change the minus character to a plus to add those
permissions.
Using Binary References to Set permissions
Now that you understand the permissions groups and types this one should feel natural. To set the permission using binary
references you must first understand that the input is done by entering three integers/numbers.
A sample permission string would be chmod 640 file1, which means that the owner has read and write permissions, the

group has read permissions, and all other user have no rights to the file.
The first number represents the Owner permission; the second represents the Group permissions; and the last number
represents the permissions for all other users. The numbers are a binary representation of the rwx string.

r=4

w=2

x=1
You add the numbers to get the integer/number representing the permissions you wish to set. You will need to include the
binary permissions for each of the three permission groups.
So to set a file to permissions on file1 to read _rwxr_____, you would enter chmod 740 file1.
Owners and Groups
I have made several references to Owners and Groups above, but have not yet told you how to assign or change the Owner
and Group assigned to a file or directory.
You use the chown command to change owner and group assignments, the syntax is simple chown owner:group
filename, so to change the owner of file1 to user1 and the group to family you would enter chown user1:family file1.
Advanced Permissions
The special permissions flag can be marked with any of the following:

_ - no special permissions

d - directory

l - The file or directory is a symbolic link

s - This indicated the setuid/setgid permissions. This is not set displayed in the special permission part of the
permissions display, but is represented as a s in the read portion of the owner or group permissions.

t - This indicates the sticky bit permissions. This is not set displayed in the special permission part of the
permissions display, but is represented as a t in the executable portion of the all users permissions
Setuid/Setgid Special Permissions
The setuid/setguid permissions are used to tell the system to run an executable as the owner with the owner\'s permissions.
Be careful using setuid/setgid bits in permissions. If you incorrectly assign permissions to a file owned by root with the
setuid/setgid bit set, then you can open your system to intrusion.

You can only assign the setuid/setgid bit by explicitly defining permissions. The character for the setuid/setguid bit is s.
So do set the setuid/setguid bit on file2.sh you would issue the command chmod g+s file2.sh.
Sticky Bit Special Permissions
The sticky bit can be very useful in shared environment because when it has been assigned to the permissions on a
directory it sets it so only file owner can rename or delete the said file.
You can only assign the sticky bit by explicitly defining permissions. The character for the sticky bit is t.
To set the sticky bit on a directory named dir1 you would issue the command chmod +t dir1.
When Permissions Are Important
To some users of Mac- or Windows-based computers you don't think about permissions, but those environments don't focus
so aggressively on user based rights on files unless you are in a corporate environment. But now you are running a Linuxbased system and permission based security is simplified and can be easily used to restrict access as you please.
So I will show you some documents and folders that you want to focus on and show you how the optimal permissions should
be set.

home directories - The users\' home directories are important because you do not want other users to be able to
view and modify the files in another user\'s documents of desktop. To remedy this you will want the directory to have
the drwx______ (700) permissions, so lets say we want to enforce the correct permissions on the user user1\'s home
directory that can be done by issuing the command chmod 700 /home/user1.

bootloader configuration files - If you decide to implement password to boot specific operating systems then you
will want to remove read and write permissions from the configuration file from all users but root. To do you can change the
permissions of the file to 700.

system and daemon configuration files - It is very important to restrict rights to system and daemon
configuration files to restrict users from editing the contents, it may not be advisable to restrict read permissions, but
restricting write permissions is a must. In these cases it may be best to modify the rights to 644.

firewall scripts - It may not always be necessary to block all users from reading the firewall file, but it is advisable
to restrict the users from writing to the file. In this case the firewall script is run by the root user automatically on boot, so all
other users need no rights, so you can assign the 700 permissions.
Other examples can be given, but this article is already very lengthy, so if you want to share other examples of needed
restrictions please do so in the comments.

Comments Welcome
If you have anything to add or want to make a comment or correction please do so in the comments. I look forward to your
feedback and wish you the best in your future with Linux-based systems.

10.LVM

Linux lvm - Logical Volume Manager


Contents[Hide]

o
o
o
o
o
o
o

This is what we are going to do


Create Partitions
Create physical volumes
Create Virtual Group
Create Logical Volumes
Create File system on logical volumes
Edit /etc/fstab

o
o

Mount logical volumes


Extend logical volume
Remove logical volume

This article describes a basic logic behind a Linux logical volume manager by showing real examples of
configuration and usage. Although Debian Linux will be used for this tutorial, you can also apply the same
command line syntax with other Linux distributions such as Red Hat, Mandriva, SuSe Linux and others.

1. This is what we are going to do

2. Create Partitions
For this Linux lvm example you need an unpartitioned hard disk /dev/sdb. First you need to create
physical volumes. To do this you need partitions or a whole disk. It is possible to run pvcreate command
on /dev/sdb, but I prefer to use partitions and from partitions I later create physical volumes.

Use your preferred partitioning tool to create partitions. In this example I have used cfdisk.

Partitions are ready to use.

3. Create physical volumes


Use the pvcreate command to create physical volumes.

# pvcreate /dev/sdb1
# pvcreate /dev/sdb2

The pvdisplay command displays all physical volumes on your system.

# pvdisplay

Alternatively the following command should be used:

# pvdisplay /dev/sdb1

4. Create Virtual Group


At this stage you need to create a virtual group which will serve as a container for your physical volumes.
To create a virtual group with the name "mynew_vg" which will include /dev/sdb1 partition, you can issue
the following command:

# vgcreate mynew_vg /dev/sdb1

To include both partitions at once you can use this command:

# vgcreate mynew_vg /dev/sdb1 /dev/sdb2

Feel free to add new physical volumes to a virtual group by using the vgextend command.

# vgextend mynew_vg /dev/sdb2

5. Create Logical Volumes


From your big cake (virtual group) you can cut pieces (logical volumes) which will be treated as a
partitions for your linux system. To create a logical volume, named "vol01", with a size of 400 MB from the
virtual group "mynew_vg" use the following command:

create a logical volume of size 400 MB -L 400

create a logical volume of size 4 GB -L 4G

# lvcreate -L 400 -n vol01 mynew_vg

With a following example you will create a logical volume with a size of 1GB and with the name vol02:

# lvcreate -L 1000 -n vol02 mynew_vg

Note the free size in virtual group.

6. Create File system on logical volumes


The logical volume is almost ready to use. All you need to do is to create a filesystem.:

# mkfs.ext3 -m 0 /dev/mynew_vg/vol01

the -m option specifies the percentage reserved for the super-user, set this to 0 if you wish not to waste
any space, the default is

5%.

7. Edit /etc/fstab
Add an entry for your newly created logical volume into /etc/fstab

7.1. Mount logical volumes


Before you mount do not forget to create a mount point.

# mkdir /home/foobar

8. Extend logical volume


The biggest advantage of logical volume manager is that you can extend your logical volumes any time
you are running out of the space. To increase the size of a logical volume by another 800 MB you can run
this command:

# lvextend -L +800 /dev/mynew_vg/vol01

The command above does not actually increase the physical size of volume, to do that you need to:

# resize2fs

/dev/mynew_vg/vol01

Look at the figure below to see what problems you may encounter when extending a volume:

9. Remove logical volume


The command lvremove can be used to remove logical volumes. Make sure that before you attempt to
remove logical volumes your logical volume does not have any valuable data stored on it, moreover,
make sure the volume is unmounted.

# lvdisplay

# lvremove /dev/mynew_vg/vol02

11.how you verify the process information

Linux Command Related with Process


Following tables most commonly used command(s) with process:
For this purpose
To see currently running
process

Use this Command


ps

To stop any process by PID i.e.


kill
to kill process

Examples*
$ ps

{PID}

$ kill 1012

To stop processes by name


i.e. to kill process

killall {Process-name}

$ killall httpd

To get information about all


running process

ps -ag

$ ps -ag

To stop all process except


your shell

kill 0

$ kill 0

For background processing


(With &, use to put particular
command and program in
background)

linux-command &

$ ls / -R | wc -l &

To display the owner of the

ps aux

$ ps aux

processes along with the


processes

To see if a particular process


is running or not. For this
ps ax | grep process-U-want-to
purpose you have to use ps
see
command in combination with
the grep command

To see currently running


processes and other
information like memory and
CPU usage with real time
updates.

top
See the output of top
command.

To display a tree of processes pstree

For e.g. you want to


see whether Apache
web server process is
running or not then
give command

$ ps ax | grep httpd

$ top
Note that to exit from top
command press q.

$ pstree

* To run some of this command you need to be root or equivalnt user.


NOTE that you can only kill process which are created by yourself. A Administrator
can almost kill 95-98% process. But some process can not be killed, such as VDU
Process.
Exercise:
You are working on your Linux workstation (might be learning LSST or some other
work like sending mails, typing letter), while doing this work you have started to play
MP3 files on your workstation. Regarding this situation, answer the following
question:
1) Is it example of Multitasking?
2) How you will you find out the both running process (MP3 Playing & Letter
typing)?
3) "Currently only two Process are running in your Linux/PC environment", Is it True
or False?, And how you will verify this?
4) You don't want to listen music (MP3 Files) but want to continue with other work on
PC, you will take any of the following action:
1. Turn off Speakers

2. Turn off Computer / Shutdown Linux Os


3. Kill the MP3 playing process
4. None of the above
1) Is it example of Multitasking?
Ans.: Yes, since you are running two process simultaneously.
2) How you will you find out the both running process (MP3 Playing & Letter
typing)?
Ans.: Try $ ps aux or $ ps ax | grep process-you-want-to-search
3) "Currently only two Process are running in your Linux/PC environment", Is it True
or False?, And how you will verify this?
Ans.: No its not true, when you start Linux Os, various process start in background for
different purpose. To verify this simply use top or ps aux command.
4) You don't want to listen music (MP3 Files) but want to continue with other work on
PC, you will take any of the following action:
1. Turn off Speakers
2. Turn off Computer / Shutdown Linux Os
3. Kill the MP3 playing process
4. None of the above
Ans.: Use action no. 3 i.e. kill the MP3 process.
Tip: First find the PID of MP3 playing process by issuing command:
$ ps ax | grep mp3-process-name
Then in the first column you will get PID of process. Kill this PID to end the process
as:
$ kill PID
Or you can try killall command to kill process by name as follows:
$ killall mp3-process-name

Linux Console (Screen)

How can I write colorful message on Linux Console? , mostly this kind of question is
asked by newcomers (Specially those who are learning shell programming!). As you
know in Linux everything is considered as a file, our console is one of such special
file. You can write special character sequences to console, which control every aspects
of the console like Colors on screen, Bold or Blinking text effects, clearing the screen,
showing text boxes etc. For this purpose we have to use special code called escape
sequence code. Our Linux console is based on the DEC VT100 serial terminals which
support ANSI escape sequence code.
What is special character sequence and how to write it to Console?
By default what ever you send to console it is printed as its. For e.g. consider
following echo statement,
$ echo "Hello World"
Hello World
Above echo statement prints sequence of character on screen, but if there is any
special escape sequence (control character) in sequence , then first some action is
taken according to escape sequence (or control character) and then normal character is
printed on console. For e.g. following echo command prints message in Blue color on
console
$ echo -e "\033[34m Hello Colorful World!"
Hello Colorful World!
Above echo statement uses ANSI escape sequence (\033[34m), above entire string
( i.e. "\033[34m Hello Colorful World!" ) is process as follows
1) First \033, is escape character, which causes to take some action
2) Here it set screen foreground color to Blue using [34m escape code.
3) Then it prints our normal message Hello Colorful World! in blue color.
Note that ANSI escape sequence begins with \033 (Octal value) which is represented
as ^[ in termcap and terminfo files of terminals and documentation.
You can use echo statement to print message, to use ANSI escape sequence you must
use -e option (switch) with echo statement, general syntax is as follows
Syntax
echo -e "\033[escape-code your-message"
In above syntax you have to use\033[ as its with different escape-code for different
operations. As soon as console receives the message it start to process/read it, and if it
found escape character (\033) it moves to escape mode, then it read "[" character and
moves into Command Sequence Introduction (CSI) mode. In CSI mode console

reads a series of ASCII-coded decimal numbers (know as parameter) which are


separated by semicolon (;) . This numbers are read until console action letter or
character is not found (which determines what action to take). In above example
\033

Escape character

Start of CSI

34

34 is parameter

m is letter (specifies action)

Following table show important list of such escape-code/action letter or character


Character or letter

Use in CSI

Examples

Set the ANSI mode

echo -e "\033[h"

Clears the ANSI mode

echo -e "\033[l"

Useful to show characters in


different colors or effects such
as BOLD and Blink, see below
for parameter taken by m.

echo -e "\033[35m Hello World"

Turns keyboard num lock, caps


lock, scroll lock LED on or off,
see below.

echo -e "\033[2q"

Stores the current cursor x,y


position (col , row position) and echo -e "\033[7s"
attributes

Restores cursor position and


attributes

echo -e "\033[8u"

m understand following parameters


Parameter
0

Meaning

Example

Sets default color scheme


(White foreground and Black
background), normal
intensity, no blinking etc.

Set BOLD intensity

$ echo -e "I am \033[1m BOLD \033[0m Person"


I am BOLD Person
Prints BOLD word in bold intensity and next ANSI
Sequence remove bold effect (\033[0m)

Set dim intensity

$ echo -e "\033[1m BOLD \033[2m DIM \


033[0m"

Blink Effect

$ echo -e "\033[5m Flash! \033[0m"

Reverse video effect i.e.


Black foreground and white
background in default color
scheme

$ echo -e "\033[7m Linux OS! Best OS!! \


033[0m"

11

Shows special control


character as graphics
character. For e.g. Before
issuing this command press
alt key (hold down it) from
numeric key pad press 178
and leave both key; nothing
will be printed. Now give -->
command shown in example
and try the above, it works.
(Hey you must know
extended ASCII Character for
this!!!)

$ press alt + 178


$ echo -e "\033[11m"
$ press alt + 178
$ echo -e "\033[0m"
$ press alt + 178

25

Removes/disables blink effect

27

Removes/disables reverse
effect

30 - 37

Set foreground color


31 - RED
32 - Green
xx - Try to find yourself this
left as exercise for you :-)

$ echo -e "\033[31m I am in Red"

40 - 47

Set background color


xx - Try to find yourself this
left as exercise for you :-)

$ echo -e "\033[44m Wow!!!"

q understand following parameters


Parameters

Meaning

Turns off all LEDs on Keyboard

Scroll lock LED on and others off

Num lock LED on and others off

Caps lock LED on and others off

Click here to see example of q command.

Click here to see example of m command.


Click here to see example of s and u command.
This is just quick introduction about Linux Console and what you can do using this
Escape sequence. Above table does not contains entire CSI sequences. My up-coming
tutorial series on C Programming Language will defiantly have entire story with SLang and curses (?). What ever knowledge you gain here will defiantly first step
towards the serious programming using c. This much knowledge is sufficient for
Shell Programming, now try the following exercise :-) I am Hungry give me More
Programming Exercise & challenges! :-)
1) Write function box(), that will draw box on screen (In shell Script)
box (left, top, height, width)
For e.g. box (20,5,7,40)

Hint: Use ANSI Escape sequence


1) Use of 11 parameter to m
2) Use following for cursor movement
row;col H
or
rowl;col f
For e.g.

$ echo -e "\033[5;10H Hello"


$ echo -e "\033[6;10f Hi"
In Above example prints Hello message at row 5 and column 6 and Hi at 6th row and
10th Column.

Shell Built in Variables


Shell Built in
Variables

Meaning

$#

Number of command line arguments. Useful to test no. of


command line args in shell script.

$*

All arguments to shell

$@

Same as above

$-

Option supplied to shell

$$

PID of shell

$!

PID of last started background process (started with &)

See example of $@ and $* variable.

Linux: Find Out Which Process Is Listening Upon


a Port
by NI XC RA F T on OCTOBER 31, 2010 35 CO MME N TS L AS T UP DATE D JU NE 25 , 2012

in LIN U X

ow do I find out running processes were associated with

each open port? How do I find out what process has open tcp
port 111 or udp port 7000 under Linux?
You can the following programs to find out about port
numbers and its associated process:
1.

netstat - a command-line tool that displays network


connections, routing tables, and a number of network
interface statistics.
2. fuser - a command line tool to identify processes using
files or sockets.
3. lsof - a command line tool to list open files under Linux /
UNIX to report a list of all open files and the processes that
opened them.
4. /proc/$pid/ file system - Under Linux /proc includes a
directory for each running process (including kernel
processes) at /proc/PID, containing information about that
process, notably including the processes name that opened
port.
You must run above command(s) as the root user.

netstat example
Type the following command:
# netstat -tulpn

Sample outputs:
Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address


State
PID/Program name

Foreign Address

tcp
0
0 127.0.0.1:3306
0.0.0.0:*
LISTEN
1138/mysqld
tcp
0
0 0.0.0.0:111
0.0.0.0:*
LISTEN
850/portmap
tcp
0
0 0.0.0.0:80
0.0.0.0:*
LISTEN
1607/apache2
tcp
0
0 0.0.0.0:55091
0.0.0.0:*
LISTEN
910/rpc.statd
tcp
0
0 192.168.122.1:53
0.0.0.0:*
LISTEN
1467/dnsmasq
tcp
0
0 0.0.0.0:22
0.0.0.0:*
LISTEN
992/sshd
tcp
0
0 127.0.0.1:631
0.0.0.0:*
LISTEN
1565/cupsd
tcp
0
0 0.0.0.0:7000
0.0.0.0:*
LISTEN
3813/transmission
tcp6
0
0 :::22
:::*
LISTEN
992/sshd
tcp6
0
0 ::1:631
:::*
LISTEN
1565/cupsd
tcp6
0
0 :::7000
:::*
LISTEN
3813/transmission
udp
0
0 0.0.0.0:111
0.0.0.0:*
850/portmap
udp
0
0 0.0.0.0:662
0.0.0.0:*
910/rpc.statd
udp
0
0 192.168.122.1:53
0.0.0.0:*
1467/dnsmasq
udp
0
0 0.0.0.0:67
0.0.0.0:*
1467/dnsmasq

udp
0
0 0.0.0.0:68
3697/dhclient
udp
0
0 0.0.0.0:7000
3813/transmission
udp
0
0 0.0.0.0:54746
910/rpc.statd

0.0.0.0:*
0.0.0.0:*
0.0.0.0:*

TCP port 3306 was opened by mysqld process having PID #


1138. You can verify this using /proc, enter:
# ls -l /proc/1138/exe

Sample outputs:
lrwxrwxrwx 1 root root 0 2010-10-29 10:20 /proc/1138/exe ->
/usr/sbin/mysqld

You can use grep command to filter out information:


# netstat -tulpn | grep :80

Sample outputs:
tcp
0
0 0.0.0.0:80
1607/apache2

0.0.0.0:*

LISTEN

Video demo
fuser command
Find out the processes PID that opened tcp port 7000, enter:
# fuser 7000/tcp

Sample outputs:

7000/tcp:

3813

Finally, find out process name associated with PID # 3813,


enter:
# ls -l /proc/3813/exe

Sample outputs:
lrwxrwxrwx 1 vivek vivek 0 2010-10-29 11:00 /proc/3813/exe ->
/usr/bin/transmission

/usr/bin/transmission is a bittorrent client, enter:


# man transmission

OR
# whatis transmission

Sample outputs:
transmission (1)

- a bittorrent client

Task: Find Out Current Working Directory Of a


Process
To find out current working directory of a process called
bittorrent or pid 3813, enter:
# ls -l /proc/3813/cwd

Sample outputs:

lrwxrwxrwx 1 vivek vivek 0 2010-10-29 12:04 /proc/3813/cwd


-> /home/vivek

OR use pwdx command, enter:


# pwdx 3813

Sample outputs:
3813: /home/vivek

Task: Find Out Owner Of a Process


Use the following command to find out the owner of a process
PID called 3813:
# ps aux | grep 3813

OR
# ps aux | grep '[3]813'

Sample outputs:
vivek
3813 1.9 0.3 188372 26628 ?
transmission

Sl 10:58 2:27

OR try the following ps command:


# ps -eo pid,user,group,args,etime,lstart | grep '[3]813'

Sample outputs:
3813 vivek vivek
29 10:58:40 2010

transmission

02:44:05 Fri Oct

Another option is /proc/$PID/environ, enter:


# cat /proc/3813/environ

OR
# grep --color -w -a USER /proc/3813/environ

Sample outputs (note --colour option):

Fig.01: grep output

lsof Command Example


Type the command as follows:
lsof -i :portNumber
lsof -i tcp:portNumber

lsof -i udp:portNumber
lsof -i :80
lsof -i :80 | grep LISTEN

Sample outputs:
apache2 1607
(LISTEN)

root

3u IPv4 6472

0t0 TCP *:www

apache2 1616 www-data


(LISTEN)

3u IPv4 6472

0t0 TCP *:www

apache2 1617 www-data


(LISTEN)

3u IPv4 6472

0t0 TCP *:www

apache2 1618 www-data


(LISTEN)

3u IPv4 6472

0t0 TCP *:www

apache2 1619 www-data


(LISTEN)

3u IPv4 6472

0t0 TCP *:www

apache2 1620 www-data


(LISTEN)

3u IPv4 6472

0t0 TCP *:www

Now, you get more information about pid # 1607 or 1616 and
so on:
# ps aux | grep '[1]616'

Sample outputs:
www-data 1616 0.0 0.0 35816 3880 ? S 10:20 0:00

/usr/sbin/apache2 -k start

I recommend the following command to grab info about pid #


1616:
# ps -eo pid,user,group,args,etime,lstart | grep '[1]616'

Sample outputs:
1616 www-data www-data /usr/sbin/apache2 -k start
03:16:22 Fri Oct 29 10:20:17 2010

Where,
1616 : PID
www-date : User name (owner - EUID)
www-date : Group name (group - EGID)
/usr/sbin/apache2 -k start : The command name and its
args

03:16:22 : Elapsed time since the process was started, in


the form [[dd-]hh:]mm:ss.

Fri Oct 29 10:20:17 2010 : Time the command started.

Help: I Discover an Open Port Which I Don't


Recognize At All
The file /etc/services is used to map port numbers and
protocols to service names. Try matching port numbers:
$ grep port /etc/services
$ grep 443 /etc/services

Sample outputs:

https
TLS/SSL

443/tcp

https

443/udp

# http protocol over

Check For rootkit


I strongly recommend that you find out which processes are
really running, especially servers connected to the high speed
Internet access. You can look for rootkit which is a program
designed to take fundamental control (in Linux / UNIX terms
"root" access, in Windows terms "Administrator" access) of a
computer system, without authorization by the system's
owners and legitimate managers. See how to detecting /
checking rootkits under Linux.

Keep an Eye On Your Bandwidth Graphs


Usually, rooted servers are used to send a large number of
spam or malware or DoS style attacks on other computers.
See also:
See the following man pages for more information:
$ man ps
$ man grep
$ man lsof

$ man netstat
$ man fuser

12.how to check the logs

Linux Log Files Location And How Do I View Logs


Files on Linux?
by NI XC RA F T on JULY 17, 2006 76 C O MME N TS LA S T U PD ATED DE CE MBE R 6, 201 4

in CO MMA N D S , FIL E S YS TE M , LIN U X

am a new Linux user. I would like to know where are the log

files located under Debian/Ubuntu or CentOS/RHEL/Fedora


Linux server? How do I open or view log files on Linux
operating systems?
Almost all logfiles are located under /var/log directory and its
sub-directories on Linux. You can change to this directory
using the cd command. You need be the root user to view or
access log files on Linux or Unix like operating systems. You
can use the following commands to see the log files:

Tutorial details
Difficulty
Root privileges

Yes

Requirements

None

Estimated completion time

1.
2.
3.
4.
5.
6.
7.
8.

Easy (rss)

5m

less command
more command
cat command
grep command
tail command
zcat command
zgrep command
zmore command

How do I view log files on Linux?


Open the Terminal or login as root user using ssh command.
Go to /var/log directory using the following cd command:
# cd /var/log

To list files use the following ls command:


# ls

Sample outputs from RHEL 6.x server:


anaconda.ifcfg.log boot.log-20111225 cron-20131110.gz
maillog-20111218
messages-20131103.gz secure20131027.gz spooler-20131117.gz up2date-20131117.gz

anaconda.log
btmp
cron-20131117.gz
maillog-20111225
messages-20131110.gz secure20131103.gz squid
uptrack.log
anaconda.program.log btmp-20120101
cups
maillog-20120101
messages-20131117.gz secure20131110.gz swinstall.d
uptrack.log.1
anaconda.storage.log btmp-20131101.gz dkms_autoinstaller
maillog-20131027.gz mysqld.log
secure-20131117.gz
tallylog
uptrack.log.2
anaconda.syslog
collectl
20131103.gz ntpstats
varnish

dmesg
setroubleshoot

anaconda.yum.log
ConsoleKit
maillog-20131110.gz prelink
wtmp
arcconfig.xml
cron
20131117.gz rhsm
20111211
yum.log
atop
messages
20111218

dmesg.old
spooler

dracut.log
spooler-20111211

maillogUcliEvt.log

up2date

maillogup2date-

cron-20111211
dracut.log-20120101
sa
spooler-20111218
up2dateyum.log-20120101

audit
cron-20111218
dracut.log-20130101.gz
messages-20111211
secure
spooler-20111225
up2date-20111225
yum.log-20130101.gz

boot.log
cron-20111225
20111218
secure-20111211
up2date-20120101

httpd
messagesspooler-20120101

boot.log-20111204
cron-20120101
lastlog
messages-20111225
secure-20111218
spooler20131027.gz up2date-20131027.gz
boot.log-20111211
cron-20131027.gz maillog
messages-20120101
secure-20111225
spooler20131103.gz up2date-20131103.gz
boot.log-20111218
cron-20131103.gz maillog-20111211
messages-20131027.gz secure-20120101
spooler20131110.gz up2date-20131110.gz

To view a common log file called /var/log/messages use any


one of the following command:
# less /var/log/messages
# more -f /var/log/messages
# cat /var/log/messages
# tail -f /var/log/messages
# grep -i error /var/log/messages

Sample outputs:
Jul 17 22:04:25 router dnsprobe[276]: dns query failed

Jul 17 22:04:29 router last message repeated 2 times


Jul 17 22:04:29 router dnsprobe[276]: Primary DNS server Is
Down... Switching To Secondary DNS server
Jul 17 22:05:08 router dnsprobe[276]: Switching Back To
Primary DNS server
Jul 17 22:26:11 debian -- MARK -Jul 17 22:46:11 debian -- MARK -Jul 17 22:47:36 router -- MARK -Jul 17 22:47:36 router dnsprobe[276]: dns query failed
Jul 17 22:47:38 debian kernel: rtc: lost some interrupts at
1024Hz.
Jun 17 22:47:39 debian kernel: IN=eth0 OUT=
MAC=00:0f:ea:91:04:07:00:08:5c:00:00:01:08:00
SRC=61.4.218.24 DST=192.168.1.100 LEN=60 TOS=0x00
PREC=0x00 TTL=46 ID=21599 DF PROTO=TCP SPT=59297
DPT=22 WINDOW=5840 RES=0x00 SYN URGP=0

Common Linux log files names and usage

/var/log/messages

: General message and system related

stuff

: Authenication logs
/var/log/kern.log : Kernel logs
/var/log/cron.log : Crond logs (cron job)
/var/log/auth.log

: Mail server logs


/var/log/qmail/ : Qmail log directory (more files inside this
directory)
/var/log/httpd/ : Apache access and error logs directory
/var/log/lighttpd/ : Lighttpd access and error logs directory
/var/log/boot.log : System boot log
/var/log/mysqld.log : MySQL database server log file
/var/log/secure or /var/log/auth.log : Authentication log
/var/log/utmp or /var/log/wtmp : Login records file
/var/log/yum.log : Yum command log file.
/var/log/maillog

GUI tool to view log files on Linux


System Log Viewer is a graphical, menu-driven viewer that
you can use to view and monitor your system logs. This tool is
only useful on your Linux powered laptop or desktop system.
Most server do not have X Window system installed. You can
start System Log Viewer in the following ways:
Click on System menu > Choose Administration > System
Log:

Sample outputs:

Fig.01 Gnome log file viewer

A note about rsyslogd


All of the above logs are generated using rsyslogd service. It
is a system utility providing support for message logging.
Support of both internet and unix domain sockets enables this
utility to support both local and remote logging. You can view
its config file by tying the following command:
# vi /etc/rsyslog.conf
# ls /etc/rsyslog.d/

You might also like