ubuntu磁盘挂载以及开机自动挂载

  • 系统: Ubuntu 18.04
  • 磁盘: 240GB nvme ssd

1. 磁盘挂载

  1. 使用命令查看分区:

sudo fdisk -l

root@ubuntu:~/workspace# fdisk -l

Disk /dev/ram0: 4 MiB, 4194304 bytes, 8192 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/nvme0n1: 238.5 GiB, 256060514304 bytes, 500118192 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

Disk /dev/mmcblk0: 14.6 GiB, 15634268160 bytes, 30535680 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: C0590000-0000-4526-8000-7D9200003A8E

Device          Start      End  Sectors  Size Type
/dev/mmcblk0p1  16384    24575     8192    4M unknown
/dev/mmcblk0p2  24576    32767     8192    4M unknown
/dev/mmcblk0p3  40960   106495    65536   32M unknown
/dev/mmcblk0p4 172032   237567    65536   32M unknown
/dev/mmcblk0p5 368640 30535646 30167007 14.4G unknown

Disk /dev/mmcblk0boot1: 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

Disk /dev/mmcblk0boot0: 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

Disk /dev/mmcblk2: 14.9 GiB, 16009658368 bytes, 31268864 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: 0xcc70ab66

Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk2p1 *     2048 31268863 31266816 14.9G  7 HPFS/NTFS/exFAT

  • 可以根据上面提供的磁盘信息确定想挂载的磁盘。本次目的是将 /dev/nvme0n1 磁盘挂载到 /ssd 目录上
  1. 创建挂载目录

sudo mkdir /ssd

  1. 挂载

mount /dev/nvme0n1 /ssd

  1. 查看:

sudo df -h

root@ubuntu:~# df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/root        15G  4.7G  9.1G  35% /
devtmpfs        1.9G     0  1.9G   0% /dev
tmpfs           1.9G   22M  1.9G   2% /dev/shm
tmpfs           1.9G   17M  1.9G   1% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
tmpfs           385M   16K  385M   1% /run/user/1000
/dev/mmcblk2p1   15G  2.9G   13G  19% /media/ubuntu/7E1EC0F91EC0AC091
/dev/nvme0n1    234G   17G  206G   8% /ssd

2. 设置开机自动挂载

  1. 查询目标磁盘UUID

sudo bljid /dev/nvme0n1

root@ubuntu:~# blkid /dev/nvme0n1
/dev/nvme0n1: UUID="8a1f77a3-6f4f-476b-9ac7-13f4299ed7ca" TYPE="ext4"
  1. 修改系统配置文件:

sudo vim /etc/fstab

root@ubuntu:~# vim /etc/fstab


# UNCONFIGURED FSTAB FOR BASE SYSTEM
UUID=8a1f77a3-6f4f-476b-9ac7-13f4299ed7ca /ssd ext4 0 2

格式为: [UUID=**********************] [挂载磁盘分区] [挂载磁盘格式] 0 2

  • 第一个数字 : 0表示开机不检查磁盘,1表示开机检查磁盘。
  • 第二个数字 : 0表示交换分区,1表示启动分区(linux),2表示普通分区

这里挂载的是ext4格式的磁盘
可以挂载windows系统下创建的分区,格式为ntfs

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页