Jumat, 30 Agustus 2019

How to extend disk Linux Redhat 7 nutanix

  Tidak ada komentar





Checking the disk size
[[email protected] ~]# df -h
Filesystem                          Size  Used Avail Use% Mounted on
/dev/mapper/rhel_devkapeldb01-root   50G   50G  9.5M 100% /
devtmpfs                            7.8G     0  7.8G   0% /dev
tmpfs                               7.8G     0  7.8G   0% /dev/shm
tmpfs                               7.8G  8.5M  7.8G   1% /run
tmpfs                               7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/sda1                          1014M  143M  872M  15% /boot
/dev/mapper/rhel_devkapeldb01-home   42G   33M   42G   1% /home
tmpfs                               1.6G     0  1.6G   0% /run/user/0
[[email protected] ~]#
Check the block size and disk block mapping
[[email protected] ~]# lsblk
NAME                       MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                          8:0    0  100G  0 disk
├─sda1                       8:1    0    1G  0 part /boot
└─sda2                       8:2    0   99G  0 part
  ├─rhel_devkapeldb01-root 253:0    0   50G  0 lvm  /
  ├─rhel_devkapeldb01-swap 253:1    0  7.9G  0 lvm  [SWAP]
  └─rhel_devkapeldb01-home 253:2    0 41.1G  0 lvm  /home
sr0                         11:0    1 1024M  0 rom
[[email protected] ~]#
Check the physical volume
[[email protected] ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               rhel_devkapeldb01
  PV Size               <99.00 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              25343
  Free PE               1
  Allocated PE          25342
  PV UUID               o1hXhV-0qQj-rB7n-UPnM-hwl0-KiTO-JWEuf1

[[email protected] ~]#
Check the scsi host and rescan
[[email protected] ~]# ls /sys/class/scsi_host/
host0  host1  host2
[[email protected] ~]#
[[email protected] ~]# sudo echo "- - -" > /sys/class/scsi_host/host0/scan
[[email protected] ~]# sudo echo "- - -" > /sys/class/scsi_host/host1/scan
[[email protected] ~]# sudo echo "- - -" > /sys/class/scsi_host/host2/scan
[[email protected] ~]#

Check the scsi device and rescan
[[email protected] ~]# ls /sys/class/scsi_device/
0:0:0:0  2:0:0:0
[[email protected] ~]# echo 1 > /sys/class/scsi_device/0\:0\:0\:0/device/rescan
[root[email protected] ~]# echo 1 > /sys/class/scsi_device/2\:0\:0\:0/device/rescan
[[email protected] ~]#
Perform running partition editor



[[email protected] ~]# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2
[[email protected] ~]#
Perform running partition editor





[[email protected] ~]# fdisk /dev/sda

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


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
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   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): p

Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: dos
Disk identifier: 0x000c401d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   209715199   103808000   8e  Linux LVM

Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 is deleted

Command (m for help): p

Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: dos
Disk identifier: 0x000c401d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2099200-419430399, default 2099200):
Using default value 2099200
Last sector, +sectors or +size{K,M,G} (2099200-419430399, default 419430399):
Using default value 419430399
Partition 2 of type Linux and of size 199 GiB is set

Command (m for help): p

Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: dos
Disk identifier: 0x000c401d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   419430399   208665600   83  Linux

Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT
1e  Hidden W95 FAT1 80  Old Minix
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk label type: dos
Disk identifier: 0x000c401d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   419430399   208665600   8e  Linux LVM

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

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[[email protected] ~]#
Running partprobe command
Reboot the machine

[r[email protected] ~]# reboot now
login as: root
[email protected]'s password:
Last login: Fri Aug 30 14:46:42 2019 from 192.168.10.10
[[email protected] ~]#
Check the physical volume after running partition 
[[email protected] ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               rhel_devkapeldb01
  PV Size               <99.00 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              25343
  Free PE               1
  Allocated PE          25342
  PV UUID               o1hXhV-0qQj-rB7n-UPnM-hwl0-KiTO-JWEuf1

[[email protected] ~]#
[[email protected] ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/rhel_devkapeldb01/swap
  LV Name                swap
  VG Name                rhel_devkapeldb01
  LV UUID                xATCaa-rRJl-vDHT-zvcE-RPxW-dNLB-eV7RGF
  LV Write Access        read/write
  LV Creation host, time devkapeldb01.debhub.go.id, 2018-11-24 02:54:52 +0700
  LV Status              available
  # open                 2
  LV Size                <7.88 GiB
  Current LE             2016
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/rhel_devkapeldb01/home
  LV Name                home
  VG Name                rhel_devkapeldb01
  LV UUID                lIHRYR-VP7y-TbV6-7Nnb-02LA-7muA-UoYa8r
  LV Write Access        read/write
  LV Creation host, time devkapeldb01.debhub.go.id, 2018-11-24 02:54:52 +0700
  LV Status              available
  # open                 1
  LV Size                <41.12 GiB
  Current LE             10526
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2

  --- Logical volume ---
  LV Path                /dev/rhel_devkapeldb01/root
  LV Name                root
  VG Name                rhel_devkapeldb01
  LV UUID                8pH6bw-cP92-d775-kS7h-tQYr-iflF-oauCiA
  LV Write Access        read/write
  LV Creation host, time devkapeldb01.debhub.go.id, 2018-11-24 02:54:53 +0700
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

[[email protected] ~]#
[[email protected] ~]# vgdisplay
  --- Volume group ---
  VG Name               rhel_devkapeldb01
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <99.00 GiB
  PE Size               4.00 MiB
  Total PE              25343
  Alloc PE / Size       25342 / 98.99 GiB
  Free  PE / Size       1 / 4.00 MiB
  VG UUID               h2DHAh-nLJX-2kXY-18bR-9Yc6-Vzck-ja7WVU

[[email protected] ~]#
Show the disk size
[[email protected] ~]# df -h
Filesystem                          Size  Used Avail Use% Mounted on
/dev/mapper/rhel_devkapeldb01-root   50G   50G  9.4M 100% /
devtmpfs                            7.8G     0  7.8G   0% /dev
tmpfs                               7.8G     0  7.8G   0% /dev/shm
tmpfs                               7.8G  8.5M  7.8G   1% /run
tmpfs                               7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/sda1                          1014M  143M  872M  15% /boot
/dev/mapper/rhel_devkapeldb01-home   42G   33M   42G   1% /home
tmpfs                               1.6G     0  1.6G   0% /run/user/0
[[email protected] ~]#







Extend the physical volume
[[email protected] ~]# pvresize /dev/sda2
  Physical volume "/dev/sda2" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
[[email protected] ~]#
[[email protected] ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               rhel_devkapeldb01
  PV Size               <199.00 GiB / not usable 2.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              50943
  Free PE               25601
  Allocated PE          25342
  PV UUID               o1hXhV-0qQj-rB7n-UPnM-hwl0-KiTO-JWEuf1

[[email protected] ~]#
Extend logical volume home
[[email protected] ~]# lvextend -L +100G /dev/rhel_devkapeldb01/root
  Size of logical volume rhel_devkapeldb01/root changed from 50.00 GiB (12800 extents) to 150.00 GiB (38400 extents).
  Logical volume rhel_devkapeldb01/root successfully resized.
[[email protected] ~]#
[[email protected] ~]# xfs_growfs /dev/mapper/rhel_devkapeldb01-root
meta-data=/dev/mapper/rhel_devkapeldb01-root isize=512    agcount=4, agsize=3276800 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=13107200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=6400, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 13107200 to 39321600
[[email protected] ~]#
Check the disk size after extending

[[email protected] ~]# df -h
Filesystem                          Size  Used Avail Use% Mounted on
/dev/mapper/rhel_devkapeldb01-root  150G   50G  101G  34% /
devtmpfs                            7.8G     0  7.8G   0% /dev
tmpfs                               7.8G     0  7.8G   0% /dev/shm
tmpfs                               7.8G  8.4M  7.8G   1% /run
tmpfs                               7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/sda1                          1014M  143M  872M  15% /boot
/dev/mapper/rhel_devkapeldb01-home   42G   33M   42G   1% /home
tmpfs                               1.6G     0  1.6G   0% /run/user/0
[[email protected] ~]#
Check the disk block mapping

[[email protected] ~]# lsblk
NAME                       MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                          8:0    0  200G  0 disk
├─sda1                       8:1    0    1G  0 part /boot
└─sda2                       8:2    0  199G  0 part
  ├─rhel_devkapeldb01-root 253:0    0  150G  0 lvm  /
  ├─rhel_devkapeldb01-swap 253:1    0  7.9G  0 lvm  [SWAP]
  └─rhel_devkapeldb01-home 253:2    0 41.1G  0 lvm  /home
sr0                         11:0    1 1024M  0 rom
[[email protected] ~]#
Check The PV, VG and LV

[[email protected] ~]# pvs
  PV         VG                Fmt  Attr PSize    PFree
  /dev/sda2  rhel_devkapeldb01 lvm2 a--  <199.00g 4.00m
[[email protected] ~]#
[[email protected] ~]# vgs
  VG                #PV #LV #SN Attr   VSize    VFree
  rhel_devkapeldb01   1   3   0 wz--n- <199.00g 4.00m
[[email protected] ~]#
[[email protected] ~]# lvs
  LV   VG                Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home rhel_devkapeldb01 -wi-ao---- <41.12g                                     
  root rhel_devkapeldb01 -wi-ao---- 150.00g                                     
  swap rhel_devkapeldb01 -wi-ao----  <7.88g                                     
[[email protected] ~]#
[[email protected] ~]#



Tidak ada komentar :

Posting Komentar