最近想给Debian10增加一块硬盘,于是少废话,搞起来!
1、先查看下硬盘情况
$sudo fdisk -l
Disk /dev/sda: 30 GiB, 32212254720 bytes, 62914560 sectors
Disk model: Virtual disk
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: 0xae2e1146
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 60913663 60911616 29G 83 Linux
/dev/sda2 60915710 62912511 1996802 975M 5 Extended
/dev/sda5 60915712 62912511 1996800 975M 82 Linux swap / Solaris
Disk /dev/sdb: 5 TiB, 5497558138880 bytes, 10737418240 sectors
Disk model: Virtual disk
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: 0x796541ea
2、给硬盘分区,并转分区表
$ sudo fdisk /dev/sdb
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.
The size of this disk is 5 TiB (5497558138880 bytes). DOS partition table format cannot be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).
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 verify the partition table
i print information about a partition
Misc
m print this menu
u change display/entry units
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
Command (m for help): p #创建主分区
Disk /dev/sdb: 5 TiB, 5497558138880 bytes, 10737418240 sectors
Disk model: Virtual disk
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: 0x796541ea
Command (m for help): g #转换分区表,MBRGPT支持大于2T的分区
Created a new GPT disklabel (GUID: 33373C9B-CB3D-BC4E-9AC4-4B8BC29501B7).
The old dos signature will be removed by a write command.
Command (m for help): p
Disk /dev/sdb: 5 TiB, 5497558138880 bytes, 10737418240 sectors
Disk model: Virtual disk
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: gpt #提示转换成功
Disk identifier: 33373C9B-CB3D-BC4E-9AC4-4B8BC29501B7
Command (m for help): n #创建分区,这里把5T做一个分区
Partition number (1-128, default 1):
First sector (2048-10737418206, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-10737418206, default 10737418206):
Created a new partition 1 of type ‘Linux filesystem’ and of size 5 TiB.
Command (m for help): p
Disk /dev/sdb: 5 TiB, 5497558138880 bytes, 10737418240 sectors
Disk model: Virtual disk
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: gpt
Disk identifier: 33373C9B-CB3D-BC4E-9AC4-4B8BC29501B7
Device Start End Sectors Size Type
/dev/sdb1 2048 10737418206 10737416159 5T Linux filesystem
Command (m for help): w #保存操作
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
song@debian:~$ sudo fdisk -l #查看磁盘列表
Disk /dev/sda: 30 GiB, 32212254720 bytes, 62914560 sectors
Disk model: Virtual disk
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: 0xae2e1146
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 60913663 60911616 29G 83 Linux
/dev/sda2 60915710 62912511 1996802 975M 5 Extended
/dev/sda5 60915712 62912511 1996800 975M 82 Linux swap / Solaris
Disk /dev/sdb: 5 TiB, 5497558138880 bytes, 10737418240 sectors #创建成功
Disk model: Virtual disk
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: gpt
Disk identifier: 33373C9B-CB3D-BC4E-9AC4-4B8BC29501B7
Device Start End Sectors Size Type
/dev/sdb1 2048 10737418206 10737416159 5T Linux filesystem
三、挂载分区
1、手动挂载分区,可以使用mount命令手动挂载磁盘分区。手动卸载分区的命令是umount。
$sudo mount /dev/sdb1 /Move
2、自动挂载
编辑 /etc/fstab 配置文件,在最后一行添加
/dev/sdb1 /Move ext4 defaults 0 0
:w保存退出,重启系统即可自动挂载硬盘!
(完)