Linux系统中怎么扩展根分区
发表于:2025-01-19 作者:千家信息网编辑
千家信息网最后更新 2025年01月19日,这篇文章主要介绍"Linux系统中怎么扩展根分区"的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇"Linux系统中怎么扩展根分区"文章能帮助大家解决问题。环境:V
千家信息网最后更新 2025年01月19日Linux系统中怎么扩展根分区
这篇文章主要介绍"Linux系统中怎么扩展根分区"的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇"Linux系统中怎么扩展根分区"文章能帮助大家解决问题。
环境:
VMware虚拟机Red Hat 6.5
技术:
逻辑卷管理(LVM)
具体步骤:
1.查看磁盘空间
[root@localhost ~]# df -h#查看磁盘空间,根分区的大小是18G,已经用了43%。Filesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 18G 7.0G 9.5G 43% /tmpfs 2.0G 76K 2.0G 1% /dev/shm/dev/sda1 485M 40M 421M 9% /boot/dev/sr0 3.6G 3.6G 0 100% /media/cdrom
2.创建磁盘分区
[root@localhost ~]# fdisk -lDisk /dev/sda: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00083529 Device Boot Start End Blocks Id System/dev/sda1 * 1 64 512000 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 64 2611 20458496 8e Linux LVM#/dev/sdb盘还有足够的空间Disk /dev/sdb: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/VolGroup-lv_root: 18.8 GB, 18798870528 bytes255 heads, 63 sectors/track, 2285 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/VolGroup-lv_swap: 2147 MB, 2147483648 bytes255 heads, 63 sectors/track, 261 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000[root@localhost ~]# fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0xac7c929b.Changes will remain in memory only, until you decide to write them.After that, of course, the previous content won't be recoverable.Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u').Command (m for help): pDisk /dev/sdb: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xac7c929b Device Boot Start End Blocks Id SystemCommand (m for help): nCommand action e extended p primary partition (1-4)pPartition number (1-4): 1#分区号First cylinder (1-2610, default 1): #回车用默认的Using default value 1Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): #回车用默认的Using default value 2610Command (m for help): t #改变类型Selected partition 1Hex code (type L to list codes): 8e #LVM的分区代码Changed system type of partition 1 to 8e (Linux LVM)Command (m for help): pDisk /dev/sdb: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xac7c929b Device Boot Start End Blocks Id System/dev/sdb1 1 2610 20964793+ 8e Linux LVMCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.[root@localhost ~]# partprobe#将磁盘分区表变化信息通知内核,请求操作系统重新加载分区表,有些小报错不要紧。Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.Error: Invalid partition table - recursive partition on /dev/sr0.
3.创建物理卷
[root@localhost ~]# fdisk -lDisk /dev/sda: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00083529 Device Boot Start End Blocks Id System/dev/sda1 * 1 64 512000 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 64 2611 20458496 8e Linux LVMDisk /dev/sdb: 21.5 GB, 21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xac7c929b Device Boot Start End Blocks Id System/dev/sdb1 1 2610 20964793+ 8e Linux LVMDisk /dev/mapper/VolGroup-lv_root: 18.8 GB, 18798870528 bytes255 heads, 63 sectors/track, 2285 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/VolGroup-lv_swap: 2147 MB, 2147483648 bytes255 heads, 63 sectors/track, 261 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000[root@localhost ~]# pvcreate /dev/sdb1#由fdisk -l查到LVM卷是/dev/sdb1,所以用/dev/sdb1来创建物理卷。 Physical volume "/dev/sdb1" successfully created
4.扩展卷组
[root@localhost ~]# pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name VolGroup PV Size 19.51 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 4994 Free PE 0 Allocated PE 4994 PV UUID qkBdcn-RQaR-ZliO-Ja2S-RhMC-stw8-CO213I "/dev/sdb1" is a new physical volume of "19.99 GiB" --- NEW Physical volume --- PV Name /dev/sdb1 VG Name PV Size 19.99 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID H7tDqG-6AZv-yBSA-U0ov-Ni0y-dlPA-kAA83i [root@localhost ~]# vgextend VolGroup /dev/sdb1 Volume group "VolGroup" successfully extendedYou have new mail in /var/spool/mail/root[root@localhost ~]# vgdisplay --- Volume group --- VG Name VolGroup System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 39.50 GiB PE Size 4.00 MiB Total PE 10112 Alloc PE / Size 4994 / 19.51 GiB Free PE / Size 5118 / 19.99 GiB VG UUID dc0vI9-KzGu-4S59-A1xv-NM4Y-rYBF-3jDNRn
5.扩展逻辑卷
[root@localhost ~]# lvextend -l +100%free /dev/mapper/VolGroup-lv_root#free也可以大写FREE Extending logical volume lv_root to 37.50 GiB Logical volume lv_root successfully resized[root@localhost ~]# blkid /dev/mapper/VolGroup-lv_root#查看分区文件系统类型/dev/mapper/VolGroup-lv_root: UUID="972fdddd-ddb8-469f-a342-e075eaeabeb2" TYPE="ext4"[root@localhost ~]# e2fsck -f /dev/mapper/VolGroup-lv_root#e2fsck -f检查分区e2fsck 1.41.12 (17-May-2010)/dev/mapper/VolGroup-lv_root is mounted.e2fsck: Cannot continue, aborting.[root@localhost ~]# resize2fs /dev/mapper/VolGroup-lv_root#如果分区是xfs系统,则用xfs_growfs命令对文件系统进行扩展resize2fs 1.41.12 (17-May-2010)Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing requiredold desc_blocks = 2, new_desc_blocks = 3Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 9830400 (4k) blocks.The filesystem on /dev/mapper/VolGroup-lv_root is now 9830400 blocks long.[root@localhost ~]# df -h#查看磁盘空间,根分区已扩展到37G。Filesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 37G 7.0G 29G 20% /tmpfs 2.0G 224K 2.0G 1% /dev/shm/dev/sda1 485M 40M 421M 9% /boot/dev/sr0 3.6G 3.6G 0 100% /media/cdrom
关于"Linux系统中怎么扩展根分区"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注行业资讯频道,小编每天都会为大家更新不同的知识点。
系统
磁盘
空间
知识
文件
物理
类型
行业
逻辑
分区表
不同
实用
不要紧
操作系统
代码
信息
内容
内核
命令
大写
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
浙江服务器维修维保价格
有个私人的服务器能干什么
pc我的世界服务器地址
学软件开发包薪资包就业
数据库test如何创建
富民创新软件开发价格信息
c语言 数据库
删除数据库sql2000
闻喜易枫网络技术
数据库的不安全因素主要有
baocms 数据库安装
服务器怎么看是千兆还是万兆
品质网络技术检查
网络安全公司产品经理
网络安全对个人影响和措施
软件开发培训学校高德地图
成都计算机软件开发大概要多少钱
toto打印服务器
上海护士数据库
应与网络安全机构
软件开发构建组装模型优缺点
福建省网络安全企业
宝塔里的数据库保存在哪
cf服务器已暂停图片
零梦服务器
淮大精诚软件开发有限公司
淄博卓勤网络技术有限公司
美旺网络技术有限公司
国泰安数据库能查托宾Q吗
数据库适配器