CentOS のパーティショニング

CentOS のパーティショニング

1 TB のディスクを 2 つ搭載した CentOS サーバーを所有しています。ただし、パーティション分割が適切ではありません。以下を確認してください。

[root@p16282558 ~]# fdisk -l

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 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: 0xd4f28eb2

   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      121602   970470104   fd  Linux raid autodetect
Partition 3 does not end on cylinder boundary.

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 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: 0x724abfe3

   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      121602   970470104   fd  Linux raid autodetect
Partition 3 does not end on cylinder boundary.

Disk /dev/md3: 993.8 GB, 993761296384 bytes
2 heads, 4 sectors/track, 242617504 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/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 / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg00-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 / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg00-var: 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/vg00-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 / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

走ったときdf

[root@p16282558 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md1              4.0G  4.0G     0 100% /
/dev/mapper/vg00-usr  4.0G  1.5G  2.4G  38% /usr
/dev/mapper/vg00-var  4.0G  880M  2.9G  23% /var
/dev/mapper/vg00-home
                      4.0G  136M  3.7G   4% /home
none                  7.9G  556K  7.9G   1% /tmp

/optは 内にあり/、 にはスペースが残っていません/

私のは/etc/fstabこんな感じです:

/dev/md1        /               ext3    defaults        1 1
/dev/sda2   none            swap    sw
/dev/sdb2   none            swap    sw
/dev/vg00/usr   /usr            ext4    defaults        0 2
/dev/vg00/var   /var            ext4    defaults,usrquota   0 2
/dev/vg00/home  /home           ext4    defaults,usrquota   0 2
devpts          /dev/pts        devpts  gid=5,mode=620  0 0
none            /proc           proc    defaults        0 0
none            /tmp    tmpfs   defaults        0 0

つまり、ディスクがいっぱいmd1で、未使用のディスク/dev/md3に 993.8 GB の空き容量があるということですか?

しかし、

[root@p16282558 ~]# df -h /dev/md3
Filesystem            Size  Used Avail Use% Mounted on
-                     7.9G  204K  7.9G   1% /dev

これは、システムの起動時にマウントされていないことを意味しますか/dev(fstab に従って)?

Output of vgdisplay:

--- Volume group ---
  VG Name               vg00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               925.51 GiB
  PE Size               4.00 MiB
  Total PE              236931
  Alloc PE / Size       3072 / 12.00 GiB
  Free  PE / Size       233859 / 913.51 GiB

問題は、/optより多くのスペースがあるディスク/パーティションにマウントする必要があることです。すべてのディスク領域を効率的に利用するために、ディスクを再構築するにはどうすればよいでしょうか?

答え1

出力によると、未割り当て領域 (値)vgdisplayが 900 GB 以上あります。Free PE

ルート ボリュームは LVM ボリュームではなく、/opt現在 上にあるため/、使用可能な領域を増やすことはできません。
ただし、 に新しいファイル システムを作成することはできます/opt

プロセスは次のようになります。

# create a new 5gb logical volume
lvcreate -n opt -L 5G vg00

# format it as ext4
mkfs.ext4 /dev/vg00/opt

# move the old dir out of the way
mv /opt /opt.orig

# mount the new logical volume
echo "/dev/vg00/opt /opt ext4 defaults 0 2" >> /etc/fstab
mkdir /opt
mount /opt

# move all data into the new mount
mv /opt.orig/* /opt
rmdir /opt.orig

LVM ではボリュームのサイズ変更が許可されているため、将来的に にスペースを追加する必要がある場合でも/opt、非常に簡単に行うことができます。

答え2

両方の出力を見るとvgsvgdisplay約 913.51 GB の空き PE があることがわかります。これらは物理エクステントであり、LVM ボリューム グループ (VG) にはこれらの物理エクステントが何にも割り当てられていません。これらは空き領域です。

Output of vgdisplay:

--- Volume group ---
  VG Name               vg00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               925.51 GiB
  PE Size               4.00 MiB
  Total PE              236931
  Alloc PE / Size       3072 / 12.00 GiB
  Free  PE / Size       233859 / 913.51 GiB

したがって、これらの物理エクステントを割り当てる必要があると結論付けます。この VG 内の論理ボリューム (LV) の 1 つを拡張してすべての空き領域を割り当てる最も簡単な方法は、たとえば次のコマンドです。

$ sudo lvextend -l+233859 /dev/vg00/home

+233859ここで、 PE の( ) を LV に追加します/dev/vg00/home

関連情報