How to Increase VMware Virtual Disk Size LVM

 

Introduction:

In this post, I will explain how to expand disk space on a Linux system using Logical Volume Manager (LVM). Whether you’re dealing with a physical or virtual disk, this step-by-step tutorial will help you make the most of your storage without the need for a system reboot.

Step 1: Increase Disk Size

The first step is to increase the size of the disk that your Linux OS uses. This can be done by expanding the virtual disk in virtualization platforms like VMWare, KVM or Hyper-V. For this post, we’ll extend a 16 GB disk to 30 GB.

My Lab Details:

Hypervisor: VMware ESXi
VM: Ubuntu 22.04.1 LTS
expand-disk

root@ubuntu-test:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                               98M  1.3M   96M   2% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  9.8G  6.7G  2.6G  73% /
tmpfs                              486M     0  486M   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          1.7G  247M  1.4G  16% /boot
tmpfs                               98M  4.0K   98M   1% /run/user/1000

Disk is still not visible/listed

Step 2: Rescan the Disk

After resizing the disk, you may need to prompt Linux to recognize the additional free space. To check for free space, run the cfdisk command and see if it lists free space. Use “q” to exit when done. If there’s no free space listed, initiate a rescan for /dev/sda with the command:

echo 1 > /sys/class/block/sda/device/rescan

Stage 2: Modify the partition within the VM

(Note: It is time to stop, if you have not backup all your data, or if you are not sure about what you are doing.)

Step 6: type the following command, find Disk /dev/sda, and confirm the size (of step 3).

$ sudo fdisk -l

Step 7: Run the command

$ sudo fdisk /dev/sda

Step 8: Type 'p' to check the partition info.

(Warning: if you have more than one partitions, STOP using this guide.)

Step 9: Type 'd' to delete Partition 1.

Step 10: Type 'p', and confirm the changes

Step 11: Type 'n', hit 'Enter' 4 times to use defaults ([Partition type], [Partition number], [first sector], and [last sector]), and type 'n'. (You might not need the last 'n'.)

Note: Chose [N]

Partition #3 contains a LVM2_member signature.

Do you want to remove the signature? [Y]es/[N]o: n


 

Step 12: Type 'p', confirm the changes, and then type 'w'

Step 13: Restart the virtual machine.

Stage 3: Resize the disk space within the VM

Step 14: Run following command

$ sudo resize2fs /dev/sda1


Step 4: Extend the Physical Volume (PV)

With the LVM partition backing up the /dev/sda3 PV extended, it’s time to extend the PV itself.

Run

pvresize /dev/sda3

to accomplish this, and then use pvdisplay to verify the new size. In our example, the PV has increased from 14.2GB to 28.2G.

Step 5: Check Volume Group (VG) Free Space

Now, check the VG’s free space using vgdisplay. In our case, there’s 18.25 GiB of free space available within the VG.

Step 6: Extend Logical Volume (LV)

Use lvdisplay to verify the size of your upstream Logical Volume (LV). Extend the LV to use all available VG free space with the below command

lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

Check the LV one more time with lvdisplay to ensure it’s been extended.

root@ubuntu-test:~# lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from 10.00 GiB (2560 extents) to <28.25 GiB (7231 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.
root@ubuntu-test:~# lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                xL1oCY-qBRL-cT86-jRRr-0cWK-0P4W-U0Y1Dp
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2023-04-12 11:44:17 +0000
  LV Status              available
  # open                 1
  LV Size                <28.25 GiB
  Current LE             7231
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

Step 7: Resize the File System

At this point, the block volume supporting your root filesystem has been expanded, but the filesystem itself needs resizing. Run df -h to check the current filesystem size. Use the below command to resize it, and run df -h once more to confirm the new available space.

resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv 

Following the above steps, you can successfully expand your Linux Machine/VM physical or virtual disk space using LVM. This allows you to efficiently manage your storage resources and accommodate growing storage needs without disrupting your system. Hope this helps.

Đọc thêm..

ibus-bamboo

- Install ibus-bamboo

echo 'deb http://download.opensuse.org/repositories/home:/lamlng/Debian_11/ /' | sudo tee /etc/apt/sources.list.d/home:lamlng.list curl -fsSL

 https://download.opensuse.org/repositories/home:lamlng/Debian_11/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_lamlng.gpg > /dev/null sudo 

apt update

sudo apt install ibus-bamboo

 

vi /etc/environment
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus

Đọc thêm..

Install XRDP on Linux

 - Install XRDP on Linux:

sudo apt install xrdp 

sudo systemctl status xrdp

sudo adduser xrdp ssl-cert 

sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils

- Config file:

/etc/xrdp/sesman.ini 

/etc/xrdp/startwm.sh

/etc/X11/Xsession

Đọc thêm..

Resizing the disk space on Ubuntu Server VMs running on VMware ESXi 5

Resizing the disk space on Ubuntu Server VMs running on VMware ESXi 5 

- fdisk /dev/sda
- p
Device     Boot   Start      End  Sectors  Size Id Type
/dev/sda1  *       2048   999423   997376  487M 83 Linux
/dev/sda2       1001470 33552383 32550914 15.5G  5 Extended
/dev/sda5       1001472 33552383 32550912 15.5G 8e Linux LVM
- d

- 2
- n 
- e
- enter
- n 
- enter
- t 8e
 
I ran this command to resize the physical volume.
ubuntu@brick:~$ sudo pvresize /dev/sda5
Physical volume "/dev/sda5" changed
1 physical volume(s) resized / 0 physical volume(s) not resized

Then I ran this command to resize the logical root volume
ubuntu@brick:~$ sudo lvresize -l +100%FREE /dev/mapper/brick-root
Extending logical volume root to 118.76 GiB
Logical volume root successfully resized

Then I ran this command to resize the file system on the root partition. This took about 6 seconds.
ubuntu@brick:~$ sudo resize2fs /dev/mapper/brick-root
resize2fs 1.42.5 (29-Jul-2012)
Filesystem at /dev/mapper/brick-root is mounted on /; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 8
The filesystem on /dev/mapper/brick-root is now 31132672 blocks long.
Đọc thêm..

Chmod file, directory in linux

For directories only do this.

Code:
find . -type d -exec chmod 775 {} \;
For files only do this.
Code:
find . -type f -exec chmod 664 {} \;
Đọc thêm..

Hướng dẫn gõ tiếng việt bằng Ibus trên Skype

Vấn đề gõ tiếng việt bằng ibus trên ứng dụng Skype có lẽ cũng rất nhiều người gặp(kể cả mình). Vì yêu cầu công việc nên mình phải dùng linux và liên lạc với đồng nghiệp qua skype. Sau một hồi tìm kiếm thì cũng đã gõ được tiếng việt trên skype, mình post lên để những ai chưa biết có thể tham khảo.

Bước 1: cài package ibus-qt4

Mã:
sudo apt-get install ibus-qt4


Bước 2: Thêm những dòng dưới đây vào cuối file /home/[tên người dùng]/.bashsrc

Mã:
export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
export XIM_PROGRAM=/usr/bin/ibus-daemon


Bước 3: Chạy ibus bằng lệnh ibus-daemon -drx thay vì lệnh ibus-daemon như bình thường.
Đọc thêm..