查看磁盘是否被挂载
$ fdisk -l Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 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: 0xb2ac676a Device Boot Start End Sectors Size Id Type /dev/vda1 * 2048 83886046 83883999 40G 83 Linux
Disk /dev/vdb: 1 TiB, 1099511627776 bytes, 2147483648 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/vdb: 1 TiB` 则为1T的数据盘
查看磁盘使用情况,再此可以看出 1T 的数据盘是否有挂载。
$ df -h Filesystem Size Used Avail Use% Mounted on udev 3.8G 0 3.8G 0% /dev tmpfs 771M 3.2M 768M 1% /run /dev/vda1 40G 4.9G 33G 14% / tmpfs 3.8G 8.0K 3.8G 1% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup tmpfs 771M 0 771M 0% /run/user/0
上面列表中没有出现
/dev/vdb1
,表示没有挂载磁盘分区数据盘
disk /dev/vdb
Welcome to fdisk (util-linux 2.31.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0x7dd962da. Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-2147483647, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-2147483647, default 2147483647): Created a new partition 1 of type 'Linux' and of size 1024 GiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
如上会出现操作界面,执行如下操作即可:
n(提示:无需帮助) p(提示:p为主分区,e为拓展分区) 1(提示:分区起始磁盘数,设置为1即可) 回车(提示:启始位置,默认即可) 回车(提示:结束位置,默认即可) w(提示:退出)
此时 输入:fdisk -l新建分区已经出现
$ fdisk -l Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 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: 0xb2ac676a Device Boot Start End Sectors Size Id Type /dev/vda1 * 2048 83886046 83883999 40G 83 Linux
Disk /dev/vdb: 1 TiB, 1099511627776 bytes, 2147483648 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: 0x7dd962da
Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 2147483647 2147481600 1024G 83 Linux
格式化分区
$ mkfs.ext4 /dev/vdb1
挂载磁盘到文件
$ mkdir /data
$ mount /dev/vdb1 /data
设置启动默认挂载
echo '/dev/vdb1 /data ext4 barrier=0 0 0' >> /etc/fstab
查看是否挂载成功
$ df -h Filesystem Size Used Avail Use% Mounted on udev 3.8G 0 3.8G 0% /dev tmpfs 771M 3.2M 768M 1% /run /dev/vda1 40G 4.9G 33G 14% / tmpfs 3.8G 8.0K 3.8G 1% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup tmpfs 771M 0 771M 0% /run/user/0 /dev/vdb1 1007G 77M 956G 1% /root/ctfdisk
出现
/dev/vdb1
表示挂载成功补充: 修改挂载
$ sudo umount -l /dev/vdb1 #卸载挂载 $ mount /dev/vdb1 /新地址 $ vim /etc/fstab # 删除原来的挂载配置 echo '/dev/vdb1 /新地址 ext4 barrier=0 0 0' >> /etc/fstab
实测
laravel 项目的使用 - 创建软连接
ln -s /usr/chowtfdisk/miniprograms/files/app/public /usr/share/nginx/yunli-test/public/files