centos系统扩容的问题
发布网友
发布时间:2022-05-05 11:46
我来回答
共2个回答
热心网友
时间:2022-06-27 11:33
着是我经验成果,希望对你有帮助.
有一次我调整VPS的时候发现自己的/分区的空间用光了.但是还剩下一个分区hda3没动.于是乎.想调整到根下面去.但是由于本人新手一个.又不太了解linux的分区机制.所以.百度满世界找答案,终于还是找到了.现在将执行代码贴出来.希望对不有帮助.
以下是Centos5给 / 分区扩容代码.
[root@localhost ~]# fdisk /dev/hda3
The number of cylinders for this disk is set to 3916.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/hda4: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000bc363
Device Boot Start End Blocks Id System
/dev/hda1 * 1 25 200781 83 Linux
/dev/hda2 26 1958 15526822+ 8e Linux LVM
/dev/hda3 1959 2610 5237190 8e Linux LVM
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Selected partition 4
First cylinder (2611-3916, default 2611):
Using default value 2611
Last cylinder or +size or +sizeM or +sizeK (2611-3916, default 3916):
Using default value 3916
Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/hda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000bc363
Device Boot Start End Blocks Id System
/dev/hda1 * 1 25 200781 83 Linux
/dev/hda2 26 1958 15526822+ 8e Linux LVM
/dev/hda3 1959 2610 5237190 8e Linux LVM
/dev/hda4 2611 3916 10490445 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
(注:建议重启一下CentOS系统)
[root@localhost ~]# pvcreate /dev/hda3
Physical volume "/dev/hda4" successfully created
[root@localhost ~]# vgextend VolGroup00 /dev/hda3
Volume group "VolGroup00" successfully extended
[root@localhost ~]# lvextend -l +100%FREE /dev/VolGroup00/LogVol00
Extending logical volume LogVol00 to 28.25 GB
Logical volume LogVol00 successfully resized
[root@localhost ~]# lvresize -l +100%FREE /dev/VolGroup00/LogVol00
New size (904 extents) matches existing size (904 extents)
lvresize: Resize a logical volume
lvresize
[-A|--autobackup y|n]
[--alloc AllocationPolicy]
[-d|--debug]
[-h|--help]
[-i|--stripes Stripes [-I|--stripesize StripeSize]]
{-l|--extents [+|-]LogicalExtentsNumber[%{VG|LV|FREE}] |
-L|--size [+|-]LogicalVolumeSize[kKmMgGtTpPeE]}
[-n|--nofsck]
[-r|--resizefs]
[-t|--test]
[--type VolumeType]
[-v|--verbose]
[--version]
LogicalVolume[Path] [ PhysicalVolumePath... ]
[root@localhost ~]# resize2fs /dev/VolGroup00/LogVol00
resize2fs 1.40.2 (12-Jul-2007)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 2
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 7405568 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 7405568 blocks long.
centos虚拟机LVM扩容方法:
1、在esxi4.0硬件配置界面,将硬盘直接由原来100G增大到256G
2、用安装光盘启动进入紧急救援系统
3、将增加空间进行分区,我是用Linux下的分区魔术师GParted,光驱启动后,在图形界面下增加一个sda3 。其实应该可以用fdisk与parted完成,我没有操作。
4、为了使用 LVM 先初始化一块 physical volumn :
pvcreate /dev/sda3
5、然后把它加到卷组 (volumn group) 里去:
vgextend vgextend VolGroup00 /dev/sda3
其中卷组名是通过 vgdisplay 看到的。这些命令非常有用: fdisk , parted, mkfs.ext3, df , mount ,另外还有 /etc/fstab 文件。
6、上面加入卷组成功后,扩展逻辑卷的容量,这个逻辑卷就是挂载到 / 上的分区,可以通过 mount 来看到:
lvextend -L +4.5G /dev/VolGroup00/LogVol00
7、最后是两条命令:
e2fsck -f /dev/VolGroup00/LogVol00
resize2fs /dev/VolGroup00/LogVol00
热心网友
时间:2022-06-27 11:34
linux 的 / 分区很少用到扩容。 你可以把其他分区挂载到根分区下,然后把数据放到这个目录下就行了。