开机自动挂载硬盘 (ubuntu16)
查看版本信息 cat /proc/version
Linux version 4.4.0-187-generic (buildd@lgw01-amd64-035) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12) ) #217-Ubuntu SMP Tue Jul 21 04:18:15 UTC 2020
查看内核 uname -a
Linux iZwz98t6hadahwoz1clfz4Z 4.4.0-187-generic #217-Ubuntu SMP Tue Jul 21 04:18:15 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
查询硬盘ID sudo blkid
/dev/vda1: LABEL="/" UUID="1af205e1-994e-48cf-9eaf-f709a9fa452b" TYPE="ext4" PARTUUID="e35474f5-01"
只有一个硬盘信息
查询硬盘信息 fdisk -l | grep Disk
Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectors
Disklabel type: dos
Disk identifier: 0xe35474f5
Disk /dev/vdb: 100 GiB, 107374182400 bytes, 209715200 sectors
格式化需要挂载的盘 /dev/vdb mkfs.ext4 /dev/vdb
root@iZwz98t6hadahwoz1clfz4Z:/# mkfs.ext4 /dev/vdb
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 26214400 4k blocks and 6553600 inodes
Filesystem UUID: 38fecdb0-bbb7-460c-85f7-6cc145ce8b17
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
查询uid
root@iZwz98t6hadahwoz1clfz4Z:/# sudo blkid
/dev/vda1: LABEL="/" UUID="1af205e1-994e-48cf-9eaf-f709a9fa452b" TYPE="ext4" PARTUUID="e35474f5-01"
/dev/vdb: UUID="38fecdb0-bbb7-460c-85f7-6cc145ce8b17" TYPE="ext4"
创建挂载目录
mkdir work
挂载开机启动
vim /etc/fstab
# /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/vda1 during installation
UUID=1af205e1-994e-48cf-9eaf-f709a9fa452b / ext4 errors=remount-ro 0 1
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
/dev/vdb /home/work ext4 defaults 0 0
# /dev/vdb /home/work ext4 defaults 0 0 为新增行
查看
root@iZwz98t6hadahwoz1clfz4Z:/home# df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 8196216 0 8196216 0% /dev
tmpfs 1643224 3260 1639964 1% /run
/dev/vda1 41152812 2161428 37087728 6% /
tmpfs 8216108 0 8216108 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 8216108 0 8216108 0% /sys/fs/cgroup
tmpfs 1643224 0 1643224 0% /run/user/0
执行 mount -a
root@iZwz98t6hadahwoz1clfz4Z:/home# df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 8196216 0 8196216 0% /dev
tmpfs 1643224 3260 1639964 1% /run
/dev/vda1 41152812 2161432 37087724 6% /
tmpfs 8216108 0 8216108 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 8216108 0 8216108 0% /sys/fs/cgroup
tmpfs 1643224 0 1643224 0% /run/user/0
/dev/vdb 103081248 61044 97760940 1% /home/work //新挂载上的
重启服务即可
网友评论