Pages

Friday, 16 September 2011

Redhat Linux – Creating New Partition table and Filesystem on SAN disk


Redhat Linux – Creating New Partition table and Filesystem on SAN disk



procedure to create a new partition table and a file system on a disk (or LUN) under Linux

1. List the available disks / LUNs with the following command:

# fdisk -l



2. Run the fdisk command against the applicable disk you wish to partition. In this instance we use the example sdb which is the second available disk on this platform:

# fdisk /dev/sdb
Replace ‘sdb’ with the device which represents the disk you wish to modify.

3. Type ‘o’ and press enter to create a new, blank, DOS-style partition table. After doing so, you can type ‘p’ to display the blank partition table, which will appear as the following:

Command (m for help): p

Disk /dev/sdb: 9100 MB, 9100044288 bytes
255 heads, 63 sectors/track, 1106 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

Command (m for help):

4. Press ‘n’ and then enter to create a new partition. You will be prompted for several pieces of information including if to create a primary or extended partition (choose primary), which partition number, and how large of a partition to create. The default values will be to create a partition as large as the entire disk:

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1106, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-1106, default 1106): 1106
After doing so, ‘p’ should show a single partition occupying the entire disk:

Command (m for help): p

Disk /dev/sdb: 9100 MB, 9100044288 bytes
255 heads, 63 sectors/track, 1106 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 1106 8883913+ 83 Linux

5. Write out the changes to the disk by pressing ‘w’ and then enter. This will cause fdisk to exit and return to the command prompt. The command ‘partprobe’ should then be run, or the system restarted, to ensure that the kernel is notified of any partition table changes.

6. A file system can then be created using whatever options are desired on the partition.

For example, to create an ext3 file system one would run:

# mkfs.ext3 /dev/sdb1

Linux Network Troubleshooting


Linux Network Troubleshooting


Network connection problems include slow connections, as well as complete loss of connectivity. Factors that may cause slow connectivity include incorrectly configured domain name system (DNS) settings, inefficiently configured routing tables, inferior cabling, overloaded servers, and network congestion. The same set of factors, as well as power or server failures, may result in complete loss of connectivity.

To troubleshoot a network connectivity problem, you should first check for the presence of a physical connection. If the network interface card (NIC) link light on a system is off, it indicates that no physical connection exists. This may result from

the use of incompatible or damaged cables
loose or unplugged cables
loss of power to a network switch or router
Troubleshooting interface problems

Linux tools you can use to troubleshoot network interface problems include
ifconfig - Used to determine the status of NICs.Without arguments, this command returns the status of all active interfaces. If you specify the name of an interface, it returns the status only of that interface. With the -a argument, the command displays the status of all interfaces on a computer, including any that may be inactive. This is the basic syntax for using the ifconfig command: ifconfig [interface] [options]
mii-tool – The mii-tool utility enables you to display and manipulate the media-independent interface status. In its simplest form, you can use it to display the status of the interface’s link. This is the basic syntax for using the mii-tool command: mii-tool [options] [interface]
ethtool – The ethtool utility is a diagnostic tool that enables you to configure and diagnose problems with NICs. However, not all NICs support its use. This is the basic syntax for using the ethtool command: ethtool [options] interface

Examples:

ifconfig - The output of the ifconfig -a command specifies that the computer has two NICs. The first NIC – eth0 – is up and configured as 192.168.1.200. The second NIC is not currently active.

[gurklindia]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:C0:DF:03:A9:5B
inet addr:192.168.1.100
Bcast:192.168.1.255
Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:26101 errors:0 dropped:0 overruns:0 frame:0
TX packets:15747 errors:0 dropped:0 overruns:0 carrier:0 collisions:116 txqueuelen:1000
RX bytes:2715195 (2.5 Mb)
TX bytes:6330747 (6.0 Mb)
Interrupt:11 Base address:0×6000
eth1 Link encap:Ethernet HWaddr 00:30:18:53:96:26
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b)
TX bytes:0 (0.0 b)
Interrupt:10 Base address:0xec00 lo
Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1

mii-tool - Use mii-tool to print verbose information on the link status and duplex settings for the NICs. The verbose output of the mii-tool command verifies that the eth0 interface link is functioning, and that the eth1 interface link is not.

[root@gurkulindia]# mii-tool -v
eth0: autonegotiation failed,
link ok
product info: vendor
00:00:00, model 0 rev 0
basic mode:
autonegotiation enabled
basic status:
autonegotiation complete,
link ok
capabilities: 100baseTx-FD
100baseTx-HD 10baseT-FD
10baseT-HD
advertising: 100baseTx-FD
100baseTx-HD 10baseT-FD
10baseT-HD flow-control
eth1: no link
product info: vendor
00:40:63, model 50 rev 5
basic mode:
autonegotiation enabled
basic status: no link
capabilities: 100baseTx-FD
100baseTx-HD 10baseT-FD
10baseT-HD
advertising: 100baseTx-FD
100baseTx-HD 10baseT-FD
10baseT-HD flow-control

Ethtool

The output of the ethtool command lists various statistics about the interface, including a verification that it has detected a link.

[root@gurkulindia]# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes
Speed: 10Mb/s
Duplex: Half
Port: MII
PHYAD: 32
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0xffffffff (-1)
Link detected: yes

Troubleshooting network connectivity

Once you’ve eliminated physical interface problems as the cause of a network connectivity problem, you need to isolate other possible causes. These may include local or network configuration errors, or faults with a router.

To help isolate the cause of a network connectivity problem, you need to determine whether a user is
unable to connect to any network

If a user is unable to connect to any network host, the problem most probably lies with the user’s local machine. For example, it may be configured with an incorrect local IP address or incorrect netmask settings.
able to connect to the local network only

If a user can connect only to the local network, then the problem probably lies with incorrectly configured default gateway settings.
able to connect to the internal network but not the Internet

If a user can connect to the internal network but not to the Internet, the problem probably lies with DNS or firewall settings.

Linux supports the following common tools for troubleshooting network connectivity problems:

ping

You use the ping command with the IP address or hostname of a target to check for a basic network connection to it. In its simplest form, the ping command sends Internet Control Message Protocol (ICMP) echo packets to the designated target computer, which – if a connection exists – responds with echo reply packets.

If you can ping an IP address but not the corresponding hostname, it indicates a name resolution problem.

[gurkuindia]$ ping 192.168.1.30 .

The output of the command indicates that the host is responding to ping requests.

[gurkulindia]$ ping 192.168.1.30

PING 192.168.1.30 (192.168.1.30) 56(84) bytes of data.
64 bytes from 192.168.1.30: icmp_seq=0 ttl=128 time=0.405 ms
64 bytes from 192.168.1.30: icmp_seq=0 ttl=128 time=0.405 ms
64 bytes from 192.168.1.30: icmp_seq=0 ttl=128 time=0.405 ms
64 bytes from 192.168.1.30: icmp_seq=0 ttl=128 time=0.405 ms

— 192.168.1.30 ping
statistics — 4 packets transmitted, 4 received, 0% packet loss, time 3009ms
rtt min/avg/max/mdev = 0.300/0.342/0.405/0.042 ms, pipe 2

traceroute

You use the traceroute command to identify and diagnose each hop in the route that packets take between two hosts. With the command, you specify the IP address or the hostname of the target host. You can also use one or more traceroute options.

The output of the traceroute command indicates that packets are reaching the default gateway of the network, but do not go any further. This is probably the result of packets being dropped by the network firewall.

[gurkulindia ~]$ traceroute 192.168.3.120
traceroute to 192.168.3.120 (192.168.1.120), 30 hops max, 38 byte packets
1 ny-fs01 (192.168.1.100) 0.384 ms 0.356 ms 0.291 ms
2 ny-fs22 (192.168.2.120) 0.434 ms 0.367 ms 0.287 ms
3 * * *

netstat – The netstat command is a complex utility that you can use to list different types of network statistics. Without options, it returns statistics about current TCP/IP connections, including the protocol, MAC address, IP address, and state of each connection.

Suppose you want to use the ping command to test for a connection to the ny-ws30 host. You are not sure if there are any problems with the DNS server, so you want to ping the host by its IP address.

Examples:

The netstat -s command returns summarized statistics for each network protocol.

[gurkulindia]$ netstat -s

Ip:
19095 total packets received
0 forwarded
0 incoming packets discarded
19024 incoming packets delivered
18971 requests sent out
Icmp:
72 ICMP messages received
0 input ICMP message failed.
ICMP input histogram:
destination unreachable: 68
echo replies: 4
68 ICMP messages sent
0 ICMP messages failed
ICMP output histogram:
destination unreachable: 68
Tcp:
10 active connections openings
7 passive connection openings
0 failed connection attempts
0 connection resets received

inetd Vs xinetd in linux


inetd Vs xinetd in linux


The inetd daemon

The inetd daemon is best described as a super-server, created to manage many daemons or services. It listens to multiple ports, and invokes only requested services.

This reduces the load that services place on a system, because it means that network services – such as telnet, File Transfer Protocol (FTP), and Simple Mail Transfer Protocol (SMTP) – can be activated on demand rather than having to run continuously.

When a system initializes, the inetd daemon needs to determine its configuration information. To do this, the daemon accesses two files – /etc/services and /etc/inetd.conf.

The /etc/services file contains a list of network services and the ports to which they map. Network services have standard default ports on which client machines can find them. This enables clients to connect to particular services. For instance, HTTP uses port 80, FTP uses port 21, and telnet uses port 23.

Entries in the /etc/services file are divided into 4 fields,
servicename – The servicename field specifies the name of a network service. Typical entries include telnet, File Transfer Protocol (FTP), and Post Office Protocol (POP).
port/protocol – The port/protocol field identifies the number of the port and the protocol – or communication standard – that a service uses. The protocol is usually Transmission Control Protocol (TCP) or User Datagram Protocol (UDP). Both port and protocol entries should be included.
aliases – The aliases field specifies any alternative names for a network service. For instance, a common alias for www is HTTP. This field is optional.
Comment – The comment field is an optional field in which you can enter any additional information about a service.

e.g.

service-name port/protocol [aliases ...] [# comment]
pop2 109/tcp pop-2 postoffice # pop version
pop2 109/udp pop-2
pop3 110/tcp pop-3 postoffice # pop version 3
pop3 110/udp pop-3 postoffice

Another configuration file, /etc/inetd.conf, contains a list of network services that tell inetd which ports to listen to and which server programs to run in response to service requests. Each entry in the /etc/inetd.conf file consists of seven fields.
service_name – The service_name field identifies a network service. The service name should be listed as it is defined in the /etc/services file. Any internal service should be given its official name.
socket_type – The socket_type field identifies the type of port or virtual connection – usually stream or dgram (datagram) – that a network service uses. TCP services use stream and UDP services use dgram. Less common socket type values include raw, rdm, and seqpacket.
protocol – The protocol field identifies the communication standard that a network service uses. Its value is usually TCP or UDP. This field should contain one of the protocols listed in the /etc/protocols file and should match the protocol field of a service’s entry in the /etc/services file.
flags – The flags field specifies the behavior of inetd after it invokes a server in response to a service request. Multithreaded TCP servers free the port after it starts and enable inetd to invoke a new instance of the server to handle new requests. Single-threaded UDP servers cannot free the port until the server has finished running. So you should always set dgram sockets to wait and all other socket types to nowait.
user – The user field identifies the user account under which a service must run. The username should be defined in the /etc/passwd file and is often set to root. You can also specify a group name by placing a dot between the user and group names.
server_path - The server_path field contains the pathname of the server that the inetd daemon must invoke when it receives a service request. In most cases, this field reads /usr/sbin/tcpd, where tcpd is responsible for controlling access to network services. If the network service is one of inetd’s local services, the entry for this field should also be local.
arguments – The arguments field enables you to specify command-line arguments for the server daemon. The first argument, argv[0], is the daemon name and is always present, except in the case of internal services. If the server daemon is tcpd, an argument must specify the name of the service that tcpd must invoke.

e.g.
ftp stream tcp nowait root /usr/sbin/tcpd
#telnet stream tcp nowait root /usr/sbin/tcpd
shell stream tcp nowait root /usr/sbin/tcpd
#login stream tcp nowait root /usr/sbin/tcpd
talk dgram udp wait nobody.tty /usr
ntalk dgram udp wait nobody.tty /usr
finger stream tcp nowait nobody /usr/sbin/tcpd

TIP: single command to check currently enabled services from /etc/inted.conf

[root@easynomad1 grosetti]# grep -v “^#” /etc/inetd.conf
Whenever we modify the /etc/inetd.conf file, you need to refresh inetd to implement the new settings.

To do this, you can use the stop command and then the start command. Alternatively, you can use either the restart or the reload commands. One drawback of the inetd daemon is that it needs to load and initialize a new process before it can handle a new request. This slows down response times.

So if a service has a high number of connections and requires high data processing, you should run it as a standalone daemon rather than using inetd to invoke it. Suppose that you want inetd to invoke the telnet service. Before you do this, you first need to check which inetd services are currently enabled.
The xinetd daemon

In linux, the extended Internet services daemon (xinetd) replaced inetd. It performs the same function as inetd in that it listens to multiple ports and invokes a requested service. However, it is more secure. Typical xinetd services include Remote Shell (RSH), FTP, telnet, and Post Office Protocol 3 (POP3).
Like the inetd daemon, xinetd needs to load and initialize a new process before it can handle a new request. If a network handles a large volume of e-mail, for example, the xinetd daemon would need to invoke the mail service for each mail request individually, resulting in an extremely slow response time. So it’s preferable to run the network’s mail service as a standalone daemon.

It’s also common to run the HTTP, sendmail, ident, and Samba services as standalone daemons. Services that xinetd manages are not encrypted. However, each service has its own level of authentication, which limits their use to trusted users and helps prevent denial-of-service (DoS) attacks.

The xinetd daemon is incompatible with inetd because its configuration file has a different format. However, a program is available that converts the inetd file into the required format.
The xinetd daemon uses the /etc/xinetd.conf file to set the parameters for the services that it manages.

The /etc/xinetd.conf file contains six parameters.
instances – The instances parameter specifies the maximum number of services that xinetd can invoke at the same time.
log_type – The log_type parameter sets xinetd to use the SYSLOG authpriv facility.
log_on_success – The log_on_success parameter specifies the logging information when a connection is successful. Typical values include PID, HOST, and USERID.
log_on_failure – The log_on_failure parameter specifies the logging information when a connection fails. Typical values include HOST and USERID.
cps – The cps parameter controls the rate of incoming connections. The first argument specifies the maximum number of connections. The second argument specifies how long xinetd is disabled.
includedir – The includedir parameter specifies the directory that xinetd must read for specific configurations.

Unlike the inetd daemon, the xinetd daemon doesn’t need the services in its configuration file to be listed in the services file. Each service’s configuration file has a disable parameter, which has yes as the default value. You can enable a service by manually changing the value of the disable parameter to no.
You can enable / disable services under xinetd. With below commands

# chkconfig service_name on
# chkconfig service_name off

If you modify the /etx/xinter.conf you need to refresh the service with below command

[root@easynomad1 grosetti]# service xinetd reload
Reloading configuration: [ OK ]
[root@easynomad1 grosetti]#
Configuring xinted

The /etc/xinetd.conf file sets the basic parameters for all services that xinetd manages. It sets the number of active servers, specifies logging settings, limits the number of incoming connections, and reads all files in /etc/xinetd.d.
For any xinetd managed service to work as required, you need to configure its settings correctly in the /etc/xinetd.d configuration file. Each xinetd service configuration file contains a disable parameter, which is set to yes by default. To enable a service, you need to set the disable parameter to no.

service telnet
{
disable = yes
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/telnetd
server_args = -a none
log_on_failure += USERID
}

Once you’ve modified entries in the /etc/xinetd.conf file, you need to refresh or restart the xinetd daemon to accept the changes. To refresh the xinetd daemon, you can use the following options:
stop – You use the stop option in the following command to shut down the xinetd daemon completely:

# /etc/rc.d/init.d/xinetd stop

The stop option temporarily interrupts the daemon’s services while it is stopped.
Start - You use the start option in the following command to restart the xinetd daemon after you’ve stopped it:

# /etc/rc.d/init.d/xinetd start

The start option temporarily interrupts the daemon’s services while it is stopped.

restart – You use the restart option in the following command to stop and start xinetd using one command:

# /etc/rc.d/init.d/xinetd restart

The restart option temporarily interrupts the daemon’s services while it is stopped.

reload – You use the reload option in the following command to refresh the xinetd daemon without interrupting services:

#/etc/rc.d/init.d/xinetd reload

TIP : You can refresh the xinetd daemon by sending it a SIGHUP signal using this command, which forces xinetd to reread its configuration file.with minimal disruption to the services

[root@easynomad1 grosetti]# killall -SIGHUP xinetd
[root@easynomad1 grosetti]#

Post titleBasis Filesystem Management in Linux


Basis Filesystem Management in Linux

Basis Filesystem Management in Linux

In this doc I am trying to present base for Linux Filesystem. I tried to cover Theoratical and Pratical portition where-ever it is necessary.

What is Filesystem

In simple term you can say a FS is a medium to access your files/directories in any Unix Flavour. In Unix each and every thing is File or Directory. In order to standardize Files or Directories structure Filesystem are used.

Now in depth you can say a FS is a portion of your harddisk (or complete harddisk) which is used to create files and directories which are world-wide accessiable.

Linux Filesystem routemap

1.) Identify Device –> which may be your internal harddisk or external storage. (/dev/sd{a,b,c,….} —> SCSI , /dev/hd{a,b,c,…} —> IDE)

2.) Partition Device –> Disks are partitioned to make seperate Filesystems as per requirement.

3.) Make Filesystem –> Partitions are used to make Filesystems so that they can be recognised by the OS.

4.) Mountpoint –> Mountpoints are nothing but just are simple directories where Filesystems are mapped. Its easy to remember simple directory names as compare to complete FS name.

5.) Make FS permanent after reboot –> The FS entry should be made under a special file called /etc/fstab which is used by init phase to mount all the filesystems listed under /etc/fstab.

Practical Example

1.) Identify Device — I have three internal disk in the server, you can check that by fdisk -l & cat /proc/partition

Here sda —>; is my root disk
sdb & sdc are newly attached disk which I will be using for FS creation.

yogesh-Linux#fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1305 10377990 8e Linux LVM
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn’t contain a valid partition table
yogesh-Linux#cat /proc/partitions
major minor #blocks name
8 0 10485760 sda
8 1 104391 sda1
8 2 10377990 sda2
8 16 1048576 sdb
8 32 1048576 sdc
253 0 9306112 dm-0
253 1 1048576 dm-1

2.) Partition Device –> We will partition the disks to create FS on them. In Linux on SCSI drives you can create 3 Primary Partitions and 1 Extended Partition. The extended partion is further used to create Logical partitions which can be treated as Primary partition by dependable to extended partition. The maximum supportable no. of partitions in SCSI drivers are 15 and IDE are 63.

In the below example I will create both primary and extended partitions for handson practice. I am using /dev/sdc disk and creating Primary partition first.

Primary Partition

yogesh-Linux#fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won’t be recoverable.

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

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130): 40

Command (m for help): p

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System /dev/sdc1 1 40 321268+ 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
yogesh-Linux#

yogesh-Linux#cat /proc/partitions
major minor #blocks name

8 0 10485760 sda
8 1 104391 sda1
8 2 10377990 sda2
8 16 1048576 sdb
8 32 1048576 sdc
8 33 321268 sdc1
253 0 9306112 dm-0
253 1 1048576 dm-1

yogesh-Linux#partprobe /dev/sdc1
Why Partporbe in Linux?

At system bootup, the kernel makes its own in-memory copy of the partition tables from the disks. Most tools like
fdisk edit the on-disk copy of the partition tables. To update the in-memory copies, run partprobe.

Extended Partition

yogesh-Linux#fdisk /dev/sdc

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 2
First cylinder (41-130, default 41):
Using default value 41
Last cylinder or +size or +sizeM or +sizeK (41-130, default 130): 100

Command (m for help): p

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdc1 1 40 321268+ 83 Linux
/dev/sdc2 41 100 481950 5 Extended ———> this extended partition can be divided into Logical partitions between 41 to 100 cylinders

Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (41-100, default 41):
Using default value 41
Last cylinder or +size or +sizeM or +sizeK (41-100, default 100): 60

Command (m for help): p

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdc1 1 40 321268+ 83 Linux
/dev/sdc2 41 100 481950 5 Extended
/dev/sdc5 41 60 160618+ 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
yogesh-Linux#

yogesh-Linux#cat /proc/partitions

major minor #blocks name

8 0 10485760 sda
8 1 104391 sda1
8 2 10377990 sda2
8 16 1048576 sdb
8 32 1048576 sdc
8 33 321268 sdc1
8 34 1 sdc2
8 37 160618 sdc5
253 0 9306112 dm-0
253 1 1048576 dm-1

yogesh-Linux#partprobe /dev/sdc5
yogesh-Linux#

3.) Make Filesystem —> Next we have to proceed with filesystem creation in Linux, with Linux RHEL version 5 the default Filesystem type in ext3 so we will take ext3 throughout over practical session. Though you can use ext2 or raiserFS or any other Linux supported filesystem.

mkfs is the command used to create FS in Linux, for more details kindly refer man for mkfs.
yogesh-Linux#mkfs -t ext3 /dev/sdc1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
80320 inodes, 321268 blocks
16063 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
40 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 21 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
yogesh-Linux#

yogesh-Linux#mkfs -t ext3 /dev/sdc5
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
40160 inodes, 160616 blocks
8030 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
20 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
yogesh-Linux#

4.) Mountpoint —> Mountpoint is just a directory on to which the FS is mapped to make the FS accessiable.

yogesh-Linux#mkdir /yogesh-primary-test

yogesh-Linux#mkdir /yogesh-extended-test

yogesh-Linux#mount /dev/sdc1 /yogesh-primary-test

yogesh-Linux#mount /dev/sdc5 /yogesh-extended-test

yogesh-Linux#df -h /yogesh*
Filesystem Size Used Avail Use% Mounted on
/dev/sdc5 152M 5.6M 139M 4% /yogesh-extended-test
/dev/sdc1 304M 11M 279M 4% /yogesh-primary-test
yogesh-Linux#

yogesh-Linux#cd /yogesh-extended-test
yogesh-Linux#ls -lrt
total 12
drwx—— 2 root root 12288 Aug 15 21:15 lost+found

yogesh-Linux#touch yogesh-test
yogesh-Linux#cp /var/log/messages /yogesh-extended-test/yogesh-test
cp: overwrite `/yogesh-extended-test/yogesh-test’? y

yogesh-Linux#ls -lrt
total 51
drwx—— 2 root root 12288 Aug 15 21:15 lost+found
-rw-r–r– 1 root root 37057 Aug 15 21:22 yogesh-test
yogesh-Linux#

5.) Make FS permanent after reboot (significance of /etc/fstab) –> Till this point of time the Filesystem’s are not permnenly mounted. For eg if your system crashed the above listed FS will not come up as mounted FS. To make them visible across reboots we have to make their entries in /etc/fstab.

Below is the example:

yogesh-Linux#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
8.6G 2.2G 6.1G 27% /
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 250M 0 250M 0% /dev/shm
/dev/sdc1 304M 11M 279M 4% /yogesh-primary-test
/dev/sdc5 152M 5.6M 139M 4% /yogesh-extended-test

yogesh-Linux#umount /yogesh-primary-test

yogesh-Linux#umount /yogesh-extended-test

yogesh-Linux#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
8.6G 2.2G 6.1G 27% /
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 250M 0 250M 0% /dev/shm

yogesh-Linux#mount -a

yogesh-Linux#df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
9014656 2250392 6298960 27% /
/dev/sda1 101086 12512 83355 14% /boot
tmpfs 255296 0 255296 0% /dev/shm
yogesh-Linux#

See the FS which we have created are not coming up once they are umounted. This is bzu once we execute mount -a command kernel start reading entries from /etc/fstab.

It will mount all the FS listed in /etc/fstab. Below is the current /etc/fstab where their is no entry for the FS which are newly created. lets add them and then check the results.

yogesh-Linux#more /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
LINUX1:/yogesh /nfstest nfs defaults 0 0
yogesh-Linux#

Amend the entries using vi /etc/fstab as shown below:

yogesh-Linux#more /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
LINUX1:/yogesh /nfstest nfs defaults 0 0
/dev/sdc1 /yogesh-primary-test ext3 defaults 0 0
/dev/sdc5 /yogesh-extended-test ext3 defaults 0 0
yogesh-Linux#mount -a

yogesh-Linux#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
8.6G 2.2G 6.1G 27% /
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 250M 0 250M 0% /dev/shm
/dev/sdc1 304M 11M 279M 4% /yogesh-primary-test
/dev/sdc5 152M 5.6M 139M 4% /yogesh-extended-test
yogesh-Linux#
All FS are visible and persists across reboots now.

Experience LINUX LVM (Logical Volume Manager) with real time examples


Experience LINUX LVM (Logical Volume Manager) with real time examples

1.) What LVM is?

2.) Terminology

3.) Creation of Physical Vol, Volume Group, Logical Volume, Filesystem creation, Mount and making the FS entry in /etc/fstab

4.) Add new disk under existing Volume Group

5.) Filesystem extension in Linux

6.) Filesystem shrinking in Linux

7.) Removing disk from existing Volume Group

8.) Special Note







1.) What LVM is?


LVM stands for Logical Volume Manger, Its a way of presenting Harddrivers/Storage to Operating System in a well defined, user understandale, logical way.
OR
LVM is a method of allocating hard drive space into logical volumes that can be easily resized instead of partitions.
OR
With LVM, the hard drive or set of hard drives is allocated to one or more physical volumes.

2.) Terminology:

a.) Harddrive/Storage Luns —> The physical media where are read and writes occured.

b.) Physical Volume —> The actual harddrive or a partition of harddrive can be assigned to Physical Volume. Its the smallest building unit in Linux LVM.

c.) Volume group —> The combination of Physical Volume is used to make a Volumegroup. You can think Volumegroup as a Pool of harddrives/partiotions.

d.) Logical Volume —> We can create Logical Volume on any Volumegroup which indeed are created on Physical Volume which indeed are on Physical disks.

e.) Mountpoint —> The Filesystem is created on Logical Volume and is mounted on mountpoint which is only a simple directory to make the Filesystem open to world for read write operations.

In simple:

PHYSICAL MEDIA ——->

PHYSICALVOLUME——>

VOLUMEGROUP ———>

LOGICALVOLUME ——>

MOUNTPOINT—>

ALL READY FOR YOU.:-)

Hard-disk, LUN Harddisk or partition Logical-storage-pool Base for Filesystem creation




3.) Creation of Physical Vol, Volume Group, Logical Volume, Filesystem creation, Mount and making the FS entry in /etc/fstab

Before proceeding I would like to make all Linux Beginners familiar with Partition Types, In Linux after making partition we have to choose the Partition Type according to the Filesystem we are going to create and use.

Linux-specific partitions would normally be one of the following types:
• 5 (or f) — Extended
• 82 — Linux swap
• 83 — Linux
• 8e — Linux LVM
• fd — Linux RAID auto

Commands used:

pvcreate
pvdisplay

vgcreate
vgdisplay

lvcreate -L or -l (by default is 4MB in Linux) -n
lvdisplay /dev/vgname/logicalvol-name

In example I am using 2 harddrive /dev/sdb & /dev/sdc for presenting LVM in Linux. I will use /dev/sdb to create PV, VG & LV and latter point of time I will add /dev/sdc in the existing VG and then we will perform online Filesystem resizing (extension and shrinking).

You can use complete disk or a portion of disk, I am taking complete disk in the example under primary partition 1.

yogesh-Linux#fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1305 10377990 8e Linux LVM

Disk /dev/sdb: 2147 MB, 2147483648 bytes ————————–> First Drive
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn’t contain a valid partition table

Disk /dev/sdc: 2147 MB, 2147483648 bytes ————————–> second Drive
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn’t contain a valid partition table
yogesh-Linux#

yogesh-Linux#cat /proc/partitions
major minor #blocks name

8 0 10485760 sda
8 1 104391 sda1
8 2 10377990 sda2
8 16 2097152 sdb
8 32 2097152 sdc
253 0 9306112 dm-0
253 1 1048576 dm-1
yogesh-Linux#

yogesh-Linux#fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won’t be recoverable.

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

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id ————————> To change partition ID
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 261 2096451 83 Linux ————> Here the ID is 83 for simple Linux FS.

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): L

0 Empty 1e Hidden W95 FAT1 80 Old Minix bf Solaris
1 FAT12 24 NEC DOS 81 Minix / old Lin c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 82 Linux swap / So c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 83 Linux c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 84 OS/2 hidden C: c7 Syrinx
5 Extended 41 PPC PReP Boot 85 Linux extended da Non-FS data
6 FAT16 42 SFS 86 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS 4d QNX4.x 87 NTFS volume set de Dell Utility
8 AIX 4e QNX4.x 2nd part 88 Linux plaintext df BootIt
9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS eb BeOS fs
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT
f W95 Ext’d (LBA) 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a6 OpenBSD f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f1 SpeedStor
12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f4 SpeedStor
14 Hidden FAT16 we have changed it to 8e as per Linux Kernel Architecture

Command (m for help): p

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 261 2096451 8e Linux LVM ———–> 8e for Linux LVM

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
yogesh-Linux#
yogesh-Linux#
yogesh-Linux#cat /proc/partitions
major minor #blocks name

8 0 10485760 sda
8 1 104391 sda1
8 2 10377990 sda2
8 16 2097152 sdb
8 17 2096451 sdb1
8 32 2097152 sdc
253 0 9306112 dm-0
253 1 1048576 dm-1

yogesh-Linux#partprobe /dev/sdb1
yogesh-Linux#

yogesh-Linux#fdisk /dev/sdc ——————————> Similar process for 2nd disk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel.

Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won’t be recoverable.

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

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdc1 1 261 2096451 8e Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
yogesh-Linux#
yogesh-Linux#cat /proc/partitions
major minor #blocks name

8 0 10485760 sda
8 1 104391 sda1
8 2 10377990 sda2
8 16 2097152 sdb
8 17 2096451 sdb1
8 32 2097152 sdc
8 33 2096451 sdc1
253 0 9306112 dm-0
253 1 1048576 dm-1
yogesh-Linux#partprobe /dev/sdc1
yogesh-Linux#

yogesh-Linux#pvcreate /dev/sdb1 —————————–> Physical Volume Creation
Physical volume “/dev/sdb1″ successfully created
yogesh-Linux#

yogesh-Linux#vgcreate gurkulgroup /dev/sdb1 ——————–> Volume group creation
/dev/cdrom: open failed: Read-only file system
/dev/cdrom: open failed: Read-only file system
Attempt to close device ‘/dev/cdrom’ which is not open.
Volume group “gurkulgroup” successfully created
yogesh-Linux#
yogesh-Linux#

yogesh-Linux#pvdisplay /dev/sdb1
— Physical volume —
PV Name /dev/sdb1
VG Name gurkulgroup
PV Size 2.00 GB / not usable 3.32 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 511
Free PE 511
Allocated PE 0
PV UUID 90ikep-gxVd-oLkf-1YGO-s0dl-JkqQ-zTqY7a

yogesh-Linux#vgdisplay gurkulgroup
— Volume group —
VG Name gurkulgroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 2.00 GB
PE Size 4.00 MB ——————-> This PE is the physical extents (Physical Volumes are defined with Phyisical Extents of a fixed size)
Total PE 511
Alloc PE / Size 0 / 0
Free PE / Size 511 / 2.00 GB
VG UUID OBnNzV-RWvO-Gvy0-L1rb-Brh1-IiIH-33Mpnc

yogesh-Linux#lvcreate -L 1.5g -n gurkulvolume gurkulgroup —————-> Logical Volume Creation
Logical volume “gurkulvolume” created
yogesh-Linux#

yogesh-Linux#lvdisplay /dev/gurkulgroup/gurkulvolume
— Logical volume —
LV Name /dev/gurkulgroup/gurkulvolume
VG Name gurkulgroup
LV UUID BAS7wh-VZDt-l9rg-mdcf-srQr-yEY2-q9dTsK
LV Write Access read/write
LV Status available
# open 0
LV Size 1.50 GB
Current LE 384
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:2

yogesh-Linux#mkfs -t ext3 /dev/gurkulgroup/gurkulvolume ——————–> Filesystem creation
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
196608 inodes, 393216 blocks
19660 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=402653184
12 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information:
done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
yogesh-Linux#

yogesh-Linux#mkdir /gurkultest —————————————> Mountpoint
yogesh-Linux#

yogesh-Linux#mount /dev/gurkulgroup/gurkulvolume /gurkultest ———–> FS mounted
yogesh-Linux#

yogesh-Linux#df -h /gurkultest
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/gurkulgroup-gurkulvolume
1.5G 35M 1.4G 3% /gurkultest

yogesh-Linux# vi /etc/fstab
yogesh-Linux#more /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
LINUX1:/yogesh /nfstest nfs defaults 0 0
#/dev/sdc1 /yogesh-primary-test ext3 defaults 0 0
#/dev/sdc5 /yogesh-extended-test ext3 defaults 0 0
#/dev/raidgroup/raidvol /test-raid ext3 defaults 0 0
/dev/gurkulgroup/gurkulvolume /gurkultest ext3 defaults 0 0 ————-> entry in fstab, to make FS persistent across reboots
yogesh-Linux#

Test on the Permanent existence of Mountpoint created:


yogesh-Linux#umount /gurkultest
yogesh-Linux#

yogesh-Linux#mount -a
mount: mount to NFS server ‘LINUX1′ failed: System Error: No route to host.
yogesh-Linux#

yogesh-Linux#df -h /gurkultest
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/gurkulgroup-gurkulvolume
1.5G 35M 1.4G 3% /gurkultest
yogesh-Linux#





4.) Add new disk under existing Volume Group:

Here in this section we will add one new disk under our existing volumegroup. This is the practical situation where some SA’s needs to extend and shrink Filesystems on regular basis, before proceeding with the Online resizing SA needs to take the disk under OS control and then assign it to existing VG. The process is same as we mentioned above but some commands will be changed as now we are expanding already existed VG.

yogesh-Linux#df -h /gurkultest
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/gurkulgroup-gurkulvolume
1.5G 35M 1.4G 3% /gurkultest

yogesh-Linux#vgdisplay gurkulgroup
— Volume group —
VG Name gurkulgroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 2.00 GB ——————————> VG size is 2GB i.e the size of /dev/sdb disk
PE Size 4.00 MB
Total PE 511
Alloc PE / Size 384 / 1.50 GB
Free PE / Size 127 / 508.00 MB
VG UUID OBnNzV-RWvO-Gvy0-L1rb-Brh1-IiIH-33Mpnc

yogesh-Linux#fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1305 10377990 8e Linux LVM

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 261 2096451 8e Linux LVM

Disk /dev/sdc: 2147 MB, 2147483648 bytes ————————————————> extra disk to add under VG
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdc1 1 261 2096451 8e Linux LVM
yogesh-Linux#

yogesh-Linux#pvcreate /dev/sdc1 ———————————–> Physical volume create for /dev/sdc
Physical volume “/dev/sdc1″ successfully created
yogesh-Linux#

yogesh-Linux#pvdisplay ——————-> I have my rootdisk under LVM so dont get confused with /dev/sda (its my rootdisk), just concentarte on /dev/sd{b,c}
— Physical volume —
PV Name /dev/sdb1
VG Name gurkulgroup
PV Size 2.00 GB / not usable 3.32 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 511
Free PE 127
Allocated PE 384
PV UUID 90ikep-gxVd-oLkf-1YGO-s0dl-JkqQ-zTqY7a

— Physical volume —
PV Name /dev/sda2
VG Name VolGroup00
PV Size 9.90 GB / not usable 22.76 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 316
Free PE 0
Allocated PE 316
PV UUID md04K8-UyPp-X8G8-KZ7F-Vvm0-jbev-x0SClg

“/dev/sdc1″ is a new physical volume of “2.00 GB” ———————-> its not yet assigned to any VG
— NEW Physical volume —
PV Name /dev/sdc1
VG Name
PV Size 2.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID JN8wPA-8mAt-9P2E-DYM0-QLYR-uubc-HeeOqb

yogesh-Linux#

yogesh-Linux#vgextend gurkulgroup /dev/sdc1 ———————> Volumegroup has been added with one new PV.
/dev/cdrom: open failed: Read-only file system
/dev/cdrom: open failed: Read-only file system
Attempt to close device ‘/dev/cdrom’ which is not open.
Volume group “gurkulgroup” successfully extended
yogesh-Linux#

yogesh-Linux#vgdisplay gurkulgroup
— Volume group —
VG Name gurkulgroup
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 3.99 GB
PE Size 4.00 MB ——————————-> The size has been increasedto 4Gb as our disk are 2GB each.
Total PE 1022
Alloc PE / Size 384 / 1.50 GB
Free PE / Size 638 / 2.49 GB
VG UUID OBnNzV-RWvO-Gvy0-L1rb-Brh1-IiIH-33Mpnc

yogesh-Linux#

yogesh-Linux#df -h /gurkultest/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/gurkulgroup-gurkulvolume
1.5G 35M 1.4G 3% /gurkultest
yogesh-Linux#





5.) Filesystem extension in Linux (How to grow Filesystem Online in Linux i.e Online resizing)

The online resizing in Linux is very simple but needs to be perform with full caution.

At this point of time we have VG of 4GB with two PV’s and our Filesystem is of 1.5GB, we will increase it to 3GB and will check what the results will be. Kindly refer above outputs before proceeding.

Add new storage —-> Partition it —-> Create PV —-> Take PV under existing VG i.e extend VG —-> Extend Logical Volume —-> resize Filesystem —-> Allready with No Downtime.

yogesh-Linux#lvextend -L +1.5g /dev/gurkulgroup/gurkulvolume
Extending logical volume gurkulvolume to 3.00 GB
Logical volume gurkulvolume successfully resized
yogesh-Linux#

yogesh-Linux#df -h /gurkultest —————-> At this point of tme only Volume has been extended, we also need to resize the FS to reflect the results
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/gurkulgroup-gurkulvolume
1.5G 35M 1.4G 3% /gurkultest

yogesh-Linux#resize2fs /dev/gurkulgroup/gurkulvolume
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/gurkulgroup/gurkulvolume is mounted on /gurkultest; on-line resizing required
Performing an on-line resize of /dev/gurkulgroup/gurkulvolume to 786432 (4k) blocks.
The filesystem on /dev/gurkulgroup/gurkulvolume is now 786432 blocks long.

yogesh-Linux#df -h /gurkultest ———————————–> Our filesystem is increased to 3GB now
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/gurkulgroup-gurkulvolume
3.0G 35M 2.8G 2% /gurkultest
yogesh-Linux#
6.) Filesystem shrinking in Linux: (How to reduce Filesystem):

In any OS the Shrinking should be peformed with extracare. It you will try to reduce the Filesystem more than space which is free in the FS, dataloss will occur.

Suppose your FS is of 3GB and out of which 2.5GB is used, here if you will try to reduce the FS to 2GB the dataloss will occur.

So best plan before proceeding with any FS shrinking operations, recommended would be to take the Backup before going ahead.

Below I am taking some backups in /gurkultest FS to show that no dataloss will occur if will reduce the FS if space is not used. I will reduce the Filesystem to 1GB.

Unmount the FS —-> Run Fsck —-> resize FS —-> resize existing volume —-> MountFS —-> All Done (Filesystem wont be available during the operation) i.e downtime for the FS is required.

yogesh-Linux#cp -p /var/log/messages /gurkultest

yogesh-Linux#df -h /gurkultest/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/gurkulgroup-gurkulvolume
3.0G 35M 2.8G 2% /gurkultest
yogesh-Linux#

yogesh-Linux#resize2fs /dev/gurkulgroup/gurkulvolume 1g —————-> Reduction wont allowed unless and until you will umount the FS
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/gurkulgroup/gurkulvolume is mounted on /gurkultest; on-line resizing required
On-line shrinking from 786432 to 262144 not supported.
yogesh-Linux#

yogesh-Linux#umount /gurkultest
yogesh-Linux#

yogesh-Linux#resize2fs /dev/gurkulgroup/gurkulvolume 1g ————> We have to proceed with fsck to check any dada inconsistency for the FS
resize2fs 1.39 (29-May-2006)
Please run ‘e2fsck -f /dev/gurkulgroup/gurkulvolume’ first.
yogesh-Linux#

yogesh-Linux#e2fsck -f /dev/gurkulgroup/gurkulvolume
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/gurkulgroup/gurkulvolume: 13/393216 files (7.7% non-contiguous), 21147/786432 blocks
yogesh-Linux#

yogesh-Linux#resize2fs /dev/gurkulgroup/gurkulvolume 1g
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/gurkulgroup/gurkulvolume to 262144 (4k) blocks.
The filesystem on /dev/gurkulgroup/gurkulvolume is now 262144 blocks long.
yogesh-Linux#

yogesh-Linux#lvreduce /dev/gurkulgroup/gurkulvolume -L 1g ——————> I am reducing Logical Vol to 1GB
WARNING: Reducing active logical volume to 1.00 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce gurkulvolume? [y/n]: y
Reducing logical volume gurkulvolume to 1.00 GB
Logical volume gurkulvolume successfully resized
yogesh-Linux#

yogesh-Linux#mount /dev/gurkulgroup/gurkulvolume /gurkultest/
yogesh-Linux#

yogesh-Linux#df -h /gurkultest/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/gurkulgroup-gurkulvolume
1008M 34M 933M 4% /gurkultest

yogesh-Linux#cd /gurkultest/
yogesh-Linux#ls

lost+found messages test

yogesh-Linux#ls -lrt —————————————-> No dataloss occured, messages file is preserved
total 104
drwx—— 2 root root 16384 Aug 17 19:22 lost+found
-rw——- 1 root root 74125 Aug 17 19:24 messages
-rw-r–r– 1 root root 0 Aug 17 19:37 test
yogesh-Linux#

7.) Removing disk from existing Volume Group:

Lets check the complete outputs before proceeding with the Disk removal from VG.

yogesh-Linux#pvdisplay
— Physical volume —
PV Name /dev/sdb1
VG Name gurkulgroup
PV Size 2.00 GB / not usable 3.32 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 511
Free PE 255
Allocated PE 256
PV UUID 90ikep-gxVd-oLkf-1YGO-s0dl-JkqQ-zTqY7a

— Physical volume —
PV Name /dev/sdc1
VG Name gurkulgroup
PV Size 2.00 GB / not usable 3.32 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 511
Free PE 511
Allocated PE 0
PV UUID JN8wPA-8mAt-9P2E-DYM0-QLYR-uubc-HeeOqb

— Physical volume —
PV Name /dev/sda2
VG Name VolGroup00
PV Size 9.90 GB / not usable 22.76 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 316
Free PE 0
Allocated PE 316
PV UUID md04K8-UyPp-X8G8-KZ7F-Vvm0-jbev-x0SClg

yogesh-Linux#vgdisplay
— Volume group —
VG Name gurkulgroup
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 3.99 GB
PE Size 4.00 MB
Total PE 1022
Alloc PE / Size 256 / 1.00 GB
Free PE / Size 766 / 2.99 GB
VG UUID OBnNzV-RWvO-Gvy0-L1rb-Brh1-IiIH-33Mpnc

— Volume group —
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 9.88 GB
PE Size 32.00 MB
Total PE 316
Alloc PE / Size 316 / 9.88 GB
Free PE / Size 0 / 0
VG UUID 53YyKs-D2uQ-0gVY-My3w-6QOi-KDQ8-9dFUjF

yogesh-Linux#lvdisplay
— Logical volume —
LV Name /dev/gurkulgroup/gurkulvolume
VG Name gurkulgroup
LV UUID BAS7wh-VZDt-l9rg-mdcf-srQr-yEY2-q9dTsK
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:2

— Logical volume —
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID XE3qZL-Ke6Z-3zN7-z1aD-3eee-BY6E-qdVmLz
LV Write Access read/write
LV Status available
# open 1
LV Size 8.88 GB
Current LE 284
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:0

— Logical volume —
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID LT743f-Oy1u-Zq1Z-lKxM-czRy-hG9x-2H7RI3
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 32
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:1

yogesh-Linux#

yogesh-Linux#vgreduce gurkulgroup /dev/sdb1 ————> I tried to remove the disk having data, the LVM is so intelligent that it throw errors as
Physical volume “/dev/sdb1″ still in use

yogesh-Linux#vgreduce gurkulgroup /dev/sdc1 —————–> disk removed from VG Removed “/dev/sdc1″ from volume group “gurkulgroup”
yogesh-Linux#

yogesh-Linux#pvremove /dev/sdc1 ————————> disk removed from PV i.e complete LVM
/dev/cdrom: open failed: Read-only file system
Attempt to close device ‘/dev/cdrom’ which is not open.
Labels on physical volume “/dev/sdc1″ successfully wiped
yogesh-Linux#

yogesh-Linux#pvdisplay /dev/sdc1
No physical volume label read from /dev/sdc1
Failed to read physical volume “/dev/sdc1″
yogesh-Linux#

yogesh-Linux#vgdisplay
— Volume group —
VG Name gurkulgroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 2.00 GB
PE Size 4.00 MB
Total PE 511
Alloc PE / Size 256 / 1.00 GB
Free PE / Size 255 / 1020.00 MB
VG UUID OBnNzV-RWvO-Gvy0-L1rb-Brh1-IiIH-33Mpnc

— Volume group —
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 9.88 GB
PE Size 32.00 MB
Total PE 316
Alloc PE / Size 316 / 9.88 GB
Free PE / Size 0 / 0
VG UUID 53YyKs-D2uQ-0gVY-My3w-6QOi-KDQ8-9dFUjF

yogesh-Linux#pvdisplay
— Physical volume —
PV Name /dev/sdb1
VG Name gurkulgroup
PV Size 2.00 GB / not usable 3.32 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 511
Free PE 255
Allocated PE 256
PV UUID 90ikep-gxVd-oLkf-1YGO-s0dl-JkqQ-zTqY7a

— Physical volume —
PV Name /dev/sda2
VG Name VolGroup00
PV Size 9.90 GB / not usable 22.76 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 316
Free PE 0
Allocated PE 316
PV UUID md04K8-UyPp-X8G8-KZ7F-Vvm0-jbev-x0SClg

yogesh-Linux#lvdisplay
— Logical volume —
LV Name /dev/gurkulgroup/gurkulvolume
VG Name gurkulgroup
LV UUID BAS7wh-VZDt-l9rg-mdcf-srQr-yEY2-q9dTsK
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:2

— Logical volume —
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID XE3qZL-Ke6Z-3zN7-z1aD-3eee-BY6E-qdVmLz
LV Write Access read/write
LV Status available
# open 1
LV Size 8.88 GB
Current LE 284
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:0

— Logical volume —
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID LT743f-Oy1u-Zq1Z-lKxM-czRy-hG9x-2H7RI3
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 32
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:1

yogesh-Linux#

8.) Special Note:

a.) You can use -l with lvcreate if you wish to use extend instead of size.
b.) Extents size can be changed as per desire.
c.) The physical volumes are combined into logical volume groups, with the exception of the /boot/ partition. The /boot/ partition can not be on a logical volume group

because the boot loader can not read it. If the root / partition is on a logical volume, create a separate /boot/ partition which is not a part of a volume group.
d.) Untill here only LVM is covered so no data redundancy is there as any disk failure will case the dataloss if data is present in the failed disk. So better take backups.

We will come up with the Software RAID in Linux soon in our next post so that we can show you the data redundancy via mirroring in Linux.

Wednesday, 14 September 2011

AIX Links

Manufacturer Links

General Information
Home Page: IBM United States
Documentation/Information: IBM System p - UNIX servers: Support and services
pSeries and AIX Information Center
Developerworks AIX Wiki: AIX Wiki
In-depth information from IBM:
IBM Redbooks: IBM Redbooks
Updates, Release management
Efix download: http://www14.software.ibm.com/webapp...f/aix.efixmgmt
Inventory Scout: https://techsupport.services.ibm.com...invreadme.html
AIX Updates, Maintenance levels: Quick links for AIX fixes
How to build installp/bff packages: Chapter 20. Packaging Software for Installation
Hardware, Firmware
Firmware and Microcode download: IBM Support

FreeWare

Open Source Software for your AIX
IBM AIX Toolbox Download Page - Alphabetical Listing

Other Software

Java for AIX download
For those of you looking for the cmd mktemp found on other unix

Performance Tuning
Initial Tuning and Security Blog
Intorduction to topas (Metrics explained)

Virtualization
Quick Sheet for VIOS (Virtual I/O Server)

AIX Virtual User Group
AIX Movies
Webinars

Sites with more AIX info
ROOTVG - AIX and System p Portal
AIX Tip of the Week Index
The UNIX Rosetta Stone

Added VIOS link from User http://www.unix.com/members/302071531.html

topas link http://www.tablespace.net/papers/topas_intro.html

AIX Bits and Pieces

AIX Bits and Pieces
There are quite many nifty little tricks, which can make life easier for the AIX administrator carrying out typical tasks in his job. I'll start the collection, suggestions will be highly welcome and added here when they are messaged to me. No, i don't claim to have found out myself what stands here.

Please do not hesitate to share your knowledge.

==================================================
Restore single file from a mksysb tape:
put tape into tape drive rmtX and save original file first, it will be overwritten
# tctl -f /dev/rmtX rewind
# tctl -f /dev/rmtX.1 fsf3 ; tar -xvf /dev/rmtX.1 /path/to/file


Reset the time counter of the SSA-RAID-Adapters cache battery (i.e. after a battery change):
# ssa_format -b -l <device>


Access the hidden (IBM only) SBB panels on a POWER3 machine (6H1, H80, etc.):
In the main menu enter "14900"


See all OS maintenance levels the machine is aware of:
# instfix -i | grep AIX_ML


See all packages which are downlevel for a certain maintenance level:
At least the machine has to be aware of the maintenance level in question. List all the maintenance levels the machine is aware of (see there). Use the displayed keyword as argument for instfix and grep for ":-:' to get all packages downlevel for this ML.

# instfix -i | grep AIX_ML
# instfix -ick <ML_Keyword> | grep ':-:'

Example: Find all filesets downlevel relative to ML03
# instfix -i | grep AIX_ML
All filesets for 5.1.0.0_AIX_ML were found.
All filesets for 5100-01_AIX_ML were found.
All filesets for 5100-02_AIX_ML were found.
Not all filesets for 5100-03_AIX_ML were found.
Not all filesets for 5100-04_AIX_ML were found.
Not all filesets for 5100-05_AIX_ML were found.
Not all filesets for 5100-06_AIX_ML were found.

# instfix -ick 5100-03_AIX_ML | grep ':-:'
5100-03_AIX_ML:IMNSearch.rte.httpdlite:2.0.0.15:2.0.0.15:-:AIX 5100-03 Update
5100-03_AIX_ML:X11.adt.imake:5.1.0.15:5.1.0.15:-:AIX 5100-03 Update
5100-03_AIX_ML:X11.apps.xdm:5.1.0.25:5.1.0.25:-:AIX 5100-03 Update

Update IMNSearch.rte.httpdlite, X11.adt.imake and X11.apps.xdm to get to ML03.


Shorten the /var/adm/wtmp file
This file can grow quite big and possibly exhaust disk space in /var. It is essential, though, to preserve the files inode therefore simply deleting it and then "touch /var/adm/wtmp" is a dangerous method. Use the following command instead (as root):

# cat /dev/null > /var/adm/wtmp

You might copy the file before for archival purposes:

# cp /var/adm/wtmp /path/to/wtmp.archive ; cat /dev/null > /var/adm/wtmp
Twitter Bird Gadget