需要增加 Centos 上的磁盘大小

需要增加 Centos 上的磁盘大小

我有一台 Linux 专用服务器,我需要更多空间,比如 500G。我发现我的文件系统只有 4G。我从这篇文章中找到了一篇增加逻辑卷大小的文章 https://help.1and1.com/servers-c37684/dedicated-server-linux-c37687/administration-c37694/increase-the-size-of-the-logical-volume-a756168.html(我在 1and1)

所以我做了以下事情:

首先,我在一个目录上安装了两个文件系统,由于某种原因,umount 命令不起作用

[root@u17669867 ~]# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/md1             4.0G  2.7G  1.4G  67% /
/dev/mapper/ssd-var  4.0G  2.7G  1.4G  67% /

[root@u17669867 ~]# fdisk -l
Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
81 heads, 63 sectors/track, 382818 cylinders
Units = cylinders of 5103 * 512 = 2612736 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x4dfb2370

Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1      382819   976761560   fd  Linux raid autodetect

Disk /dev/sdb: 240.1 GB, 240057409536 bytes
255 heads, 63 sectors/track, 29185 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: 0xb322c93e

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         523     4194304   fd  Linux raid autodetect
Partition 1 does not end on cylinder boundary.
/dev/sdb2             523         784     2097152   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sdb3             784       29186   228138584   fd  Linux raid autodetect
Partition 3 does not end on cylinder boundary.

Disk /dev/sdd: 1000.2 GB, 1000204886016 bytes
81 heads, 63 sectors/track, 382818 cylinders
Units = cylinders of 5103 * 512 = 2612736 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x8c756b43

Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1      382819   976761560   fd  Linux raid autodetect

Disk /dev/sda: 240.1 GB, 240057409536 bytes
255 heads, 63 sectors/track, 29185 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: 0x26616fe2

Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         523     4194304   fd  Linux raid autodetect
Partition 1 does not end on cylinder boundary.
/dev/sda2             523         784     2097152   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             784       29186   228138584   fd  Linux raid autodetect
Partition 3 does not end on cylinder boundary.

Disk /dev/md3: 233.6 GB, 233613819904 bytes
2 heads, 4 sectors/track, 57034624 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/md1: 4294 MB, 4294901760 bytes
2 heads, 4 sectors/track, 1048560 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/md11: 1000.2 GB, 1000203747328 bytes
2 heads, 4 sectors/track, 244190368 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/hdd-data: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/ssd-usr: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 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


Disk /dev/mapper/ssd-var: 15.0 GB, 15032385536 bytes
255 heads, 63 sectors/track, 1827 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


Disk /dev/mapper/ssd-home: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 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

在这里我看到了我有多少个物理卷

[root@u17669867 ~]# pvs
PV         VG   Fmt  Attr PSize   PFree
/dev/md11  hdd  lvm2 a--  931.51g 927.51g
/dev/md3   ssd  lvm2 a--  217.57g 195.57g

这里我尝试添加一些空间,例如 10G 到我正在使用的磁盘

[root@u17669867 ~]# lvextend -L +10 /dev/md1
Path required for Logical Volume "md1"
Please provide a volume group name
Run `lvextend --help' for more information.
[root@u17669867 ~]#

但我不是专业人士,也不知道在哪里添加空间……只要我的网页内容存储在 /var/www/ 目录中即可。所以我可能必须将磁盘安装到该目录,因为正如我从这里看到的:

[root@u17669867 /]# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/md1             4.0G  2.7G  1.4G  67% /
/dev/mapper/ssd-var  4.0G  2.7G  1.4G  67% /

/var 上没有挂载任何内容

如果可能的话,请帮助我。

答案1

您有一个“md11”磁盘,这可能意味着您在盒子上安装了软件 raid。好消息是,您在主磁盘上获得了大量空间 1T,SSD 驱动器上获得了 256GB。

您应该粘贴您的 fstab、lvs 的输出和 mount 的输出。

解决空间问题最简单的方法是

lvcreate -L 10G -n var_www hdd
mkfs.ext4 /dev/mapper/hdd-var_www

在 fstab 中添加以下行:/dev/mapper/hdd-var_www /var/www ext4 defaults 0 1

然后输入 mount /var/www 来检查您编辑的 fstab 是否正确。

或者,如果 lvs 和 mount 的输出确认你的斜线位于 lv 上,你可以输入

 lvextend -L +10G /dev/mapper/<vg-lvname>

并使用与 fs 对应的文件系统工具命令,将 fs 大小增加到分区大小,对于 ext2,3,4 来说,它将是

 resize2fs /dev/mapper/<vg-lvname>

相关内容