今天学校有一台机器发现有块硬盘没有挂载,然后叫我挂载一下,这里记录一下 Linux 下新增硬盘分区、格式化硬盘、挂载硬盘的操作。
查看当前硬盘
首先我们查看一下当前的硬盘配置。使用命令
sudo fdisk -l
就可以看到目前的硬盘了。可以看到有块空的 sda(这里忘了复制输出了,大家可以看到自己的硬盘就对了)。
新增硬盘,新建分区
下面我们将使用 fdisk 命令来创建新的分区。首先进入我们需要操作的硬盘:
$ sudo fdisk /dev/sda
sudo: unable to resolve host csc-server-0-2
Welcome to fdisk (util-linux 2.27.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.
The size of this disk is 7.3 TiB (7999376588800 bytes). DOS partition table format can not be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).
Created a new DOS disklabel with disk identifier 0xcb6595dd.
然后我们可以输入 m 来查看一下帮助信息。
Command (m for help): m
Help:
DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v