linux添加硬盘的命令 linux新添加硬盘( 二 )


Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3b1ffeba
DeviceBootStartEndSectorsSize Id Type
#分区序列 | 引导 | 开始 | 终止 | Sectors | 容量 | 分区类型ID | 分区类型
/dev/sda1*2048314777531457281.5G 83 Linux
/dev/sda23147776 138412031 135264256 64.5G5 Extended
/dev/sda3138412032 1614807032306867211G 83 Linux
/dev/sda4161480704 16777011162894083G 82 Linux swap / Solaris
/dev/sda53149824346050553145523215G 83 Linux
/dev/sda634607104660623353145523215G 83 Linux
/dev/sda766064384 13841203172347648 34.5G 83 Linux
Partition table entries are not in disk order.
a. 在虚拟机中添加硬盘,添加后使用fdisk -l命令查看,磁盘变成两个,在sda中还没有分区
root@zfy-PC:/home/zfy# fdisk -l
Disk /dev/sda: 2 GiB, 2147483648 bytes, 4194304 sectors
Disk model: VMware Virtual S
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 /dev/sdb: 80 GiB, 85899345920 bytes, 167772160 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3b1ffeba
DeviceBootStartEndSectorsSize Id Type
/dev/sdb1*2048314777531457281.5G 83 Linux
/dev/sdb23147776 138412031 135264256 64.5G5 Extended
/dev/sdb3138412032 1614807032306867211G 83 Linux
/dev/sdb4161480704 16777011162894083G 82 Linux swap / Solaris
/dev/sdb53149824346050553145523215G 83 Linux
/dev/sdb634607104660623353145523215G 83 Linux
/dev/sdb766064384 13841203172347648 34.5G 83 Linux
Partition table entries are not in disk order.
b.下面对sda进行分区
root@zfy-PC:/home/zfy# fdisk /dev/sda
Welcome to fdisk (util-linux 2.33.1).
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.
Created a new DOS disklabel with disk identifier 0xb985e226.
Command (m for help): m
#输入m查看帮助
Help:
DOS (MBR)
atoggle a bootable flag
bedit nested BSD disklabel
ctoggle the dos compatibility flag
Generic
ddelete a partition
Flist free unpartitioned space
llist known partition types
nadd a new partition
pprint the partition table
tchange a partition type
vverify the partition table
iprint information about a partition
Misc
mprint this menu
uchange display/entry units
xextra functionality (experts only)
Script
Iload disk layout from sfdisk script file
Odump disk layout to sfdisk script file
SaveExit
wwrite table to disk and exit
qquit without saving changes
Create a new label
gcreate a new empty GPT partition table
Gcreate a new empty SGI (IRIX) partition table
ocreate a new empty DOS partition table
screate a new empty Sun partition table
Command (m for help): n
#输入n创建一个分区
Partition type
pprimary (0 primary, 0 extended, 4 free)
eextended (container for logical partitions)
Select (default p): p
#选择主分区
Partition number (1-4, default 1): 1
#选择编号为1
First sector (2048-4194303, default 2048): 2500000
#起始sector 设为2500000
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2500000-4194303, default 4194303): 4194303
#终止sector 设为4194303
Created a new partition 1 of type 'Linux' and of size 827.3 MiB.

推荐阅读