当前位置: 代码网 > 科技>电脑产品>硬盘 > ubuntu磁盘分区、格式化、挂载方式

ubuntu磁盘分区、格式化、挂载方式

2026年02月09日 硬盘 我要评论
一、查看设备1、列出系统上的所有块设备:sudo fdisk -lxxx@xxx:~$ sudo fdisk -ldisk /dev/ram0: 8 mib, 8388608 bytes, 16384

一、查看设备

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

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2026  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com