如何缩小 /var FS(ext4)以创建新分区

如何缩小 /var FS(ext4)以创建新分区

我是 Ubuntu 14.04 的新手。我们有一个运行 Ubuntu 14.04 的服务器,我的需求是缩小 /var 文件系统 (ext4) 并使用从与 /var FS 相关的卷中释放的空间创建一个新分区。

注意 - 我们没有存储空间分配给此服务器。有人能帮我吗?

仅供参考,服务器上仅创建一个 VG

root@Belga:~# fdisk -l

Disk /dev/sda: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders, total 838860800 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 identifier: 0x0000b970

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758   838858751   419178497    5  Extended
/dev/sda5          501760   838858751   419178496   8e  Linux LVM

Disk /dev/mapper/Belga--vg-swap_1: 8585 MB, 8585740288 bytes
255 heads, 63 sectors/track, 1043 cylinders, total 16769024 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 identifier: 0x00000000

Disk /dev/mapper/Belga--vg-swap_1 doesn't contain a valid partition table

Disk /dev/mapper/Belga--vg-root: 25.0 GB, 24998051840 bytes
255 heads, 63 sectors/track, 3039 cylinders, total 48824320 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 identifier: 0x00000000

Disk /dev/mapper/Belga--vg-root doesn't contain a valid partition table

Disk /dev/mapper/Belga--vg-var: 363.9 GB, 363906203648 bytes
255 heads, 63 sectors/track, 44242 cylinders, total 710754304 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 identifier: 0x00000000

Disk /dev/mapper/Belga--vg-var doesn't contain a valid partition table

Disk /dev/mapper/Belga--vg-tmp: 1996 MB, 1996488704 bytes
255 heads, 63 sectors/track, 242 cylinders, total 3899392 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 identifier: 0x00000000

Disk /dev/mapper/Belga--vg-tmp doesn't contain a valid partition table

root@Belga:~#

root@Belga:~# vgs
  VG             #PV #LV #SN Attr   VSize   VFree

  Belga-vg   1   4   0 wz--n- 399.76g 27.71g

root@Belga:~# lvs
  LV     VG             Attr      LSize   Pool Origin Data%  Move Log Copy%  Convert
  root   Belga-vg -wi-ao---  23.28g
  swap_1 Belga-vg -wi-ao---   8.00g
  tmp    Belga-vg -wi-ao---   1.86g
  var    Belga-vg -wi-ao--- 338.91g
root@Belga:~#

root@Belga:~# df -h
Filesystem                                         Size  Used Avail Use% Mounted on
/dev/mapper/Belga--vg-root                    23G   19G  3.1G  86% /
udev                                               4.9G   12K  4.9G   1% /dev
tmpfs                                             1001M  644K 1000M   1% /run
/dev/mapper/Belga--vg-var                    334G  240G   80G  76% /var
/dev/mapper/Belga--vg-tmp                    1.8G  596M  1.2G  35% /tmp

答案1

嗯,我通常这样做:

  • 从 CD 启动任何基于 Debian 的实时系统
  • 备份你的磁盘
  • sudo apt-get install gparted(如果尚未安装)
  • sudo gparted &
  • 缩小你的分区
  • 创建新分区

任何问题?

相关内容