Linux sunucularda LVM disk genişletme

Linux sunucularda LVM disk genişletme

Genellikle LVM diskleri genişletirken sorun yaşadığınızı biliyoruz, en çok aldığımız destek talepleri arasındadır. Bu yazımızda işinizi kolaylaştırmak için örnek bir genişletme işlemini sizinle paylaşıyoruz.

Sunucumuzun diski 500GB ve bunu 2TB olarak güncelleyeceğiz. Örnek çıktı aşağıdaki gibi, kontrolde 500 GB olduğu gözüküyor ve sanal sunucumuzun diskini, vmware üzerinden 2TB olarak ayarladıktan sonra sunucuyu yeniden başlatıyoruz.

[root@sunucu.com.tr veeam]# fdisk -l Disk /dev/sda: 515.4 GB, 515396075520 bytes, 1006632960 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000a7393 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 39845887 18873344 8e Linux LVM /dev/sda3 39845888 1006632959 483393536 83 Linux Disk /dev/mapper/cl-root: 512.3 GB, 512271319040 bytes, 1000529920 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/cl-swap: 2042 MB, 2042626048 bytes, 3989504 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes [root@sunucu.com.tr veeam]# reboot

Sunucumuz yeniden başladı ve diski kontrol ettiğimizde aşağıdaki gibi bir çıktı alıyoruz.

[root@sunucu.com.tr ~]# fdisk -l Disk /dev/sda: 2147.5 GB, 2147483648000 bytes, 4194304000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000a7393 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 39845887 18873344 8e Linux LVM /dev/sda3 39845888 1006632959 483393536 83 Linux Disk /dev/mapper/cl-root: 512.3 GB, 512271319040 bytes, 1000529920 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/cl-swap: 2042 MB, 2042626048 bytes, 3989504 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes [root@sunucu.com.tr ~]#

Eklediğimiz ve boşta olan alan için aşağıdaki şekilde yeni bir partition ekleyelim.

[root@sunucu.com.tr ~]# fdisk /dev/sda 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): p Disk /dev/sda: 2147.5 GB, 2147483648000 bytes, 4194304000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000a7393 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 39845887 18873344 8e Linux LVM /dev/sda3 39845888 1006632959 483393536 83 Linux Command (m for help): n Partition type: p primary (3 primary, 0 extended, 1 free) e extended Select (default e): p Selected partition 4 First sector (1006632960-4194303999, default 1006632960): Using default value 1006632960 Last sector, +sectors or +size{K,M,G} (1006632960-4194303999, default 4194303999):
Using default value 4194303999
Partition 4 of type Linux and of size 1.5 TiB is set

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.
[root@sunucu.com.tr ~]#

Kontrol ettiğimizde sda4’ün eklendiğini görüyoruz.

[root@sunucu.com.tr ~]# fdisk /dev/sda 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): p Disk /dev/sda: 2147.5 GB, 2147483648000 bytes, 4194304000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000a7393 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 39845887 18873344 8e Linux LVM /dev/sda3 39845888 1006632959 483393536 83 Linux /dev/sda4 1006632960 4194303999 1593835520 83 Linux

Aşağıdaki şekilde sistemin partitionı tanımasını sağlıyoruz.

[root@sunucu.com.tr ~]# partx -v -a /dev/sda partition: none, disk: /dev/sda, lower: 0, upper: 0 /dev/sda: partition table type ‘dos’ detected partx: /dev/sda: adding partition #1 failed: Device or resource busy partx: /dev/sda: adding partition #2 failed: Device or resource busy partx: /dev/sda: adding partition #3 failed: Device or resource busy /dev/sda: partition #4 added partx: /dev/sda: error adding partitions 1-3 [root@sunucu.com.tr ~]# [root@sunucu.com.tr ~]# pvcreate /dev/sda4 Physical volume “/dev/sda4” successfully created. [root@sunucu.com.tr ~]#

Diskimizin adını öğrenelim. Biz kurulumda adını cl olarak belirlemişiz. Siz uygularken diskin adını ve yolunu buna göre belirlemelisiniz.

[root@sunucu.com.tr ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 478G 22G 456G 5% / devtmpfs 16G 0 16G 0% /dev tmpfs 16G 0 16G 0% /dev/shm tmpfs 16G 8.5M 16G 1% /run tmpfs 16G 0 16G 0% /sys/fs/cgroup /dev/sda1 1014M 141M 874M 14% /boot tmpfs 3.2G 0 3.2G 0% /run/user/0 [root@sunucu.com.tr ~]#

sda4’ü genişletiyor ve kontrol ediyoruz.

[root@sunucu.com.tr ~]# vgextend cl /dev/sda4 Volume group “cl” successfully extended [root@sunucu.com.tr ~]# vgdisplay — Volume group — VG Name cl System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 6 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 3 Act PV 3 VG Size 1.95 TiB PE Size 4.00 MiB Total PE 511741 Alloc PE / Size 122622 / 478.99 GiB Free PE / Size 389119 / 1.48 TiB VG UUID zDTXPv-o9MO-qRIT-AtOy-OkO4-ejFX-jli3sH [root@sunucu.com.tr ~]#

Ve sıra geldi oluşturduğumuz bu diski, sistem diskimiz üzerinde kullanmaya ve diski genişletmeye.

[root@sunucu.com.tr cl]# lvextend /dev/cl/root /dev/sda4 Size of logical volume cl/root changed from 477.09 GiB (122135 extents) to 1.95 TiB (511254 extents). Logical volume cl/root successfully resized. [root@sunucu.com.tr cl]#

resize2fs komutu ile diski genişletmeyi başaramazsanız, muhtemelen disk yapınız xfs olarak ayarlanmıştır, o durumda xfs_growfs komutu ile genişletmeyi tamamlayabilirsiniz.

[root@sunucu.com.tr cl]# resize2fs /dev/mapper/cl-root resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open /dev/mapper/cl-root Couldn’t find valid filesystem superblock. [root@sunucu.com.tr cl]# xfs_growfs /dev/mapper/cl-root meta-data=/dev/mapper/cl-root isize=512 agcount=119,agsize=1054720 = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=125066240, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 125066240 to 523524096 [root@sunucu.com.tr cl]#

Kontrol edelim 😉

[root@sunucu.com.tr cl]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 2.0T 22G 2.0T 2% / devtmpfs 16G 0 16G 0% /dev tmpfs 16G 0 16G 0% /dev/shm tmpfs 16G 8.5M 16G 1% /run tmpfs 16G 0 16G 0% /sys/fs/cgroup /dev/sda1 1014M 141M 874M 14% /boot tmpfs 3.2G 0 3.2G 0% /run/user/0 [root@sunucu.com.tr cl]#

Disk yapısını kontrol etmeden resize2fs komutunu çalıştırmayı denedik, dosya sistemi xfs olduğu için çalışmadı, bu nedenle xfs_growfs ile genişletmeyi tamamladık.

Kullanacağınız komutlar çıktıların içindedir, bu işlemi yapmaya niyetliyseniz yukarıdaki şablonları anladığınızı varsayıyoruz. Eğer bilginiz yoksa işlem yapmanızı önermeyiz, yanlış bir durumda diski geri döndürülemeyecek şekilde bozabilirsiniz, bu nedenle destek almanızda fayda vardır.

Benzer Yazılar
Yorum Yazın

E-posta hesabınız yayımlanmayacak.Gerekli alanlar * ile işaretlenmiştir.