一、查看设备
1、列出系统上的所有块设备: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中还有剩余的空间未被分区。
2、打开需要进行分区的磁盘进行分区操作: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 # 列出空闲的未分区的空间
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
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