CentOS 7 非 LVM 硬盘简单扩容

CentOS 7 非 LVM 硬盘简单扩容
狂犬主子CentOS 7 非 LVM 硬盘简单扩容
查看分区信息
1 | [root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk └─sda1 8:1 0 8G 0 part / sr0 11:0 1 1024M 0 rom sr1 11:1 1 1024M 0 rom [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 900M 0 900M 0% /dev tmpfs 919M 0 919M 0% /dev/shm tmpfs 919M 17M 903M 2% /run tmpfs 919M 0 919M 0% /sys/fs/cgroup /dev/sda1 8.0G 3.8G 4.3G 48% / tmpfs 184M 0 184M 0% /run/user/0 |
重新分区
用 cfdisk 也行,反正就是把原来的分区删了新建一个然后保存
1 | [root@localhost ~]# fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x00095067 Device Boot Start End Blocks Id System /dev/sda1 * 2048 16777215 8387584 83 Linux Command (m for help): d Selected partition 1 Partition 1 is deleted Command (m for help): p Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x00095067 Device Boot Start End Blocks Id System Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-41943039, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): Using default value 41943039 Partition 1 of type Linux and of size 20 GiB is set Command (m for help): p Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x00095067 Device Boot Start End Blocks Id System /dev/sda1 2048 41943039 20970496 83 Linux 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 or after you run partprobe(8) or kpartx(8) Syncing disks. |
刷新分区
1 | [root@localhost ~]# partprobe /dev/sda [root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk └─sda1 8:1 0 20G 0 part / sr0 11:0 1 1024M 0 rom sr1 11:1 1 1024M 0 rom [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 900M 0 900M 0% /dev tmpfs 919M 0 919M 0% /dev/shm tmpfs 919M 17M 903M 2% /run tmpfs 919M 0 919M 0% /sys/fs/cgroup /dev/sda1 8.0G 3.8G 4.2G 48% / tmpfs 184M 0 184M 0% /run/user/0 |
扩容分区
如果磁盘格式是 xfs:
1 | [root@localhost ~]# xfs_growfs /dev/sda1 meta-data=/dev/sda1 isize=512 agcount=4, agsize=524224 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=2096896, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 2096896 to 5242624 |
如果磁盘格式是 ext4:
1 | [root@localhost ~]# resize2fs /dev/sda1 |
扩容完成
1 | [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 900M 0 900M 0% /dev tmpfs 919M 0 919M 0% /dev/shm tmpfs 919M 17M 903M 2% /run tmpfs 919M 0 919M 0% /sys/fs/cgroup /dev/sda1 20G 3.8G 17G 19% / tmpfs 184M 0 184M 0% /run/user/0 |
参考资料:
评论
匿名评论隐私政策
✅ 你无需删除空行,直接评论以获取最佳展示效果