目录
格式化硬盘
将磁盘接到机器上,进入dev目录,查看连接的磁盘是否被系统识别,比如以下的的sda是接入小机的TF卡,是我们要挂载在系统上的存储设备。
dolphin@localhost:~/work$ cd /dev
dolphin@localhost:/dev$ ll
total 4
crw------- 1 root root 5, 1 Oct 26 02:25 console
crw------- 1 root root 10, 62 Jan 28 2018 cpu_dma_latency
brw-rw---- 1 root disk 179, 0 Jan 28 2018 mmcblk1
brw-rw---- 1 root disk 8, 0 Jan 28 2018 sda
crw-rw-rw- 1 root root 1, 5 Jan 28 2018 zero
通过mkfs命令将磁盘格式化,如下指令将其格式化成了ext4格式,格式化后会生成新的UUID,这个UUID在后续的挂载操作中也会用到。
dolphin@localhost:~$ sudo mkfs -t ext4 /dev/sda
mke2fs 1.44.1 (24-Mar-2018)
Found a gpt partition table in /dev/sda
Proceed anyway? (y,N) y
Creating filesystem with 980224 4k blocks and 245280 inodes
Filesystem UUID: b6f4aa37-6bf5-4c78-a1e7-c8ce64507196
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
如果是要在磁盘下创建新的分区,比如树莓派在烧录镜像后有多余的空间,可以用以下方法:
sudo fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 sector