ubuntu磁盤分區(qū)、格式化、掛載方式
更新時間:2026年02月09日 08:50:31 作者:立昂
文章介紹了如何查看設備、進行分區(qū)、格式化和掛載磁盤的步驟,以及可能遇到的問題和解決方案
一、查看設備
1、列出系統(tǒng)上的所有塊設備: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、打開需要進行分區(qū)的磁盤進行分區(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 # 增加一個新的分區(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、掛載可能會遇到的格式問題
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
開機掛載
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
總結
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Apache Shiro 使用手冊(五) Shiro 配置說明
這篇文章主要為大家分享了Apache Shiro 配置說明,需要的朋友可以參考下2014-06-06
在Apache服務器上啟用GZip壓縮靜態(tài)內容的方法
這篇文章主要介紹了在Apache服務器上啟用GZip壓縮靜態(tài)內容的方法,通過配置.htaccess文件即可輕松實現(xiàn),同時附帶了一些GZip的常用命令,需要的朋友可以參考下2015-08-08
Linux進程排查實戰(zhàn)之strace和lsof命令使用指南
這篇文章主要為大家詳細介紹了Linux進程排查實戰(zhàn)之strace和lsof命令使用的相關方法,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下2025-12-12
Linux下使用使用socket實現(xiàn)TCP服務端的示例代碼
套接字(socket)是 Linux 下的一種進程間通信機制(socket IPC),它不僅支持同一主機的不同進程間通信,還支持跨網(wǎng)絡的不同主機的進程間通信,本文介紹了 Linux 下使用 socket 接口實現(xiàn) TCP 服務端的示例程序,需要的朋友可以參考下2024-03-03

