EXSI服务器上有一台linux主机起初分配的数据磁盘空间较小,导致现在空间不足,需要扩容磁盘
原数据盘大小:50GB
扩容目标大小:60GB
操作系统:CentOS 7.5
具体扩容过程
1.Vcenter控制台修改磁盘大小
2.重启系统
3. 查看磁盘容量
1 |
fdisk -l #磁盘容量60GB,并且已经存在分区/dev/sdb1 |
记录分区的起始扇区和结束扇区,本实例中起始扇区2048,结束扇区104857599
4.使用fdisk删除原有分区
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
[root@system ~]# fdisk -lu /dev/sdb Disk /dev/sdb: 64.4 GB, 64424509440 bytes, 125829120 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: 0xfb9f9341 Device Boot Start End Blocks Id System /dev/sdb1 2048 104857599 52427776 83 Linux [root@system ~]# fdisk -u /dev/sdb 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/sdb: 64.4 GB, 64424509440 bytes, 125829120 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: 0xfb9f9341 Device Boot Start End Blocks Id System /dev/sdb1 2048 104857599 52427776 83 Linux Command (m for help): d Selected partition 1 Partition 1 is deleted Command (m for help): p Disk /dev/sdb: 64.4 GB, 64424509440 bytes, 125829120 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: 0xfb9f9341 Device Boot Start End Blocks Id System Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. |
5.使用fdisk重新建立分区
新分区的起始位置必须和旧分区的起始位置相同,结束位置必须大于旧分区的结束位置,否则会导致扩容失败。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
[root@system ~]# <strong>fdisk -u /dev/sdb</strong> 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): <strong>p</strong> Disk /dev/sdb: 64.4 GB, 64424509440 bytes, 125829120 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: 0xfb9f9341 Device Boot Start End Blocks Id System Command (m for help): <strong>n</strong> Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): Using default response <strong>p</strong> Partition number (1-4, default 1): First sector (2048-125829119, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-125829119, default 125829119): Using default value 125829119 Partition 1 of type Linux and of size 60 GiB is set Command (m for help): <strong>p</strong> Disk /dev/sdb: 64.4 GB, 64424509440 bytes, 125829120 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: 0xfb9f9341 Device Boot Start End Blocks Id System /dev/sdb1 2048 125829119 62913536 83 Linux Command (m for help): <strong>w</strong> The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. |
6.检查分区扩容结果
1 2 3 4 5 6 7 8 9 |
[root@system ~]# <strong>lsblk /dev/sdb</strong> NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 0 60G 0 disk └─sdb1 8:17 0 60G 0 part [root@system ~]# e2fsck -n /dev/sdb sdb sdb1 [root@system ~]# <strong>e2fsck -n /dev/sdb1</strong> e2fsck 1.42.9 (28-Dec-2013) /dev/sdb1: clean, 52988/3276800 files, 4879296/13106944 blocks |
7.通知内核更新分区表并扩容文件系统
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@system ~]# <strong>partprobe /dev/sdb1</strong> [root@system ~]# <strong>e2fsck -f /dev/sdb1</strong> e2fsck 1.42.9 (28-Dec-2013) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity /lost+found not found. Create<y>? <strong>yes</strong> #由于这个磁盘之前是使用的,lost+found不存在,所以会有这个提示,输入yes创建即可 Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/sdb1: ***** FILE SYSTEM WAS MODIFIED ***** /dev/sdb1: 52989/3276800 files (0.1% non-contiguous), 4879297/13106944 blocks [root@system ~]# <strong>resize2fs /dev/sdb1</strong> resize2fs 1.42.9 (28-Dec-2013) Resizing the filesystem on /dev/sdb1 to 15728384 (4k) blocks. The filesystem on /dev/sdb1 is now 15728384 blocks long. |
8.使用mount挂载
1 2 3 4 5 6 7 8 9 10 |
mount /dev/sdb1 /opt/ [root@system ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 38G 3.6G 35G 10% / devtmpfs 7.8G 0 7.8G 0% /dev tmpfs 7.8G 0 7.8G 0% /dev/shm tmpfs 7.8G 8.9M 7.8G 1% /run tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup tmpfs 1.6G 0 1.6G 0% /run/user/0 <strong>/dev/sdb1 59G 18G 39G 32% /opt</strong> |
至此,Exsi为linux主机扩容磁盘空间并扩展分区完成,如有问题欢迎下方留言