ubuntu磁盘分区

root@ubuntu:~# df -lh
Filesystem                   Size  Used Avail Use% Mounted on
udev                         7.9G     0  7.9G   0% /dev
tmpfs                        1.6G  8.8M  1.6G   1% /run
/dev/mapper/ubuntu--vg-root  80G   79G   1G   99% /
tmpfs                        7.9G     0  7.9G   0% /dev/shm
tmpfs                        5.0M     0  5.0M   0% /run/lock
tmpfs                        7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/sda1                    472M  313M  135M  70% /boot
tmpfs                        100K     0  100K   0% /run/lxcfs/controllers
overlay                      555G   79G  453G  15% /var/lib/docker/overlay2/9a04529da03da1c8cc2cdff91938fdb5eee74cace8ee05598de90db02fc043da/merged
root@ubuntu:~# ls
root@ubuntu:~# 
root@ubuntu:~# 
root@ubuntu:~# lsblk
NAME                  MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                     8:0    0   200G  0 disk  
|-sda1                  8:1    0   487M  0 part  /boot
|-sda2                  8:2    0     1K  0 part  
`-sda5                  8:5    0  99.5G  0 part  
  |-ubuntu--vg-root   252:0    0 563.5G  0 lvm   /
  `-ubuntu--vg-swap_1 252:1    0    16G  0 lvm   
    `-cryptswap1      252:2    0    16G  0 crypt [SWAP]
sdb                     8:16   0   500G  0 disk  
sr0                    11:0    1   655M  0 rom   

接下来对sdb进行分区
查看具体的需要扩容的路径为/dev/mapper/ubuntu--vg-root
root@ubuntu:~# fdisk -l
Disk /dev/sdb: 500 GiB, 536870912000 bytes, 1048576000 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
Disklabel type: dos
Disk identifier: 0x4970329d

Device     Boot Start        End    Sectors  Size Id Type
/dev/sdb3        2048 1048575999 1048573952  500G 83 Linux


Disk /dev/sda: 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
Disklabel type: dos
Disk identifier: 0x8fb316e8

Device     Boot   Start       End   Sectors  Size Id Type
/dev/sda1  *       2048    999423    997376  487M 83 Linux
/dev/sda2       1001470 209713151 208711682 99.5G  5 Extended
/dev/sda5       1001472 209713151 208711680 99.5G 8e Linux LVM


Disk /dev/mapper/ubuntu--vg-root: 80 GiB, 605074489344 bytes, 1181786112 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


然后fdisk,注意分区格式化的是/dev/sdb,搞错了就自己找个地方躲起来

fdisk /dev/sdb

按n
按p
按1-1
按w保存
分区好了再lsblk看看
root@ubuntu:~# lsblk
NAME                  MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                     8:0    0   200G  0 disk  
|-sda1                  8:1    0   487M  0 part  /boot
|-sda2                  8:2    0     1K  0 part  
`-sda5                  8:5    0  99.5G  0 part  
  |-ubuntu--vg-root   252:0    0  80G  0 lvm   /
  `-ubuntu--vg-swap_1 252:1    0    16G  0 lvm   
    `-cryptswap1      252:2    0    16G  0 crypt [SWAP]
sdb                     8:16   0   500G  0 disk  
`-sdb3                  8:19   0   500G  0 part  
sr0                    11:0    1   655M  0 rom 

现在分区有了
但是要做成lvm才可以

root@ubuntu:~# vgs
  VG        #PV #LV #SN Attr   VSize  VFree
  ubuntu-vg   1   2   0 wz--n- 99.52g    0 

ubuntu-vg这个好像是分区组的意思

然后把/dev/sdb3划分到这个分区组里面

root@ubuntu:~# vgextend ubuntu-vg /dev/sdb3
  Physical volume "/dev/sdb3" successfully created
  Volume group "ubuntu-vg" successfully extended
root@ubuntu:~# vgs
  VG        #PV #LV #SN Attr   VSize   VFree  
  ubuntu-vg   2   2   0 wz--n- 599.52g 500.00g

然后扩容
root@ubuntu:~# lvextend /dev/mapper/ubuntu--vg-root -L +480G
  Size of logical volume ubuntu-vg/root changed from 83.52 GiB (21381 extents) to 563.52 GiB (144261 extents).
  Logical volume root successfully resized.

最后更新
root@ubuntu:~# resize2fs /dev/mapper/ubuntu--vg-root
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/mapper/ubuntu--vg-root is mounted on /; on-line resizing required
old_desc_blocks = 6, new_desc_blocks = 36
The filesystem on /dev/mapper/ubuntu--vg-root is now 147723264 (4k) blocks long.

 

你可能感兴趣的:(LINUX)