如何调整损坏的分区的大小?

如何调整损坏的分区的大小?

有一个专用服务器,其具有一些奇怪的默认分区设置,但我似乎无法使用可用的磁盘。

尝试将 200GB 分区设为其上的 960GB 磁盘的大小。

root@jdcuser:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
udev                                16G     0   16G   0% /dev
tmpfs                              3.2G  251M  2.9G   8% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  196G  196G     0 100% /
tmpfs                               16G     0   16G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                               16G     0   16G   0% /sys/fs/cgroup
/dev/sda2                          976M  104M  806M  12% /boot
/dev/loop0                          30M   30M     0 100% /snap/snapd/8542
/dev/loop1                          55M   55M     0 100% /snap/core18/1880
/dev/loop2                          72M   72M     0 100% /snap/lxd/16099
tmpfs                              3.2G     0  3.2G   0% /run/user/0
/dev/loop3                          56M   56M     0 100% /snap/core18/1885
/dev/loop4                          31M   31M     0 100% /snap/snapd/9607
/dev/loop5                          71M   71M     0 100% /snap/lxd/16922
root@jdcuser:~# fdisk -l
Disk /dev/loop0: 29.9 MiB, 31334400 bytes, 61200 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/loop1: 54.98 MiB, 57626624 bytes, 112552 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/loop2: 71.28 MiB, 74735616 bytes, 145968 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/loop3: 55.33 MiB, 58007552 bytes, 113296 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/loop4: 30.95 MiB, 32432128 bytes, 63344 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/loop5: 70.58 MiB, 73990144 bytes, 144512 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/sda: 953.89 GiB, 1024209543168 bytes, 2000409264 sectors
Disk model: TEAM T253X2001T 
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: 4338853D-6405-4F81-ADFD-EE57B6DA7C74

Device       Start        End    Sectors   Size Type
/dev/sda1     2048       4095       2048     1M BIOS boot
/dev/sda2     4096    2101247    2097152     1G Linux filesystem
/dev/sda3  2101248 2000409230 1998307983 952.9G Linux filesystem


Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 200 GiB, 214748364800 bytes, 419430400 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@jdcuser:~# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv 
resize2fs 1.45.5 (07-Jan-2020)
The filesystem is already 52428800 (4k) blocks long.  Nothing to do!

编辑:

以下是输出sudo pvs; sudo vgs; sudo lvs

root@jdcuser:~# sudo pvs; sudo vgs; sudo lvs
  PV         VG        Fmt  Attr PSize   PFree  
  /dev/sda3  ubuntu-vg lvm2 a--  952.86g 752.86g
  /etc/lvm/archive: mkdir failed: No space left on device
  /etc/lvm/backup: mkdir failed: No space left on device
  VG        #PV #LV #SN Attr   VSize   VFree  
  ubuntu-vg   1   1   0 wz--n- 952.86g 752.86g
  LV        VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  ubuntu-lv ubuntu-vg -wi-ao---- 200.00g 

答案1

对您来说好消息是卷组有额外的空间,因此我们可以尝试实时调整大小。

警告:无论何时修改磁盘上的数据或进行分区,都应该备份关键数据,以防万一!

首先我们需要扩展逻辑卷ubuntu-lv来填充可用的卷组空间。

sudo lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

一旦完成,如果它成功完成,那么我们只需要扩展文件系统:

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

这应该会扩展您的 Ubuntu 根分区以适合可用的磁盘大小。

之后我将重新启动以确保系统识别更改并且任何“空间不足”锁都会消失。

相关内容