[root@10-0-18-185 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 8:0 0 60G 0 disk
└─vda1 8:1 0 60G 0 part /
sr0 11:0 1 1024M 0 rom
sda 253:0 0 100G 0 disk
└─sda1 253:1 0 60G 0 part /data
使用fdisk
/dev/sda命令重建分区。
Note: 新建分区的起始sector需与原磁盘保持一致,否则可能造成数据丢失。
[root@10-0-18-185 ~]# 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): d #删除现有分区
Selected partition 1
Partition 1 is deleted
Command (m for help): n #新建分区
Partition type: #选择新分区类型为主分区
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1): #选择新分区Partition number为1
First sector (2048-209715199, default 2048): #设置新分区起始sector,需与原磁盘保持一致,否则可能造成数据丢失。
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): #使用默认值作为新分区结束sector,将全部磁盘空间分配给新分区
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set
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.
[root@10-0-18-185 ~]# resize2fs /dev/sda1
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/sda1 to 26214144 (4k) blocks.
The filesystem on /dev/sda1 is now 26214144 blocks long.
使用lsblk命令查看当前分区容量。
[root@10-0-18-185 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
└─sda1 8:1 0 100G 0 part /data
sr0 11:0 1 1024M 0 rom
vda 253:0 0 60G 0 disk
└─vda1 253:1 0 60G 0 part /
[root@10-0-44-210 ~]# fdisk /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): d #删除现有分区
Selected partition 1
Partition 1 is deleted
Command (m for help): n #新建分区
Partition type: #选择新分区类型为主分区
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1): #选择新分区Partition number为1
First sector (2048-209715199, default 2048): #设置新分区起始sector,需与原磁盘保持一致,否则可能造成数据丢失。
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): #使用默认值作为新分区结束sector,将全部磁盘空间分配给新分区
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set
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.