在阿里云上对ECS购买好新的磁盘后,需要挂载新磁盘到系统;
运行命令:
fdisk -l
结果:
Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 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: 0x0008de3e
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 209713151 104855552 83 Linux
Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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
从上述结果中可以看出,目前已经有磁盘vda在使用,磁盘vdb还未使用,我们需要挂载vdb磁盘到系统;
对vdb磁盘进行分区,默认只分成1个区
执行命令:
fdisk /dev/vdb
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.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x41b1ce82.
Command (m for help): m #查看fdisk命令帮助
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n #新增加分区
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p #选择p,增加主分区
Partition number (1-4, default 1): 1 #输入分区编号,1~4范围
First sector (2048-209715199, default 2048): #输入起始sector,使用默认值直接enter
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): #输入结束sector,使用默认值直接enter,这样整个磁盘就分为了1个区
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set
Command (m for help): p #查看现在的分区情况
Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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: 0x41b1ce82
Device Boot Start End Blocks Id System
/dev/vdb1 2048 209715199 104856576 83 Linux #这里可以看到已经分出了vdb1区
Command (m for help): w #输入w,保存上述操作,如不需保存,则如q直接退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
输入如下命令,把分区vdb1格式化为ext4格式
mkfs.ext4 /dev/vdb1
结果:
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214144 blocks
1310707 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
使用mount命令,把vdb1分区挂载到 /mnt 目录
mount /dev/vdb1 /mnt
vi /etc/fstab
输入如下分区信息
/dev/vdb1 /mnt ext4 defaults 0 0
保存并退出