Expanding the Root Volume in Linux Using LVM

When managing storage on Linux, it’s often necessary to expand the root volume to accommodate increasing data requirements. If your disk – for example, /dev/sda – has unallocated space, you can utilize Logical Volume Management (LVM) to extend the root volume. Below are the detailed steps to achieve this.

Prerequisites

  • Ensure your disk has sufficient unallocated space.
  • Confirm that LVM is being used to manage the root volume.
  • Backup any important data to avoid potential data loss.

Step 1: Check Available Space in the Volume Group

First, inspect the available space in your volume group (VG). Run the following command:

vgdisplay ubuntu-vg

Look for the Free PE / Size field, which indicates how much unallocated space is available in the volume group. If sufficient space is available, you can proceed with the expansion.


Step 2: Extend the Logical Volume

You can now extend the logical volume (LV) managing your root directory. Depending on your requirements, choose one of the following options:

Option 1: Extend to a Specific Size

If you want to extend the root volume to a specific size, such as 50GB, use this command:

lvextend -L 50G /dev/ubuntu-vg/ubuntu-lv

Option 2: Use All Available Free Space

To allocate all the unallocated space in the volume group to the root volume, use:

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

This ensures that the entire free space in the volume group is assigned to the root volume.


Step 3: Resize the Filesystem

After extending the logical volume, the filesystem must be resized to utilize the newly added space. Execute the following command:

resize2fs /dev/ubuntu-vg/ubuntu-lv

This automatically adjusts the filesystem size to match the extended logical volume.


Step 4: Verify the Expansion

To confirm the root volume’s new size, run:

df -h /

This will display the updated size of the root filesystem.


Key Considerations

  • Backup Your Data: Always ensure critical data is backed up before modifying disk partitions or resizing filesystems.
  • Ensure Sufficient Space: Confirm there is enough free space in the volume group before attempting an expansion.
  • Avoid Disruption: Perform these steps during a maintenance window to minimize the risk of service interruptions.

By following these steps, you can effectively extend the root volume and optimize your system’s storage capacity. If you encounter any issues or errors, review the output of each command for debugging or consult relevant documentation for further assistance.

以上資訊整理來自於 ChatGPT

Read more

如何安裝 KubeSphere 以及管理 Workspace 和新增 Label

前言 在 Kubernetes 的世界中,KubeSphere 是一個功能強大的開源容器平台,它不僅讓 Kubernetes 的管理更簡單,還集成了多集群管理、DevOps、微服務治理等功能。本篇文章將教您如何使用 Helm 快速安裝 KubeSphere,並如何通過管理 Workspace 和新增 Label 來實現資源的高效管理。 一、使用 Helm 安裝 KubeSphere 1. 為什麼選擇 Helm 安裝? Helm 是 Kubernetes 中廣泛使用的包管理工具,使用 Helm 安裝 KubeSphere 有以下優點: * 自動化:簡化安裝過程,減少手動配置。 * 靈活性:可以根據需求自定義安裝的模組。 * 版本控制:支持管理和回滾安裝的不同版本。 2. 安裝前準備 在開始安裝之前,請確保以下條件:

By Tim Chiagn

我的經驗

1. 網絡與安全 (Networking & Security) * Fortigate: 防火牆來管理網路環境 * Traefik: 用於 K8s 的 2. 虛擬化與存儲 (Virtualization & Storage) * Esxi: 買了一台server 使用 Esxi 管理 vm * TrueNAS: 還沒有買 NAS 使用這個加減用一下 3. DevOps 與持續交付 (DevOps & CI/CD) * ArgoCD: GitOps 工具,用於 Kubernetes 的應用交付和管理,支持自動化部署和同步。 * KubeSphere:提供完整的 CI/CD 工作流管理、應用部署和 DevOps 整合功能,是 Kubernetes

By Tim Chiagn