Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxmox ubuntu虚拟机扩容教程 #104

Open
Triment opened this issue May 9, 2024 · 0 comments
Open

Proxmox ubuntu虚拟机扩容教程 #104

Triment opened this issue May 9, 2024 · 0 comments

Comments

@Triment
Copy link
Owner

Triment commented May 9, 2024

企业微信截图_a42d378a-ae61-48a1-b1fe-adb8b7bbc700
在proxmox扩容磁盘后,需要在虚拟机中进行一些操作才能扩容

1、运行fdisk -l

root@ubuntu:~#  fdisk -l
Disk /dev/loop0: 63.95 MiB, 67051520 bytes, 130960 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: 87.02 MiB, 91246592 bytes, 178216 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: 63.91 MiB, 67010560 bytes, 130880 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: 87.03 MiB, 91258880 bytes, 178240 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: 177.95 MiB, 186589184 bytes, 364432 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: 177.95 MiB, 186593280 bytes, 364440 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/loop6: 39.1 MiB, 40996864 bytes, 80072 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/loop7: 38.73 MiB, 40615936 bytes, 79328 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
GPT PMBR size mismatch (419430399 != 838860799) will be corrected by write.
The backup GPT table is not on the end of the device.


Disk /dev/sda: 400 GiB, 429496729600 bytes, 838860800 sectors
Disk model: QEMU HARDDISK   
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: 21A12F61-5C76-4E93-872C-AB0978CD7F74

Device       Start       End   Sectors   Size Type
/dev/sda1     2048   2203647   2201600     1G EFI System
/dev/sda2  2203648   6397951   4194304     2G Linux filesystem
/dev/sda3  6397952 419428351 413030400 196.9G Linux filesystem


Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 98.47 GiB, 105734209536 bytes, 206512128 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

2、运行parted /dev/sda进行扩容分区

root@ubuntu:~#parted /dev/sda
GNU Parted 3.4
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) resizepart 3 100%
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 419430400 blocks) or
continue with the current setting? 
Fix/Ignore? fix                                                           
Partition number? 3                                                       
End?  [215GB]?                                                            
(parted)                                                                  
(parted) resizepart 3 100%                                                
(parted) quit
Information: You may need to update /etc/fstab.

3、再看一下fdisk -l

Disk /dev/loop0: 63.95 MiB, 67051520 bytes, 130960 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: 87.02 MiB, 91246592 bytes, 178216 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: 63.91 MiB, 67010560 bytes, 130880 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: 87.03 MiB, 91258880 bytes, 178240 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: 177.95 MiB, 186589184 bytes, 364432 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: 177.95 MiB, 186593280 bytes, 364440 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/loop6: 39.1 MiB, 40996864 bytes, 80072 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/loop7: 38.73 MiB, 40615936 bytes, 79328 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: 400 GiB, 429496729600 bytes, 838860800 sectors
Disk model: QEMU HARDDISK   
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: 21A12F61-5C76-4E93-872C-AB0978CD7F74

Device       Start       End   Sectors   Size Type
/dev/sda1     2048   2203647   2201600     1G EFI System
/dev/sda2  2203648   6397951   4194304     2G Linux filesystem
/dev/sda3  6397952 838860766 832462815 396.9G Linux filesystem


Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 98.47 GiB, 105734209536 bytes, 206512128 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

4、运行 pvresize /dev/sda3

root@ubuntu:~# pvresize /dev/sda3
  Physical volume "/dev/sda3" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

5、运行 lvresize --extents +100%FREE --resizefs /dev/mapper/ubuntu--vg-ubuntu--lv 扩张逻辑大小

root@ubuntu:~# lvresize --extents +100%FREE --resizefs /dev/mapper/ubuntu--vg-ubuntu--lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from 98.47 GiB (25209 extents) to <396.95 GiB (101618 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.
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 = 13, new_desc_blocks = 50
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 104056832 (4k) blocks long.

6、再次查看,成功

root@ubuntu:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              297M  1.4M  295M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  391G   34G  340G  10% /
tmpfs                              1.5G     0  1.5G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          2.0G  253M  1.6G  14% /boot
/dev/sda1                          1.1G  6.1M  1.1G   1% /boot/efi
tmpfs                              297M  4.0K  297M   1% /run/user/1000
overlay                            391G   34G  340G  10% /var/lib/docker/overlay2/4c9357912f040db8dcc205026125f8f3b60b0a76c63a8abd42785eb1f9b1328b/merged
overlay                            391G   34G  340G  10% /var/lib/docker/overlay2/2cf57926ae60af81c063858fc63619a30111930fbf37d82080e7af43894fe257/merged
tmpfs                              2.8G   12K  2.8G   1% /var/snap/microk8s/common/var/lib/kubelet/pods/2a00ddf5-402a-451f-a406-fef5ae5b823a/volumes/kubernetes.io~projected/kube-api-access-6ktmt
overlay                            391G   34G  340G  10% /var/lib/docker/overlay2/9296c1615ea942fc0162c8a28b2e4b8dc2439cd3129b7e9f6379508443d8eefe/merged
@Triment Triment added release 发布文章 and removed release 发布文章 labels May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant