centos lvm 扩容?centos7卸载软件命令
centos系统扩容的问题
着是我经验成果,希望对你有帮助.
有一次我调整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
centos下原磁盘扩容后给lvm的root根/文件系统扩容
在CentOS系统中,若需要对原磁盘扩容后给LVM的root文件系统扩容,可以按照以下步骤操作:
1.首先,在云主机管理界面为磁盘扩容,例如将100GB扩展为200GB,务必在操作前创建快照作为备份。
2.使用fdisk-l命令检查新扩容的磁盘,确认其已正确增加。
3.执行fdisk/dev/vda,为新磁盘创建一个新的分区。
4.重启服务器后,通过lsblk查看,新分区应已显示在设备列表中。
5.使用pvscan和vgdisplay命令,确认vg(卷组)的状态,然后执行vgextend centos/dev/vda3,将新分区加入到centos卷组,使其大小变为200GB。
6.接下来,检查逻辑卷(lv)的状况,如果需要,执行lvextend-l+100%FREE/dev/centos/root,按百分比方式为root逻辑卷扩容。
7.如果希望以固定大小追加,可使用lvextend-L+20G命令(替换为实际需要的大小)。
8.完成扩容后,使用df-h检查文件系统空间,确保扩容已生效。
9.最后,通过xfs_growfs/dev/centos/root命令执行文件系统的扩展,以使新空间生效。
10.检查df-h的结果,确认root文件系统已成功扩容。
这样,你就完成了在CentOS环境下,对原磁盘扩容后给LVM root文件系统的扩容操作。
Centos操作系统,硬盘容量不足,如何对对根目录进行扩容
在CentOS 7的虚拟机环境中,磁盘空间不足时,可以通过增加硬盘并利用Linux的逻辑卷管理(LVM)技术来对根目录进行扩容。首先,添加一块40GB的新硬盘sdb。有两种扩容方案:
1.**直接挂载方式**:虽然可以直接挂载新硬盘到指定目录,但这种方式限制了空间使用,不是最优选择。
2.**LVM扩容**:LVM是一种强大的磁盘管理工具,它允许在不重新分区的情况下动态调整分区大小。通过将新硬盘sdb1创建为物理卷pv,然后将其添加到卷组vg中(如"centos"),使用vgextend命令扩容卷组。接着,检查逻辑卷LV,可以有两种扩容逻辑卷的方法:一是指定大小,但需确保合适;二是让系统自动分配剩余空间。最后,通过xfs_growfs命令给文件系统扩容,确保根目录空间增加。
在操作过程中,首先使用fdisk对新硬盘分区,创建物理卷pv,接着扩容卷组vg,检查和调整逻辑卷,最后执行文件系统扩容命令,完成根目录的扩容。这种做法提供了更灵活和高效的磁盘使用管理。