系统相关
首页 > 系统相关> > ubuntu服务器挂载硬盘过程详解

ubuntu服务器挂载硬盘过程详解

作者:互联网

服务器硬盘做了read,但装完系统没有分盘挂载,因此不能使用。
1、硬盘分区
首先查看机器所有的硬盘状态sudo fdisk -l,结果如下:

Disk /dev/sda: 893.3 GiB, 959119884288 bytes, 1873281024 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 9C433BFE-CBF9-4E96-B79C-4DC31470B69F

Device          Start        End    Sectors   Size Type
/dev/sda1        2048    1050623    1048576   512M EFI System
/dev/sda2     1050624 1605627903 1604577280 765.1G Linux filesystem
/dev/sda3  1605627904 1873278975  267651072 127.6G Linux swap

Disk /dev/sdb: 21.8 TiB, 23998129766400 bytes, 46871347200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

可以看到有个/dev/sdb:21.8T的硬盘。

执行 sudo fdisk /dev/sdb按照提示进行硬盘分区:一般分到2T以内(记得w保存分区)。

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.

Command (m for help): n
Partition number (1-128, default 1): 
First sector (3124756478-46871347166, default 15623782400): 
Last sector, +sectors or +size{K,M,G,T,P} (15623782400-46871347166, default 46871347166): q^H1
Last sector, +sectors or +size{K,M,G,T,P} (15623782400-46871347166, default 46871347166): 20000000000

Created a new partition 1 of type 'Linux filesystem' and of size 2 TiB.

Command (m for help):

2、格式化硬盘

sudo mkfs -t ext4 /dev/sdb1

3、挂载
在/home下面创建相关挂载节点并挂载

mkdir data1
sudo mount -t ext4 /dev/sdb1 /home/data1

至此就挂载好了,可用df -l查看挂载情况,不过重启所有的挂载会失效。

若要每次重启不需要重新挂载,还需要进行下面的操作:
在文件 /etc/fstab 中加入配置sudo vim /etc/fstab

/dev/sdb1     /home/data1    ext4     defaults       0  0

标签:sectors,bytes,dev,详解,ubuntu,挂载,512,硬盘,size
来源: https://blog.csdn.net/qq_33206394/article/details/89017459