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

编程入门 行业动态 更新时间:2024-10-04 01:20:07

ubuntu<a href=https://www.elefans.com/category/jswz/34/1769757.html style=磁盘分区、格式化、挂载"/>

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

一、查看设备

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 bytesDisk /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 bytesDisk /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 bytesDisk /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 bytesDisk /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 bytesDisk /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 bytesDisk /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 bytesDisk /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 bytesDisk /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 bytesDisk /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 bytesDisk /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 bytesDisk /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 bytesDisk /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 bytesDisk /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 bytesDisk /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 bytesDisk /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 bytesDisk /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: 0x00000000Disk /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 bytesGPT 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-B01320240ACBDevice          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 filesystemPartition 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 bytesDisk /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 bytesDisk /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 bytesDisk /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/mmcblk0Welcome 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 commandCommand (m for help): mHelp:Genericd   delete a partitionF   list free unpartitioned space  # 列出空闲的未分区的空间l   list known partition typesn   add a new partition  # 增加一个新的分区p   print the partition tablet   change a partition typev   verify the partition tablei   print information about a partitionMiscm   print this menux   extra functionality (experts only)ScriptI   load disk layout from sfdisk script fileO   dump disk layout to sfdisk script fileSave & Exitw   write table to disk and exitq   quit without saving changesCreate a new labelg   create a new empty GPT partition tableG   create a new empty SGI (IRIX) partition tableo   create a new empty DOS partition tables   create a new empty Sun partition tableCommand (m for help): FUnpartitioned space /dev/mmcblk0: 87.2 GiB, 93673471488 bytes, 182955999 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytesStart       End   Sectors  Size
61067264 244023262 182955999 87.2GCommand (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 bytesCommand (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

更多推荐

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

本文发布于:2024-02-28 10:34:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1769518.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:磁盘分区   ubuntu   挂载

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!