Debian扩容根目录(虚拟化扩盘)

由于使用虚拟化,磁盘不足后扩盘,但是Ubuntu和Debina等不会自动识别,因此要手工扩容大小。

查看磁盘信息

#fdisk -l
Disk /dev/sda: 160 GiB, 171798691840 bytes, 335544320 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 0E48C0D5-E124-4658-BEA7-2CAE5164B204

Device       Start       End   Sectors  Size Type
/dev/sda1     2048      4095      2048    1M BIOS boot
/dev/sda2     4096   4198399   4194304    2G Linux filesystem
/dev/sda3  4198400 251656191 247457792  118G Linux filesystem
mail# lsblk #查看lvm位置
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda                         8:0    0  160G  0 disk
├─sda1                      8:1    0    1M  0 part
├─sda2                      8:2    0    2G  0 part /boot
└─sda3                      8:3    0  158G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0   79G  0 lvm  /
sr0                        11:0    1 1024M  0 rom

mail# df -h # 查看lvm的存储位置
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              791M  1.3M  790M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   78G  6.4G   67G   9% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          2.0G  129M  1.7G   8% /boot
tmpfs                              791M  4.0K  791M   1% /run/user/1000

通过lsblk命令可以看到,/目录使用的空间并不是整个磁盘,因此需要将剩余的空间增加到/目录中
操作命令:

  • 扩展lvm大小
    # lvextend -L +1G /dev/mapper/pve-root  #扩大指定容量
    # lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv   #扩大剩余所有容量
    Size of logical volume ubuntu-vg/ubuntu-lv changed from <79.00 GiB (20223 extents) to <158.00 GiB (40447 extents).
    Logical volume ubuntu-vg/ubuntu-lv successfully resized.
  • 扩展文件系统大小
    
    # resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv   #扩充文件系统
    resize2fs 1.46.5 (30-Dec-2021)
    Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
    old_desc_blocks = 10, new_desc_blocks = 20
    The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 41417728 (4k) blocks long.

发表回复

登录... 后才能评论