前言

家里云安装了Ubuntu20,只安装了Nginx作为所有网络的入口服务器,最新在做文件上传的时候,发现文件上传到最后才出现异常,开始以为是网络问题,最后发现是Nginx所在服务器的临时缓存硬盘空间不足,网络上的各种解法都很混乱,这里针对这台机器做个记录。

修复分区表异常

QQ_1739513198412
这里调整大小是不会实时生效的,

1. 检查磁盘信息

fdisk -l

可以看到异常信息

GPT PMBR size mismatch (146800639 != 157286399) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Disk /dev/sda: 75 GiB, 80530636800 bytes, 157286400 sectors
Disk model: QEMU HARDDISK   

2. 使用以下命令修复

apt-get update
apt-get install parted
parted -l

弹出Fix/Ignore?的提示
输入Fix后回车即可。
QQ_1739513502932

扩容物理卷

1. 执行扩容命令

执行

parted /dev/sda

此时会出现

 parted /dev/sda
GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)    

输入

print

返回提示

 parted /dev/sda
GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 80.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2097kB  1049kB                     bios_grub
 2      2097kB  1881MB  1879MB  ext4
 3      1881MB  75.2GB  73.3GB

(parted)   

输入扩容命令

resizepart 3 100%
quit

返回

(parted) resizepart 3 100%                                                
(parted) quit                                                             
Information: You may need to update /etc/fstab.

2. 更新物理卷的大小

pvresize /dev/sda3

扩容硬盘

1. 扩容硬盘

输入

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

返回

 Size of logical volume ubuntu-vg/ubuntu-lv changed from <68.25 GiB (17471 extents) to <73.25 GiB (18751 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.

2. 更新文件系统大小

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

返回

resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 9, new_desc_blocks = 10
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 19201024 (4k) blocks long.

3. 扩容成功

QQ_1739514236302

Q.E.D.


味无味处求吾乐,材不材间过此生。