我的硬盘是长期接在树莓派上的,这里设置开机自动挂载,避免重启后,读不到硬盘数据
挂载硬盘
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| sudo fdisk -l
mkdir /mnt/h1
sudo mount /dev/sdb1 /mnt/h1
sudo mount -o umask=0002,gid=watchdog,uid=ubuntu /dev/sdb1 /mnt/h1
sudo umount /dev/sdb1
|
自动挂载硬盘
- 查看硬盘UUID
1 2 3 4 5
| sudo blkid
/dev/sda1: LABEL="pi" UUID="3E5F551D2B409931" TYPE="ntfs" PTTYPE="atari"
|
得到UUID为:3E5F551D2B409931
- 开机挂载
/etc/fstab
1 2 3 4
| UUID="3E5F551D2B409931" /mnt/h1 ntfs defaults 0 1
UUID="3E5F551D2B409931" /mnt/h1 ntfs user,rw,umask=0002,uid=ubuntu,gid=watchdog 0 1
|
使用 df
命令查看硬盘挂载情况
1 2 3 4 5 6 7
| ubuntu@ubuntu:~$ df Filesystem 1K-blocks Used Available Use% Mounted on tmpfs 189000 4080 184920 3% /run tmpfs 944992 0 944992 0% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 4096 0 4096 0% /sys/fs/cgroup /dev/sda1 976760828 72838540 903922288 8% /mnt/h1
|
完成