resp.text返回的是Unicode型的数据。

resp.content返回的是bytes型也就是二进制的数据

也就是说,如果你想取文本,可以通过r.text。

如果想取图片,文件,则可以通过r.content。

(resp.json()返回的是json格式数据)

大概情况就是,装了ubuntu之后,本来1个T的硬盘,df -h查看,只有100G.

Filesystem                         Size  Used Avail Use% Mounted on
udev                               3.9G     0  3.9G   0% /dev
tmpfs                              789M  1.4M  788M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   98G   35G   59G  37% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/loop1                         114M  114M     0 100% /snap/core/13425
/dev/loop0                         114M  114M     0 100% /snap/core/13308
/dev/loop4                          62M   62M     0 100% /snap/core20/1518
/dev/loop2                          68M   68M     0 100% /snap/lxd/22753
/dev/loop3                          40M   40M     0 100% /snap/hub/43
/dev/loop8                          47M   47M     0 100% /snap/snapd/16292
/dev/loop5                          47M   47M     0 100% /snap/snapd/16010
/dev/loop7                          68M   68M     0 100% /snap/lxd/21835
/dev/sda2                          1.5G  208M  1.2G  16% /boot
/dev/sda1                          1.1G  5.3M  1.1G   1% /boot/efi
/dev/loop9                          62M   62M     0 100% /snap/core20/1581
tmpfs                              789M     0  789M   0% /run/user/0

然后,lsblk:

NAME                      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0                       7:0    0 113.9M  1 loop /snap/core/13308
loop1                       7:1    0   114M  1 loop /snap/core/13425
loop2                       7:2    0  67.8M  1 loop /snap/lxd/22753
loop3                       7:3    0  39.3M  1 loop /snap/hub/43
loop4                       7:4    0  61.9M  1 loop /snap/core20/1518
loop5                       7:5    0    47M  1 loop /snap/snapd/16010
loop7                       7:7    0  67.2M  1 loop /snap/lxd/21835
loop8                       7:8    0    47M  1 loop /snap/snapd/16292
loop9                       7:9    0    62M  1 loop /snap/core20/1581
sda                         8:0    0 931.5G  0 disk 
├─sda1                      8:1    0   1.1G  0 part /boot/efi
├─sda2                      8:2    0   1.5G  0 part /boot
└─sda3                      8:3    0   929G  0 part 
  └─ubuntu--vg-ubuntu--lv 253:0    0   100G  0 lvm  /
sr0                        11:0    1  1024M  0 rom  

可以看到sda3,应该是有929G的,但是ubuntu那个lvm只有100G。大概意思就是还有828G多是未分配空间。
然后用vgs命令确认了:

 VG        #PV #LV #SN Attr   VSize    VFree   
  ubuntu-vg   1   1   0 wz--n- <928.96g <828.96g

vgdisplay:

  --- Volume group ---
  VG Name               ubuntu-vg
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <928.96 GiB
  PE Size               4.00 MiB
  Total PE              237813
  Alloc PE / Size       25600 / 100.00 GiB
  Free  PE / Size       212213 / <828.96 GiB
  VG UUID               jkV7YK-c0LY-v9au-nGj6-265a-n6bG-hGyV0d

可以看到当前的VG确实有剩余828.96G的空间。

lvdisplay:

  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                gOMnxJ-3ONt-ldWu-ZzU7-neh2-dygv-Z8qM5t
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2022-03-31 14:47:48 +0800
  LV Status              available
  # open                 1
  LV Size                100.00 GiB
  Current LE             25600
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

确实是只分配了100G。
好了现在要做的就是把未分配的828G,加到现有的lv里面就行了,使用命令lvextend:

lvextend -L +828G /dev/ubuntu-vg/ubuntu-lv   或  lvextend -l +212213 /dev/ubuntu-vg/ubuntu-lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from 100.00 GiB (25600 extents) to 928.00 GiB (237568 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.

然后刷新一下,使用resize2fs命令:

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

此时,再用df -h查看,可以看到,根目录已经是900多G了:

#df -h
Filesystem                         Size  Used Avail Use% Mounted on
udev                               3.9G     0  3.9G   0% /dev
tmpfs                              789M  1.4M  788M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  913G   35G  841G   4% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/loop1                         114M  114M     0 100% /snap/core/13425
/dev/loop0                         114M  114M     0 100% /snap/core/13308
/dev/loop4                          62M   62M     0 100% /snap/core20/1518
/dev/loop2                          68M   68M     0 100% /snap/lxd/22753
/dev/loop3                          40M   40M     0 100% /snap/hub/43
/dev/loop8                          47M   47M     0 100% /snap/snapd/16292
/dev/loop5                          47M   47M     0 100% /snap/snapd/16010
/dev/loop7                          68M   68M     0 100% /snap/lxd/21835
/dev/sda2                          1.5G  208M  1.2G  16% /boot
/dev/sda1                          1.1G  5.3M  1.1G   1% /boot/efi
/dev/loop9                          62M   62M     0 100% /snap/core20/1581
tmpfs                              789M     0  789M   0% /run/user/0

参考https://blog.csdn.net/cuichongxin/article/details/103064707