網頁

2016年12月5日 星期一

擴充pve 下的 debian 磁區大小

現在pve下的控制台 resize disk



wwh@cms:~$ sudo dmesg | grep vda

[    0.620525]  vda: vda1 vda2 < vda5 >
[    1.331007] EXT4-fs (vda1): mounting ext2 file system using the ext4 subsystem
[    1.334246] EXT4-fs (vda1): mounted filesystem without journal. Opts: (null)

wwh@cms:~$ sudo fdisk -l /dev/vda | grep ^/dev
/dev/vda1  *      2048   499711   497664  243M 83 Linux
/dev/vda2       501758 41940991 41439234 19.8G  5 Extended
/dev/vda5       501760 41940991 41439232 19.8G 8e Linux LVM


wwh@cms:~$ sudo parted /dev/vda
GNU Parted 3.2
Using /dev/vda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 236GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  256MB   255MB   primary   ext2         boot
 2      257MB   21.5GB  21.2GB  extended
 5      257MB   21.5GB  21.2GB  logical                lvm


(parted) resizepart 5 100%
Error: Can't have overlapping partitions.
此錯誤是因2是擴充詞區,5是邏輯磁碟,所以需要先擴充2,再擴充5。

(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 236GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  256MB   255MB   primary   ext2         boot
 2      257MB   21.5GB  21.2GB  extended
 5      257MB   21.5GB  21.2GB  logical                lvm

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


wwh@cms:~$ sudo fdisk -l /dev/vda | grep ^/dev
/dev/vda1  *      2048    499711    497664   243M 83 Linux
/dev/vda2       501758 461373439 460871682 219.8G  5 Extended
/dev/vda5       501760 461373439 460871680 219.8G 8e Linux LVM


wwh@cms:~$ sudo pvresize /dev/vda5

wwh@web:~$ sudo pvresize /dev/vda5
  Physical volume "/dev/vda5" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized



參考資料:https://pve.proxmox.com/wiki/Resize_disks


但是這樣還是沒有變大??

wwh@cms:~$ sudo pvs
[sudo] password for wwh:
  PV         VG    Fmt  Attr PSize   PFree
  /dev/vda5  D8-vg lvm2 a--  219.76g 200.00g

wwh@cms:~$ sudo vgs
  VG    #PV #LV #SN Attr   VSize   VFree
  D8-vg   1   2   0 wz--n- 219.76g 200.00g

wwh@cms:~$ sudo lvs
  LV     VG    Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   D8-vg -wi-ao----  18.91g
  swap_1 D8-vg -wi-ao---- 872.00m


wwh@cms:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/dm-0        19G  967M   17G   6% /
udev             10M     0   10M   0% /dev
tmpfs           794M  8.4M  785M   2% /run
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/vda1       236M   33M  191M  15% /boot

wwh@cms:~$ sudo fdisk -l /dev/vda | grep ^/dev
/dev/vda1  *      2048    499711    497664   243M 83 Linux
/dev/vda2       501758 461373439 460871682 219.8G  5 Extended
/dev/vda5       501760 461373439 460871680 219.8G 8e Linux LVM

--------這一段是錯誤示範(是我不會作亂弄的)------------------------------------------------------------


wwh@cms:~$ sudo lvresize -L+200G --resizefs /dev/dm-0
  Path required for Logical Volume "dm-0"
  Please provide a volume group name
  Run `lvresize --help' for more information.
wwh@cms:~$ sudo lvresize -L+200G --resizefs /dev/vda2
  Path required for Logical Volume "vda2"
  Please provide a volume group name
  Run `lvresize --help' for more information.

所以既不是dm-0 也不是vda2

--------  這一段是錯誤示範  ------------------------------------------------------------

那到底是??

wwh@cms:~$ sudo pvdisplay
  --- Physical volume ---
  PV Name               /dev/vda5
  VG Name               D8-vg
  PV Size               219.76 GiB / not usable 2.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              56258
  Free PE               51200
  Allocated PE          5058
  PV UUID               cC963w-****-****-****-PMdI-VPpH-McB99G

wwh@cms:~$ sudo vgdisplay | grep Name
  VG Name               D8-vg


wwh@cms:~$ sudo lvdisplay | grep Path
  LV Path                /dev/D8-vg/root
  LV Path                /dev/D8-vg/swap_1


終於找到正確的 LV Path

wwh@cms:~$ sudo lvextend -l +100%FREE /dev/D8-vg/root
  Size of logical volume D8-vg/root changed from 18.91 GiB (4840 extents) to 218.91 GiB (56040 extents).
  Logical volume root successfully resized


wwh@cms:~$ sudo resize2fs /dev/D8-vg/root
resize2fs 1.42.12 (29-Aug-2014)
Filesystem at /dev/D8-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 14
The filesystem on /dev/D8-vg/root is now 57384960 (4k) blocks long.

wwh@cms:~$ df -lh
Filesystem      Size  Used Avail Use% Mounted on
/dev/dm-0       216G  982M  206G   1% /
udev             10M     0   10M   0% /dev
tmpfs           794M  8.4M  785M   2% /run
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/vda1       236M   33M  191M  15% /boot


終於弄對了!!


沒有留言:

張貼留言