Làm thế nào để mở rộng dung lượng lưu trữ gốc của máy chủ Ubuntu?
- Resize the Partition: Khi đĩa ảo lớn hơn, bạn cần thay đổi kích thước phân vùng (sda3) để chiếm thêm không gian. Bạn có thể sử dụng tiện ích fdisk hoặc parted để thực hiện việc này:
- If you’re using
fdisk
, run:sudo fdisk /dev/sda
Then, delete and recreate partition 3 (
sda3
) with the new size, making sure it covers the entire available space. After making the changes, save and exit. - If you’re using
parted
, run:sudo parted /dev/sda (parted) resizepart 3
Follow the prompts to resize the partition to occupy the entire available space.
- If you’re using
- Resize the LVM Physical Volume: Now that the partition is resized, you need to resize the LVM Physical Volume (PV) to recognize the increased space. Run the following command:
sudo pvresize /dev/sda3
- Extend the Logical Volume (LV): After resizing the PV, you can extend the LV (
/dev/ubuntu-vg/ubuntu-lv
) to use the newly available space. Use thelvextend
command:sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
This command extends the LV to use 100% of the available free space in the VG.
- Resize the Filesystem: Finally, you should resize the filesystem to utilize the newly allocated space:
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
This command resizes the filesystem to match the size of the LV.
After completing these steps, your Ubuntu partition should have been successfully resized to utilize the additional space.