大网数据广告活动
服务器运维问答

Debian disk full, How to increase size?

· 52CE 我爱测

I have a small web server running Debian 7. If I run command df -h , I can see that I have /dev/mapper/deb--webxxx-root/ allmost full, 17 megabytes of free space. How can I allocate more free space? /dev/mapper/deb--webxxx-home/ …

问题原文

原帖链接 · Timo77 · CC BY-SA 3.0

I have a small web server running Debian 7. If I run command df -h, I can see that I have /dev/mapper/deb--webxxx-root/ allmost full, 17 megabytes of free space.

How can I allocate more free space? /dev/mapper/deb--webxxx-home/ has 130 gigabytes of free space. Can I some how move some of that free space to another mapper? Debian is a virtual machine so I could add more disk space quite easily too, but how?

I 'am newbaby on these debian server things...

pvdisplay:

--- Physical volume ---
  PV Name               /dev/sda5
  VG Name               deb-web138
  PV Size               159,76 GiB / not usable 2,00 MiB
  Allocatable           yes (but full)
  PE Size               4,00 MiB
  Total PE              40898
  Free PE               0
  Allocated PE          40898
  PV UUID               3rsJgY-I7KJ-Mv7H-xQ3Z-jNGn-z4bE-eKTUmH

Vgdisplay

  --- Volume group ---
  VG Name               deb-web138
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                6
  Open LV               6
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               159,76 GiB
  PE Size               4,00 MiB
  Total PE              40898
  Alloc PE / Size       40898 / 159,76 GiB
  Free  PE / Size       0 / 0
  VG UUID               90CrJD-xtBB-DaZB-UD1R-Lzxj-90w2-kZROya

lvdisplay

  LV Path                /dev/deb-web138/tmp
  LV Name                tmp
  VG Name                deb-web138
  LV UUID                IKNzaW-t55g-FiIK-lP8L-3OFe-Lg8z-hg910U
  LV Write Access        read/write
  LV Creation host, time deb-web138, 2014-12-15 16:18:55 +0200
  LV Status              available
  # open                 1
  LV Size                380,00 MiB
  Current LE             95
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:4

lvscan

  ACTIVE            '/dev/deb-web138/root' [332,00 MiB] inherit
  ACTIVE            '/dev/deb-web138/usr' [8,38 GiB] inherit
  ACTIVE            '/dev/deb-web138/var' [2,79 GiB] inherit
  ACTIVE            '/dev/deb-web138/swap_1' [4,00 GiB] inherit
  ACTIVE            '/dev/deb-web138/tmp' [380,00 MiB] inherit
  ACTIVE            '/dev/deb-web138/home' [143,89 GiB] inherit

社区高分解答

原帖链接 · Simon MC. Cheng · CC BY-SA 3.0

Since you are running a virtual machine and adding new disk is easy task, I would suggest you to add a new virtual disk instead of shrinking /home because it might be difficult for you.

Depends on your VM host, add a new virtual disk to your VM.

Then, check the device name for your new disk by:

# fdisk -l

You will get something similar to below:

Disk /dev/sdb: 70.9 GB, 70866960384 bytes
255 heads, 63 sectors/track, 8615 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Next, you need to either partition your disk or simply make use of whole disk:

To partition your disk (assume you have disk with label /dev/sdb) added:

# fdisk /dev/sdb
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-8615, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-8615, default 8615):
Using default value 8615

Next, you need to format the disk the become a Physical Volume of LVM:

# pvcreate /dev/sdb1

From your information, you have a volume group deb-web138. So you can add new space by:

# vgextend deb-web138 /dev/sdb1

You will now have new space added to volume group, resize your logical volume root by 70G for example:

# lvresize -L+70G /dev/deb-web138/root
# resize2fs /dev/deb-web138/root

When the resizing operation completes, you will have new free space and can be checked by the command:

# df -h

When you need to add new space again, you can add new virtual disk and follow the procedure as mentioned above.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-08-12)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。