丹东企业做网站,福建建设工程环保备案网站入口,怎么做网站快捷方式,cname解析对网站影响Linux系统扩容根目录磁盘空间的操作方法一、使用背景Linux根目录磁盘空间不够用了#xff0c;当修改了虚拟机模版增加磁盘大小或者插入了一块新硬盘#xff0c;但是发现系统里的大小还是没改变。产生的原因是没有给磁盘格式化#xff0c;没有增加分区。二、操作方法1.查看磁…Linux系统扩容根目录磁盘空间的操作方法一、使用背景Linux根目录磁盘空间不够用了当修改了虚拟机模版增加磁盘大小或者插入了一块新硬盘但是发现系统里的大小还是没改变。产生的原因是没有给磁盘格式化没有增加分区。二、操作方法1.查看磁盘空间大小使用df -h 命令发现挂载根目录节点的/dev/mapper/vg_node003-lv_root 只有7.1G容量。[rootnode-002 ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg_node003-lv_root 18G 9.3G 7.1G 57% /tmpfs 491M 0 491M 0% /dev/shm/dev/sda1 477M 42M 411M 10% /boot2.增加磁盘空间例如下图使用VM虚拟机增加的方式。3.使用fdisk -l命令查看磁盘信息。当看到第一行Disk /dev/sda: 53.7 GB与实际df -h显示内容不符时说明增加磁盘成功了。[rootnode-002 ~]# fdisk -lDisk /dev/sda: 53.7 GB, 53687091200 bytes255 heads, 63 sectors/track, 6527 cylindersUnits cylinders of 16065 * 512 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00092cf6Device 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/mapper/vg_node003-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/vg_node003-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: 0x000000004.使用fdisk /dev/sda, 创建新分区。注意不同操作系统的磁盘命名方式不同有些是/dev/vda。具体使用方式参考第三步中fdisk -l首行显示Disk。如笔者在该系统中首行显示为Disk /dev/sda: 53.7 GB, 53687091200 bytes 故使用命令fdisk /dev/sda)按照下面Linux操作进行分区。[rootnode-002 ~]# fdisk /dev/vda命令(输入 m 获取帮助) m命令操作a toggle a bootable flagb edit bsd disklabelc toggle the dos compatibility flagd delete a partitionl list known partition typesm print this menun add a new partitiono create a new empty DOS partition tablep print the partition tableq quit without saving changess create a new empty Sun disklabelt change a partitions system idu change display/entry unitsv verify the partition tablew write table to disk and exitx extra functionality (experts only)命令(输入 m 获取帮助) n #new 新分区Partition type:p primary (1 primary, 1 extended, 2 free)l logical (numbered from 5)Select (default p): p #选择主分区分区号 (1-4默认为 3) 3 #分区序号起始 sector (499712-314572799默认为 499712) #分区开始回车默认将使用默认值 499712Last sector, 扇区 or size{K,M,G} (499712-501757默认为 501757)将使用默认值 501757命令(输入 m 获取帮助) n #new 新分区Partition type:p primary (2 primary, 1 extended, 1 free)l logical (numbered from 5)Select (default p): p #选择主分区Selected partition 4 #分区序号起始 sector (62912512-314572799默认为 62912512) #分区开始回车默认将使用默认值 62912512Last sector, 扇区 or size{K,M,G} (62912512-314572799默认为 314572799)将使用默认值 314572799命令(输入 m 获取帮助) t #修改分区格式分区号 (1-5): 4 #修改分区号Hex code (type L to list codes): 8e #格式选择8e linux LVMChanged system type of partition 4 to 8e (Linux LVM)命令(输入 m 获取帮助) p #显示分区信息Disk /dev/sda: 161.1 GB, 161061273600 bytes16 heads, 63 sectors/track, 312076 cylinders, total 314572800 sectorsUnits 扇区 of 1 * 512 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0001a023设备 启动 起点 终点 块数 Id 系统/dev/sda1 * 2048 499711 248832 83 Linux/dev/sda2 501758 62912511 31205377 5 扩展/dev/sda3 499712 501757 1023 83 LinuxPartition table entries are not in disk order命令(输入 m 获取帮助) w #保存信息The partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)Syncing disks.5.重启Linux操作系统使用reboot命令。6.创建物理卷使用pvcreate /dev/sda3命令。[rootnode-002 dev]# pvcreate /dev/sda3Physical volume /dev/sda3 successfully created7.查看新建的物理卷和大小使用pvdisplay命令。[rootnode-002 dev]# pvdisplay--- Physical volume ---PV Name /dev/sda2VG Name vg_node003PV Size 19.51 GiB / not usable 3.00 MiBAllocatable yes (but full)PE Size 4.00 MiBTotal PE 4994Free PE 0Allocated PE 4994PV UUID UC4j5m-rJO4-DroW-E92L-n5Vj-SU0U-PJyfJf/dev/sda3 is a new physical volume of 30.00 GiB--- NEW Physical volume ---PV Name /dev/sda3VG NamePV Size 30.00 GiBAllocatable NOPE Size 0Total PE 0Free PE 0Allocated PE 0PV UUID nng8Gx-51fP-DIBH-YeF4-Sw7B-S0jQ-oGXfpa8.将添加新的物理卷加载到vg_node003卷组使用vgextend vg_node003 /dev/sda3命令。[rootnode-002 dev]# vgextend vg_node003 /dev/sda3Volume group vg_node003 successfully extended9.查看卷组信息使用vgdisplay命令。[rootnode-002 dev]# vgdisplay--- Volume group ---VG Name vg_node003System IDFormat lvm2Metadata Areas 2Metadata Sequence No 4VG Access read/writeVG Status resizableMAX LV 0Cur LV 2Open LV 2Max PV 0Cur PV 2Act PV 2VG Size 49.50 GiBPE Size 4.00 MiBTotal PE 12673Alloc PE / Size 4994 / 19.51 GiBFree PE / Size 7679 / 30.00 GiBVG UUID v37e5T-4iPX-olm0-Claw-8EfO-axHf-evCAfc10.增加vg_node003大小增加30G。使用lvresize -L 30G /dev/mapper/vg_node003-lv_root命令。注vg_node003-lv_root在/dev/mapper里面查看[rootnode-002 mapper]# lvresize -L 29.99G /dev/mapper/vg_node003-lv_rootRounding size to boundary between physical extents: 29.99 GiBSize of logical volume vg_node003/lv_root changed from 17.51 GiB (4482 extents) to 47.50 GiB (12160 extents).Logical volume lv_root successfully resized11.重新识别vg_node003大小使用resize2fs /dev/mapper/vg_node003-lv_root命令。[rootnode-002 mapper]# resize2fs /dev/mapper/vg_node003-lv_rootresize2fs 1.41.12 (17-May-2010)Filesystem at /dev/mapper/vg_node003-lv_root is mounted on /; on-line resizing requiredold desc_blocks 2, new_desc_blocks 3Performing an on-line resize of /dev/mapper/vg_node003-lv_root to 12451840 (4k) blocks.The filesystem on /dev/mapper/vg_node003-lv_root is now 12451840 blocks long.如出现下列情况resize2fs: Bad magic number in super-block 当尝试打开 /dev/mapper/vg_node003-lv_root 时 找不到有效的文件系统超级块.请使用xfs_growfs /dev/mapper/vg_node003-lv_root[rootnode-002 ~]# xfs_growfs /dev/mapper/vg_node003-lv_rootmeta-data/dev/mapper/centos-root isize512 agcount4, agsize2891264 blks sectsz512 attr2, projid32bit1 crc1 finobt0 spinodes0data bsize4096 blocks11565056, imaxpct25 sunit0 swidth0 blksnaming version 2 bsize4096 ascii-ci0 ftype1log internal bsize4096 blocks5647, version2 sectsz512 sunit0 blks, lazy-count1realtime none extsz4096 blocks0, rtextents0data blocks changed from 11565056 to 2467225612.查看扩容后的大小 使用df -h命令。[rootnode-002 mapper]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg_node003-lv_root 47G 9.3G 36G 21% /tmpfs 491M 0 491M 0% /dev/shm/dev/sda1 477M 42M 411M 10% /boot当看到/dev/mapper/vg_node003-lv_root 已经更新到新的大小时则表示增加成功。三、总结以上所述是小编给大家介绍的Linux系统扩容根目录磁盘空间的操作方法希望对大家有所帮助如果大家有任何疑问请给我留言小编会及时回复大家的。