Debian系统 如何手动挂载数据盘?
一、查找磁盘,找到磁盘,物理服务器磁盘名一般为/dev/sda、/dev/sdb、/dev/sdc等等依此类推,云主机、vps类一般为vda、vdb、vdc等等依此类推。
执行命令
fdisk -l
如图,找到数据盘为/dev/vdb
二、建立分区
执行命令
fdisk /dev/vdb
具体过程如下
root@debyogile:/home/yogile# fdisk /dev/sdb1 Welcome to fdisk (util-linux 2.33.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. # 删除硬盘原分区 Command (m for help): d Selected partition 1 Partition 1 has been deleted. # 添加硬盘新分区 Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) # 添加分区,默认的分区格式是 primary Select (default p): Using default response p. # 分区号默认 1 Partition number (1-4, default 1): # 指定分区的起始扇区,一般默认 2048 First sector (2048-62668799, default 2048): # 指定分区的终止扇区,一般默认最大值 Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-62668799, default 62668799): Created a new partition 1 of type Linux and of size 29.9 GiB. Partition #1 contains a vfat signature. # 询问删除签名,确认:y Do you want to remove the signature? [Y]es/[N]o: y The signature will be removed by a write command. # 保存修改 Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
三、再查看一下硬盘分区信息
可以看到有一个/dev/vdb1
四、格式化文件系统
执行命令
mkfs.ext4 /dev/vdb1
五、建立要挂载到的目录www
执行命令
mkdir /www
六、挂载数据盘到建立的目录www
执行命令
mount /dev/vdb1 /www
七、查看挂载是否显示
执行命令
df -h
八、添加开机自动挂载
查看磁盘的UUID
blkid/dev/sdb会返回/dev/sdb:UUID="xxxxx-xxxxx-xxxxx" TYPE="xxx"
nano/etc/fstab在尾部追加一行UUID,示例:
UUID=271d48fa-7729-4200-848a-b3dfc61135dd /www ext4 defaults 0 0退出并保存:ctrl+x,然后按y,然后直接enter。
重启以验证是否成功。
rebootdf -h