May 26, 2016

Managing disk/ storage in Linux

1) df - disk space of file systems
Reports various partitions, their mount points and the used and available space on each.

# df -H
Filesystem             Size   Used  Avail Use% Mounted on
/dev/mapper/ROOTVG-rootfs
                        21G    14G   6.1G  70% /
tmpfs                   11G   7.7G   2.9G  73% /dev/shm
/dev/sda1              508M    40M   442M   9% /boot
/dev/mapper/ROOTVG-tmpfs
                       5.2G   145M   4.8G   3% /tmp
/dev/mapper/DATAVG-datalv01
                       529G   409G    94G  82% /u01
/dev/mapper/TEMPVG-templv01
                       269G   193G    63G  76% /u10
#

2) fdisk -l
Use fdisk -l to list all disk / storage attached to system. But if system is a vm and multipather is enabled, then message/ output will be more.
you can use below filterations and other commands to view details about disk / storage

a) Using lsblk:

# lsblk -o KNAME,TYPE,SIZE,MODEL
KNAME TYPE   SIZE MODEL
sda   disk   150G Virtual Disk  
sda1  part   500M
sda2  part   127G
dm-0  lvm   19.5G
dm-1  lvm     16G
dm-4  lvm    4.9G
sdb   disk   127G Virtual Disk  
sdb1  part   127G
dm-3  lvm    254G
sdd   disk   127G Virtual Disk  
dm-3  lvm    254G
sdc   disk   500G 1814      FAStT
dm-2  lvm    500G
[root@eh-uatdb1 ~]#


b) Using filters in lsblk


# lsblk -d -n -oNAME,RO | grep '0$' | awk {'print $1'}
sda
sdb
sdd
sdc
#

c) lsblk command is graphical window:


















d) view disks

# file /dev/disk/by-id/* | awk -F'/' 'NR>1{print "\047/dev/"$NF}' | sort | uniq
'/dev/dm-0'
'/dev/dm-1'
'/dev/dm-2'
'/dev/dm-3'
'/dev/dm-4'
'/dev/sda'
'/dev/sda1'
'/dev/sda2'
'/dev/sdb'
'/dev/sdb1'
'/dev/sdc'
'/dev/sdd'
#

e) sfsik

Sfdisk is another utility with a purpose similar to fdisk, but with more features. It can display the size of each partition in MB.

f) more filteration on sfdisk
# sfdisk -l -uM

Disk /dev/sda: 19581 cylinders, 255 heads, 63 sectors/track
Units = mebibytes of 1048576 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start   End    MiB    #blocks   Id  System
/dev/sda1   *     1    500    500     512000   83  Linux
/dev/sda2       501  130557  130057  133178368   8e  Linux LVM
/dev/sda3         0      -      0          0    0  Empty
/dev/sda4         0      -      0          0    0  Empty

Disk /dev/sdb: 16578 cylinders, 255 heads, 63 sectors/track
Units = mebibytes of 1048576 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start   End    MiB    #blocks   Id  System
/dev/sdb1         0+ 130047  130048- 133169151+  8e  Linux LVM
/dev/sdb2         0      -      0          0    0  Empty
/dev/sdb3         0      -      0          0    0  Empty
/dev/sdb4         0      -      0          0    0  Empty

Disk /dev/sdd: 16578 cylinders, 255 heads, 63 sectors/track

Disk /dev/sdc: 65270 cylinders, 255 heads, 63 sectors/track
Units = mebibytes of 1048576 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start   End    MiB    #blocks   Id  System
/dev/sdc1         0      -      0          0    0  Empty
/dev/sdc2         0      -      0          0    0  Empty
/dev/sdc3         0      -      0          0    0  Empty
/dev/sdc4         0      -      0          0    0  Empty

Disk /dev/mapper/ROOTVG-rootfs: 2549 cylinders, 255 heads, 63 sectors/track

Disk /dev/mapper/ROOTVG-swapfs: 2088 cylinders, 255 heads, 63 sectors/track

Disk /dev/mapper/DATAVG-datalv01: 65270 cylinders, 255 heads, 63 sectors/track

Disk /dev/mapper/TEMPVG-templv01: 33156 cylinders, 255 heads, 63 sectors/track

Disk /dev/mapper/ROOTVG-tmpfs: 637 cylinders, 255 heads, 63 sectors/track
#

f) lsscsi - List scsi devices

Lists out the scsi/sata devices like hard drives and optical drives.

[root@eh-uatdb1 ~]# lsscsi
[0:0:0:0]    disk    Msft     Virtual Disk     1.0   /dev/sda
[1:0:0:0]    disk    Msft     Virtual Disk     1.0   /dev/sdb
[1:0:0:1]    disk    IBM      1814      FAStT  1060  /dev/sdc
[1:0:0:2]    disk    Msft     Virtual Disk     1.0   /dev/sdd
[root@eh-uatdb1 ~]#



3) Find CPU details using "lscpu" command:

# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    1
Core(s) per socket:    4
CPU socket(s):         1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 44
Stepping:              2
CPU MHz:               2399.493
BogoMIPS:              4798.98
Hypervisor vendor:     Microsoft
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              12288K
NUMA node0 CPU(s):     0-3
#



4) mount
The mount is used to mount/unmount and view mounted file systems.

[root@eh-uatdb1 ~]# mount | column -t
/dev/mapper/ROOTVG-rootfs    on  /                         type  ext4                   (rw)
proc                         on  /proc                     type  proc                   (rw)
sysfs                        on  /sys                      type  sysfs                  (rw)
devpts                       on  /dev/pts                  type  devpts                 (rw,gid=5,mode=620)
tmpfs                        on  /dev/shm                  type  tmpfs                  (rw)
/dev/sda1                    on  /boot                     type  ext4                   (rw)
/dev/mapper/ROOTVG-tmpfs     on  /tmp                      type  ext4                   (rw)
/dev/mapper/DATAVG-datalv01  on  /u01                      type  ext4                   (rw)
/dev/mapper/TEMPVG-templv01  on  /u10                      type  ext4                   (rw)
none                         on  /proc/sys/fs/binfmt_misc  type  binfmt_misc            (rw)
/tmp                         on  /tmp                      type  none                   (rw,bind)
/var/tmp                     on  /var/tmp                  type  none                   (rw,bind)
/home                        on  /home                     type  none                   (rw,bind)
none                         on  /sys/kernel/config        type  configfs               (rw)
sunrpc                       on  /var/lib/nfs/rpc_pipefs   type  rpc_pipefs             (rw)
gvfs-fuse-daemon             on  /root/.gvfs               type  fuse.gvfs-fuse-daemon  (rw,nosuid,nodev)
[root@eh-uatdb1 ~]#

5) View details from attached volume groups:

( must be in graphical view)

system --> administration --> Logical volume management -->

It will show below window. Here you can manage your volume groups. You can create lvs also.


6) Creating VG and LV on Linux :

To view Un-allocated volume and Create volume group (VG):

system --> administration --> Logical volume management --> Unallocated Volumes --> Partition
( see below image to follow)





























To create Logical Volume(LV)  on VG:

system --> administration --> Logical volume management --> select VG name --> Create :Logical Volume --> Enter Logival Volume Name --> Give LV size --> Give proposed mount point Name ( go with default file system)
( see below image to follow)






























To View the LV name:
system --> administration --> Logical volume management --> select VG name -->select Logical View ( here you can view any space available to create more lv or not)





























Related Link:

creating volume groups and mount storage in IBM-AIX



No comments:

Post a Comment

Translate >>