Ubuntu 挂载硬盘
为了获取流畅的体验,我们把 Ubuntu 系统安装在固态硬盘当中,但一般固态硬盘存储空间有限,需要挂载一块机械硬盘用于数据存储。Ubuntu 挂载硬盘的步骤如下:
查看系统硬盘信息
查看当前硬盘使用情况
$ fdisk -l
查看设备挂载的硬盘
$ df -lh
通过上面的两步,我们可以找到未挂载到系统的硬盘设备,这里为 /dev/sdb。
删除待挂载硬盘分区并格式化为 ext4 格式
- 删除 /dev/sdb 分区(可选)
$ fdisk /dev/sdb ...... Command (m for help): d Partition number (1,5-7, default 7): 7 Partition 7 has been deleted. Command (m for help): d ......
- 格式化 /dev/sdb
$ mkfs.ext4 /dev/sdb
- 删除 /dev/sdb 分区(可选)
挂载硬盘
$ mkdir /mnt/data $ mount /dev/sdb /mnt/data $ df -lh
开机启动
在 /etc/fstab 文件中追加:/dev/sdb /mnt/data ext4 defaults 0 0
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/sda5 during installation UUID=deb7c953-8d99-42f1-81e9-f82238a5f214 / ext4 errors=remount-ro 0 1 # /boot/efi was on /dev/sda1 during installation UUID=BDEE-5B21 /boot/efi vfat umask=0077 0 1 /swapfile none swap sw 0 0 /dev/sdb /mnt/data ext4 defaults 0 0