ubuntu磁盤分區(qū)、格式化、掛載方式
更新時(shí)間:2026年02月09日 08:50:31 作者:立昂
文章介紹了如何查看設(shè)備、進(jìn)行分區(qū)、格式化和掛載磁盤的步驟,以及可能遇到的問題和解決方案
一、查看設(shè)備
1、列出系統(tǒng)上的所有塊設(shè)備:sudo fdisk -l
xxx@xxx:~$ sudo fdisk -l Disk /dev/ram0: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram1: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram2: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram3: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram4: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram5: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram6: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram7: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram8: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram9: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram10: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram11: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram12: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram13: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram14: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/ram15: 8 MiB, 8388608 bytes, 16384 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 Disk /dev/loop0: 16 MiB, 16777216 bytes, 32768 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: 0x00000000 Disk /dev/mtdblock0: 4 MiB, 4194304 bytes, 8192 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 GPT PMBR size mismatch (26769407 != 244023295) will be corrected by w(rite). Disk /dev/mmcblk0: 116.4 GiB, 124939927552 bytes, 244023296 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: gpt Disk identifier: 2D215E13-695C-4DAB-B877-B01320240ACB Device Start End Sectors Size Type /dev/mmcblk0p1 28672 61067263 61038592 29.1G Linux filesystem /dev/mmcblk0p2 2048 2303 256 128K Linux filesystem /dev/mmcblk0p3 4096 4991 896 448K Linux filesystem /dev/mmcblk0p4 6144 7295 1152 576K Linux filesystem /dev/mmcblk0p5 8192 8319 128 64K Linux filesystem /dev/mmcblk0p6 10240 10623 384 192K Linux filesystem /dev/mmcblk0p7 12288 13055 768 384K Linux filesystem /dev/mmcblk0p8 14336 14463 128 64K Linux filesystem /dev/mmcblk0p9 16384 17279 896 448K Linux filesystem /dev/mmcblk0p10 18432 19327 896 448K Linux filesystem /dev/mmcblk0p11 20480 22015 1536 768K Linux filesystem /dev/mmcblk0p12 22528 22655 128 64K Linux filesystem /dev/mmcblk0p13 24576 24959 384 192K Linux filesystem /dev/mmcblk0p14 26624 26879 256 128K Linux filesystem Partition table entries are not in disk order. Disk /dev/zram0: 2 GiB, 2078359552 bytes, 507412 sectors Units: sectors of 1 * 4096 = 4096 bytes Sector size (logical/physical): 4096 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/zram1: 2 GiB, 2078359552 bytes, 507412 sectors Units: sectors of 1 * 4096 = 4096 bytes Sector size (logical/physical): 4096 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/zram2: 2 GiB, 2078359552 bytes, 507412 sectors Units: sectors of 1 * 4096 = 4096 bytes Sector size (logical/physical): 4096 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/zram3: 2 GiB, 2078359552 bytes, 507412 sectors Units: sectors of 1 * 4096 = 4096 bytes Sector size (logical/physical): 4096 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes
可以看到磁盤/dev/mmcblk0中還有剩余的空間未被分區(qū)。
2、打開需要進(jìn)行分區(qū)的磁盤進(jìn)行分區(qū)操作:sudo fdisk /dev/sdX
xxx@xxx:~$ sudo fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
GPT PMBR size mismatch (26769407 != 244023295) will be corrected by w(rite).
GPT PMBR size mismatch (26769407 != 244023295) will be corrected by w(rite).
Command (m for help): e
e: unknown command
Command (m for help): m
Help:
Generic
d delete a partition
F list free unpartitioned space # 列出空閑的未分區(qū)的空間
l list known partition types
n add a new partition # 增加一個(gè)新的分區(qū)
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
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): F
Unpartitioned space /dev/mmcblk0: 87.2 GiB, 93673471488 bytes, 182955999 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Start End Sectors Size
61067264 244023262 182955999 87.2G
Command (m for help): n
Partition number (15-128, default 15): 15
First sector (61067264-244023262, default 61067264):
Last sector, +sectors or +size{K,M,G,T,P} (61067264-244023262, default 244023262):
Created a new partition 15 of type 'Linux filesystem' and of size 87.2 GiB.
Command (m for help): F
Unpartitioned space /dev/mmcblk0: 0 B, 0 bytes, 0 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Command (m for help): w
GPT PMBR size mismatch (26769407 != 244023295) will be corrected by w(rite).
The partition table has been altered.
Syncing disks.
二、格式化
1、掛載可能會(huì)遇到的格式問題
xxx@jxxx:~$ sudo mount /dev/mmcblk0p15 /home/xxx/node NTFS signature is missing. Failed to mount '/dev/mmcblk0p15': Invalid argument The device '/dev/mmcblk0p15' doesn't seem to have a valid NTFS. Maybe the wrong device is used? Or the whole disk instead of a partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around? xxx@jxxx:~$ sudo fdisk -l /dev/mmcblk0p15 Disk /dev/mmcblk0p15: 87.2 GiB, 93673471488 bytes, 182955999 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
2、格式化
xxx@jxxx:~$
xxx@jxxx:~$
xxx@jxxx:~$ sudo mkfs.ntfs /dev/mmcblk0p15
Cluster size has been automatically set to 4096 bytes.
Initializing device with zeroes: 26%
61%
100% - Done.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
三、掛載
xxx@xxx:~$ sudo mount /dev/mmcblk0p15 /home/xxx/node
開機(jī)掛載
xxx@xxx:~$ sudo vim /etc/fstab # <file system> <mount point> <type> <options> <dump> <pass> /dev/root / ext4 defaults 0 1 /dev/mmcblk0p15 /home/rushi/node ntfs defaults 0 0
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Linux定時(shí)任務(wù)Crontab命令使用詳解與總結(jié)
本為大家介紹了Linux定時(shí)任務(wù)Crontab命令使用詳解并總結(jié)Crontab命令的一些使用技巧以及工作中遇到的一些問題解決方法2018-10-10
Linux中的內(nèi)核態(tài)&用戶態(tài)使用
本文詳細(xì)介紹了Linux系統(tǒng)內(nèi)核態(tài)與用戶態(tài)的概念、區(qū)別及實(shí)現(xiàn)原理,包括特權(quán)級(jí)、地址空間劃分、系統(tǒng)調(diào)用機(jī)制、頁(yè)表結(jié)構(gòu)等核心內(nèi)容,文章通過對(duì)比用戶態(tài)與內(nèi)核態(tài)的特征,以及具體的操作系統(tǒng)實(shí)現(xiàn)細(xì)節(jié),幫助讀者理解Linux系統(tǒng)中這兩個(gè)重要概念的運(yùn)行機(jī)制和實(shí)際應(yīng)用2026-01-01
Linux系統(tǒng)非正常關(guān)機(jī)導(dǎo)致磁盤異常的問題及解決
文章介紹了在VMware ESXi虛擬化環(huán)境中,由于斷電導(dǎo)致的Linux系統(tǒng)非正常關(guān)機(jī)和磁盤異常問題及其解決方案,主要問題包括文件系統(tǒng)損壞和報(bào)錯(cuò)信息,解決方案涉及檢查和修復(fù)`/etc/fstab`文件中的語(yǔ)法錯(cuò)誤,并使用`dmsetup`命令恢復(fù)設(shè)備映射2025-11-11
linux系統(tǒng)磁盤存儲(chǔ)擴(kuò)容根目錄邏輯卷擴(kuò)容詳解
文章詳細(xì)介紹了如何將新增磁盤增加到Linux根目錄,包括區(qū)分邏輯卷和物理卷、查看新增磁盤信息、對(duì)新磁盤進(jìn)行分區(qū)和格式化、創(chuàng)建物理卷、擴(kuò)展卷組、擴(kuò)展邏輯卷、擴(kuò)展文件系統(tǒng)以及查看擴(kuò)容效果2026-01-01
淺談RHEL 7中systemctl 的用法(替代service和chkconfig)
下面小編就為大家?guī)?lái)一篇淺談RHEL 7中systemctl 的用法(替代service和chkconfig)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧2016-11-11

