debian 10 扩展分区容量

debian 10 扩展分区容量

  • 1、扩展分区原因
  • 2、添加一块磁盘
  • 3、命令记录
    • 3.1、新增加的磁盘是/dev/sdb
    • 3.2、使用磁盘/dev/sdb 创建物理卷
    • 3.3、 把物理卷/dev/sdb加入到卷组debian-vg中
    • 3.4、查看物理卷、逻辑卷
    • 3.5、扩展逻辑卷/tmp
    • 3.6、逻辑卷组debian-vg 空余空间被用掉10g 还剩90g可供分配
    • 3.7、查看逻辑卷/tmp的文件系统类型 为ext4
    • 3.8、更新文件系统,把增加的10G 更新到文件系统中

1、扩展分区原因

安装软件时,有些安装程序会把软件包解压到/tmp分区,导致/tmp分区占满,软件安装失败,因此需要扩展/tmp分区

2、添加一块磁盘


3、命令记录

root@debian:~# fdisk -l
Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 sectors
Disk model: VMware Virtual S
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: 0x62c59554

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/sdb: 100 GiB, 107374182400 bytes, 209715200 sectors
Disk model: VMware Virtual S
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/mapper/debian--vg-root: 18.7 GiB, 20103299072 bytes, 39264256 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/mapper/debian--vg-swap_1: 976 MiB, 1023410176 bytes, 1998848 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/mapper/debian--vg-var: 6.6 GiB, 7033847808 bytes, 13737984 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/mapper/debian--vg-tmp: 1.2 GiB, 1258291200 bytes, 2457600 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/mapper/debian--vg-home: 72.1 GiB, 77439434752 bytes, 151248896 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

3.1、新增加的磁盘是/dev/sdb

增加磁盘前

root@debian:~/Koal/package/dm8# ls  /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2	/dev/sda5

增加磁盘后重启系统 查看增加的是/dev/sdb

root@debian:/sys/class/scsi_host# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2	/dev/sda5  /dev/sdb

3.2、使用磁盘/dev/sdb 创建物理卷

root@debian:~# pvcreate /dev/sd
sda   sda1  sda2  sda5  sdb   
root@debian:~# pvs
  PV         VG        Fmt  Attr PSize   PFree
  /dev/sda5  debian-vg lvm2 a--  <99.52g    0 
root@debian:~# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created.
root@debian:~# pvs
  PV         VG        Fmt  Attr PSize   PFree  
  /dev/sda5  debian-vg lvm2 a--  <99.52g      0 
  /dev/sdb             lvm2 ---  100.00g 100.00g

3.3、 把物理卷/dev/sdb加入到卷组debian-vg中

root@debian:~# vgs
  VG        #PV #LV #SN Attr   VSize   VFree
  debian-vg   1   5   0 wz--n- <99.52g    0 
root@debian:~# vgextend debian-vg /dev/sd
/dev/sda5  /dev/sdb   
root@debian:~# vgextend debian-vg /dev/sdb 
  Volume group "debian-vg" successfully extended
root@debian:~# vgs
  VG        #PV #LV #SN Attr   VSize    VFree   
  debian-vg   2   5   0 wz--n- <199.52g <100.00g

3.4、查看物理卷、逻辑卷

root@debian:~# pvs
PV         VG        Fmt  Attr PSize    PFree   
/dev/sda5  debian-vg lvm2 a--   <99.52g       0 
/dev/sdb   debian-vg lvm2 a--  <100.00g <100.00g
root@debian:~# lvs
LV     VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
home   debian-vg -wi-ao----  72.12g                                                    
root   debian-vg -wi-ao----  18.72g                                                    
swap_1 debian-vg -wi-ao---- 976.00m                                                    
tmp    debian-vg -wi-ao----   1.17g                                                    
var    debian-vg -wi-ao----   6.55g                                                    
root@debian:~# df -lh 
Filesystem                   Size  Used Avail Use% Mounted on
udev                         3.9G     0  3.9G   0% /dev
tmpfs                        796M   18M  779M   3% /run
/dev/mapper/debian--vg-root   19G  9.6G  7.9G  55% /
tmpfs                        3.9G     0  3.9G   0% /dev/shm
tmpfs                        5.0M  4.0K  5.0M   1% /run/lock
tmpfs                        3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1                    470M   57M  389M  13% /boot
/dev/mapper/debian--vg-home   71G   12M   67G   1% /home
/dev/mapper/debian--vg-var   6.4G  493M  5.6G   8% /var
/dev/mapper/debian--vg-tmp   1.2G  408K  1.1G   1% /tmp
tmpfs                        796M   28K  796M   1% /run/user/116
tmpfs                        796M     0  796M   0% /run/user/0

3.5、扩展逻辑卷/tmp

root@debian:~# lvextend -L +10G /dev/debian-vg/
/dev/debian-vg/home    /dev/debian-vg/root    /dev/debian-vg/swap_1  /dev/debian-vg/tmp     /dev/debian-vg/var     
root@debian:~# lvextend -L +10G /dev/debian-vg/tmp 
Size of logical volume debian-vg/tmp changed from 1.17 GiB (300 extents) to 11.17 GiB (2860 extents).
Logical volume debian-vg/tmp successfully resized.

3.6、逻辑卷组debian-vg 空余空间被用掉10g 还剩90g可供分配

root@debian:~# vgs
VG        #PV #LV #SN Attr   VSize    VFree  
debian-vg   2   5   0 wz--n- <199.52g <90.00g
root@debian:~# df -lh
Filesystem                   Size  Used Avail Use% Mounted on
udev                         3.9G     0  3.9G   0% /dev
tmpfs                        796M   18M  779M   3% /run
/dev/mapper/debian--vg-root   19G  9.6G  7.9G  55% /
tmpfs                        3.9G     0  3.9G   0% /dev/shm
tmpfs                        5.0M  4.0K  5.0M   1% /run/lock
tmpfs                        3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1                    470M   57M  389M  13% /boot
/dev/mapper/debian--vg-home   71G   12M   67G   1% /home
/dev/mapper/debian--vg-var   6.4G  493M  5.6G   8% /var
/dev/mapper/debian--vg-tmp   1.2G  408K  1.1G   1% /tmp
tmpfs                        796M   28K  796M   1% /run/user/116
tmpfs                        796M     0  796M   0% /run/user/0

3.7、查看逻辑卷/tmp的文件系统类型 为ext4

root@debian:~# df -lTh
Filesystem                  Type      Size  Used Avail Use% Mounted on
udev                        devtmpfs  3.9G     0  3.9G   0% /dev
tmpfs                       tmpfs     796M   18M  779M   3% /run
/dev/mapper/debian--vg-root ext4       19G  9.6G  7.9G  55% /
tmpfs                       tmpfs     3.9G     0  3.9G   0% /dev/shm
tmpfs                       tmpfs     5.0M  4.0K  5.0M   1% /run/lock
tmpfs                       tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1                   ext2      470M   57M  389M  13% /boot
/dev/mapper/debian--vg-home ext4       71G   12M   67G   1% /home
/dev/mapper/debian--vg-var  ext4      6.4G  493M  5.6G   8% /var
/dev/mapper/debian--vg-tmp  ext4      1.2G  408K  1.1G   1% /tmp
tmpfs                       tmpfs     796M   28K  796M   1% /run/user/116
tmpfs                       tmpfs     796M     0  796M   0% /run/user/0

3.8、更新文件系统,把增加的10G 更新到文件系统中

root@debian:~# resize2fs /dev/
Display all 169 possibilities? (y or n)
root@debian:~# resize2fs /dev/mapper/
control            debian--vg-home    debian--vg-root    debian--vg-swap_1  debian--vg-tmp     debian--vg-var     
root@debian:~# resize2fs /dev/debian-vg/
home    root    swap_1  tmp     var     
root@debian:~# resize2fs /dev/debian-vg/tmp 
resize2fs 1.44.5 (15-Dec-2018)
Filesystem at /dev/debian-vg/tmp is mounted on /tmp; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/debian-vg/tmp is now 2928640 (4k) blocks long.

root@debian:~# df -lTh
Filesystem                  Type      Size  Used Avail Use% Mounted on
udev                        devtmpfs  3.9G     0  3.9G   0% /dev
tmpfs                       tmpfs     796M   18M  779M   3% /run
/dev/mapper/debian--vg-root ext4       19G  9.6G  7.9G  55% /
tmpfs                       tmpfs     3.9G     0  3.9G   0% /dev/shm
tmpfs                       tmpfs     5.0M  4.0K  5.0M   1% /run/lock
tmpfs                       tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1                   ext2      470M   57M  389M  13% /boot
/dev/mapper/debian--vg-home ext4       71G   12M   67G   1% /home
/dev/mapper/debian--vg-var  ext4      6.4G  493M  5.6G   8% /var
/dev/mapper/debian--vg-tmp  ext4       11G  408K   11G   1% /tmp
tmpfs                       tmpfs     796M   28K  796M   1% /run/user/116
tmpfs                       tmpfs     796M     0  796M   0% /run/user/0
root@debian:~#

你可能感兴趣的:(linux,linux)