Linux: Difference between revisions

Jump to navigation Jump to search
4,940 bytes added ,  6 July 2020
→‎Volume group: adding a new disk to LVM
→‎Volume group: adding a new disk to LVM
Line 134: Line 134:
|}
|}


=== Adding a new disk to a LVM ===
<source lang="console">
[root@chara mhan]# lsblk
NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                    8:0    0 238.5G  0 disk
└─sda1                  8:1    0 238.5G  0 part
  ├─centos_chara-root 253:0    0    2T  0 lvm  /
  └─centos_chara-home 253:2    0  200G  0 lvm  /home
sdb                    8:16  0 119.2G  0 disk
├─sdb1                  8:17  0  200M  0 part /boot/efi
├─sdb2                  8:18  0    1G  0 part /boot
└─sdb3                  8:19  0  118G  0 part
  ├─centos_chara-root 253:0    0    2T  0 lvm  /
  └─centos_chara-swap 253:1    0  7.9G  0 lvm  [SWAP]
sdc                    8:32  0  1.8T  0 disk
└─sdc1                  8:33  0  1.8T  0 part
  └─centos_chara-root 253:0    0    2T  0 lvm  /
sdd                    8:48  0 931.5G  0 disk
└─sdd1                  8:49  0 931.5G  0 part
sr0                    11:0    1  1024M  0 rom
[root@chara mhan]# fdisk /dev/sdd
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x8d7dc33f.
Command (m for help): n
Partition type
  p  primary (0 primary, 0 extended, 4 free)
  e  extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-1953525167, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-1953525167, default 1953525167):
Created a new partition 1 of type 'Linux' and of size 931.5 GiB.
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
[root@chara mhan]# pvcreate /dev/sdd1
  Physical volume "/dev/sdd1" successfully created.
[root@chara mhan]# vgs
  VG          #PV #LV #SN Attr  VSize  VFree
  centos_chara  3  3  0 wz--n- <2.17t    0
[root@chara mhan]# vgextend centos_chara /dev/sdd1
  Volume group "centos_chara" successfully extended
[root@chara mhan]# lvdisplay | grep Path
  LV Path                /dev/centos_chara/swap
  LV Path                /dev/centos_chara/root
  LV Path                /dev/centos_chara/home
[root@chara mhan]# lvresize -l +100%free /dev/centos_chara/root
  Size of logical volume centos_chara/root changed from 1.96 TiB (514983 extents) to 2.87 TiB (753449 extents).
  Logical volume centos_chara/root successfully resized.
[root@chara mhan]# df -h | grep root
/dev/mapper/centos_chara-root  2.0T  1.9T  89G  96% /
[root@chara mhan]# grep root /etc/mtab
/dev/mapper/centos_chara-root / xfs rw,relatime,attr2,inode64,noquota 0 0
[root@chara mhan]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
devtmpfs                      7.8G    0  7.8G  0% /dev
tmpfs                          7.8G  176K  7.8G  1% /dev/shm
tmpfs                          7.8G  9.3M  7.8G  1% /run
tmpfs                          7.8G    0  7.8G  0% /sys/fs/cgroup
/dev/mapper/centos_chara-root  2.0T  1.9T  89G  96% /
/dev/sdb2                    1014M  293M  722M  29% /boot
/dev/mapper/centos_chara-home  200G  103G  98G  52% /home
/dev/sdb1                      200M  11M  190M  6% /boot/efi
tmpfs                          1.6G  4.0K  1.6G  1% /run/user/1000
[root@chara mhan]# xfs_growfs /
meta-data=/dev/mapper/centos_chara-root isize=512    agcount=161, agsize=3276800 blks
        =                      sectsz=512  attr=2, projid32bit=1
        =                      crc=1        finobt=0, sparse=0, rmapbt=0
        =                      reflink=0
data    =                      bsize=4096  blocks=527342592, imaxpct=25
        =                      sunit=0      swidth=0 blks
naming  =version 2              bsize=4096  ascii-ci=0, ftype=1
log      =internal log          bsize=4096  blocks=6400, version=2
        =                      sectsz=512  sunit=0 blks, lazy-count=1
realtime =none                  extsz=4096  blocks=0, rtextents=0
data blocks changed from 527342592 to 771531776
[root@chara mhan]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
devtmpfs                      7.8G    0  7.8G  0% /dev
tmpfs                          7.8G  176K  7.8G  1% /dev/shm
tmpfs                          7.8G  9.3M  7.8G  1% /run
tmpfs                          7.8G    0  7.8G  0% /sys/fs/cgroup
/dev/mapper/centos_chara-root  2.9T  1.9T 1020G  66% /
/dev/sdb2                    1014M  293M  722M  29% /boot
/dev/mapper/centos_chara-home  200G  103G  98G  52% /home
/dev/sdb1                      200M  11M  190M  6% /boot/efi
tmpfs                          1.6G  4.0K  1.6G  1% /run/user/1000
[root@chara mhan]#
</source>


=== Links ===
=== Links ===

Navigation menu