列出硬碟
kirito@kirito:~$ lsblk
name maj:min rm size ro type mountpoint
loop0 7:0 0 89.1m 1 loop /snap/core/8268
nvme0n1 259:0 0 1.9t 0 disk
├─nvme0n1p1 259:1 0 512m 0 part /boot/efi
└─nvme0n1p2 259:2 0 1.9t 0 part /
nvme1n1 259:3 0 1.9t 0 disk
對硬碟進行分割槽
kirito@kirito:~$ sudo fdisk /dev/nvme1n1
按m可獲取幫助。按n新增分割槽,按w保留分割槽
command (m for help): n
partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
select (default p): p
partition number (1-4, default 1): 1
first sector (2048-4000797359, default 2048): +900g
value out of range.
first sector (2048-4000797359, default 2048):
last sector, +sectors or +size (2048-4000797359, default 4000797359): +900g
created a new partition 1 of type 'linux' and of size 900 gib.
command (m for help): n
partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
select (default p): p
partition number (2-4, default 2): 2
first sector (1887438848-4000797359, default 1887438848):
last sector, +sectors or +size (1887438848-4000797359, default 4000797359):
created a new partition 2 of type 'linux' and of size 1007.7 gib.
command (m for help): p
disk /dev/nvme1n1: 1.9 tib, 2048408248320 bytes, 4000797360 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
disklabel type: dos
disk identifier: 0x0b0a7549
device boot start end sectors size id type
/dev/nvme1n1p1 2048 1887438847 1887436800 900g 83 linux
/dev/nvme1n1p2 1887438848 4000797359 2113358512 1007.7g 83 linux
command (m for help): w
the partition table has been altered.
calling ioctl() to re-read partition table.
syncing disks.
結果
kirito@kirito:~$ lsblk
name maj:min rm size ro type mountpoint
loop0 7:0 0 89.1m 1 loop /snap/core/8268
nvme0n1 259:0 0 1.9t 0 disk
├─nvme0n1p1 259:1 0 512m 0 part /boot/efi
└─nvme0n1p2 259:2 0 1.9t 0 part /
nvme1n1 259:3 0 1.9t 0 disk
├─nvme1n1p1 259:6 0 900g 0 part
└─nvme1n1p2 259:7 0 1007.7g 0 part
格式化硬碟
sudo mkfs -t ext4 /dev/nvme1n1
建立目錄
sudo mkdir /sdd_cache
掛載
sudo mount /dev/nvme1n1 /sdd_cache/
開機自動掛載
sudo vim /etc/fstab
新增
/dev/nvme1n1 /sdd_cache auto defaults,nofail,comment=cloudconfig 0 2修改檔案許可權
sudo chown -r usename:usename /sdd_cache/
lsblk
df -h
sudo fdisk -l
linux硬碟分割槽及掛載
由於時間限制,本人僅在centos 8下測試通過,理論上適用於幾乎所有的linux發行版。輸入df h檢視當前系統的硬碟容量使用情況,當前我的伺服器上空間總容量看起來只有20g,然而當輸入lsblk檢視當前系統上所有的磁碟列表時,從輸出結果中可以看出,除了乙個vda的20g的硬碟外還有乙個vdb的6...
Linux新增硬碟分割槽及掛載
1 分割槽 fdisk命令,l 檢視所有分割槽 fdisk dev sdb1 進行分割槽,過程比較簡單,根據提示即可,注意最後要儲存生效 2 格式化 mke2fs命令,mke2fs t ext4 dev sdb1 格式化 dumpe2fs命令,dumpe2fs dev sdb1 檢視分割槽檔案系統 ...
linux 硬碟分割槽及行動硬碟掛載
1.linux 硬碟分割槽 在 linux 中規定,每乙個硬碟裝置最多能有 4 個主分割槽 其中包含擴充套件分割槽 構成,任何乙個擴充套件分割槽都要占用乙個主分割槽號碼,也就是在乙個硬碟中,主分割槽和擴充套件分割槽一共最多是 4 個。對於早期的 dos 和 windows windows 2000 ...