阿里云和腾讯云挂载磁盘
Linux CentOS 7.2 64位 磁盘挂载教程
阿里云服务器-云磁盘挂载 | 挂载云盘 https://help.aliyun.com/document_detail/25446.html Linux 格式化数据盘 https://help.aliyun.com/document_detail/25426.html |
腾讯云服务器-云磁盘挂载 | Linux 系统分区、格式化、挂载及创建文件系统 https://cloud.tencent.com/document/product/362/6735 |
查看系统版本
[root@iZwz97lpp0wul509ix8zweZ ~]# lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.2.1511 (Core) Release: 7.2.1511 Codename: Core
如果命令 提示 command not found。很显然,lsb_release没有安装。于是安装:
[root@iZwz97lpp0wul509ix8zweZ ~]# yum install redhat-lsb -y
查看一下分区文件系统类型
[root@iZwz97lpp0wul509ix8zweZ ~]# df -T Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/vda1 ext3 41152832 1523112 37532620 4% / devtmpfs devtmpfs 498336 0 498336 0% /dev tmpfs tmpfs 508204 0 508204 0% /dev/shm tmpfs tmpfs 508204 344 507860 1% /run tmpfs tmpfs 508204 0 508204 0% /sys/fs/cgroup tmpfs tmpfs 101644 0 101644 0% /run/user/0
查看home分区所在的硬盘名称
[root@ebs-21232 junjun]# df -vh Filesystem Size Used Avail Use% Mounted on /dev/vda1 29G 1.5G 26G 6% / devtmpfs 2.9G 0 2.9G 0% /dev tmpfs 2.9G 0 2.9G 0% /dev/shm tmpfs 2.9G 8.4M 2.9G 1% /run tmpfs 2.9G 0 2.9G 0% /sys/fs/cgroup /dev/vdb1 69G 53M 66G 1% /home tmpfs 581M 0 581M 0% /run/user/0 [root@ebs-21232 junjun]#
查看本机有几块磁盘
[root@iZwz97lpp0wul509ix8zweZ ~]# fdisk -l Disk /dev/vda: 42.9 GB, 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 Disk label type: dos Disk identifier: 0x0000efd2 Device Boot Start End Blocks Id System /dev/vda1 * 2048 83886079 41942016 83 Linux Disk /dev/vdb: 53.7 GB, 53687091200 bytes, 104857600 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
格式化第二块磁盘,分区格式为ext3
[root@iZwz97lpp0wul509ix8zweZ ~]# mkfs.ext3 /dev/vdb mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 3276800 inodes, 13107200 blocks 655360 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 400 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
将格式化完的磁盘进行硬盘挂载,硬盘挂载前,先在服务器上创建一个需要挂载的挂载点,根目录下创建一个www目录
默认情况下,跳转到根目录的命令为:
[root@iZwz97lpp0wul509ix8zweZ ~]# cd / [root@iZwz97lpp0wul509ix8zweZ /]# ll total 60 lrwxrwxrwx. 1 root root 7 Feb 24 10:58 bin -> usr/bin dr-xr-xr-x. 4 root root 4096 Mar 13 22:00 boot drwxr-xr-x 20 root root 3040 Mar 13 21:59 dev drwxr-xr-x. 82 root root 4096 Mar 14 2017 etc drwxr-xr-x. 2 root root 4096 Aug 12 2015 home lrwxrwxrwx. 1 root root 7 Feb 24 10:58 lib -> usr/lib lrwxrwxrwx. 1 root root 9 Feb 24 10:58 lib64 -> usr/lib64 drwx------. 2 root root 16384 Feb 24 10:58 lost+found drwxr-xr-x. 2 root root 4096 Aug 12 2015 media drwxr-xr-x. 2 root root 4096 Aug 12 2015 mnt drwxr-xr-x. 2 root root 4096 Aug 12 2015 opt dr-xr-xr-x 75 root root 0 Mar 13 21:59 proc dr-xr-x---. 4 root root 4096 Mar 13 22:12 root drwxr-xr-x 21 root root 600 Mar 13 22:00 run lrwxrwxrwx. 1 root root 8 Feb 24 10:58 sbin -> usr/sbin drwxr-xr-x. 2 root root 4096 Aug 12 2015 srv dr-xr-xr-x 13 root root 0 Mar 14 2017 sys drwxrwxrwt. 8 root root 4096 Mar 13 22:00 tmp drwxr-xr-x. 13 root root 4096 Feb 24 10:58 usr drwxr-xr-x. 19 root root 4096 Mar 14 2017 var
创建目录命令为: mkdir /www
[root@iZwz97lpp0wul509ix8zweZ /]# mkdir /www [root@iZwz97lpp0wul509ix8zweZ /]# ll total 64 lrwxrwxrwx. 1 root root 7 Feb 24 10:58 bin -> usr/bin dr-xr-xr-x. 4 root root 4096 Mar 13 22:00 boot drwxr-xr-x 20 root root 3040 Mar 13 21:59 dev drwxr-xr-x. 82 root root 4096 Mar 14 2017 etc drwxr-xr-x. 2 root root 4096 Aug 12 2015 home lrwxrwxrwx. 1 root root 7 Feb 24 10:58 lib -> usr/lib lrwxrwxrwx. 1 root root 9 Feb 24 10:58 lib64 -> usr/lib64 drwx------. 2 root root 16384 Feb 24 10:58 lost+found drwxr-xr-x. 2 root root 4096 Aug 12 2015 media drwxr-xr-x. 2 root root 4096 Aug 12 2015 mnt drwxr-xr-x. 2 root root 4096 Aug 12 2015 opt dr-xr-xr-x 75 root root 0 Mar 13 21:59 proc dr-xr-x---. 4 root root 4096 Mar 13 22:12 root drwxr-xr-x 21 root root 600 Mar 13 22:00 run lrwxrwxrwx. 1 root root 8 Feb 24 10:58 sbin -> usr/sbin drwxr-xr-x. 2 root root 4096 Aug 12 2015 srv dr-xr-xr-x 13 root root 0 Mar 14 2017 sys drwxrwxrwt. 8 root root 4096 Mar 13 22:00 tmp drwxr-xr-x. 13 root root 4096 Feb 24 10:58 usr drwxr-xr-x. 19 root root 4096 Mar 14 2017 var drwxr-xr-x 2 root root 4096 Mar 13 22:13 www
如果硬盘挂载失败,或者是提示这样的内容。
Writing superblocks and filesystem accounting information: done 设置一下你创建的目录权限 chmod -R 777 /www
硬盘挂载到www目录 硬盘挂载命令 mount /dev/vdb /www ,挂载完成后,我们在查看一下挂载状态 df -lh
[root@iZwz97lpp0wul509ix8zweZ ~]# mount /dev/vdb /www [root@iZwz97lpp0wul509ix8zweZ ~]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/vda1 40G 1.5G 36G 4% / devtmpfs 487M 0 487M 0% /dev tmpfs 497M 0 497M 0% /dev/shm tmpfs 497M 308K 496M 1% /run tmpfs 497M 0 497M 0% /sys/fs/cgroup tmpfs 100M 0 100M 0% /run/user/0 /dev/vdb 50G 52M 47G 1% /www
设置开机自动硬盘挂载,重起服务器
[root@iZwz97lpp0wul509ix8zweZ ~]# echo /dev/vdb /www ext3 defaults 0 0 >> /etc/fstab [root@iZwz97lpp0wul509ix8zweZ ~]# init 6 Connection closed by foreign host. Disconnected from remote host(huoniao) at 22:20:16. Type `help' to learn how to use Xshell prompt. [c:\~]$
如果添加自动硬盘挂载,出现这样错误
-bash: /etc/fstab: No such file or directory
需要给语句添加一下单引号,在执行即可
echo '/dev/vdb /www ext3 defaults 0 0' >> /etc/fstab
重起服务器后,查看一下服务器硬盘挂载状态
[root@iZwz97lpp0wul509ix8zweZ ~]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/vda1 40G 1.5G 36G 4% / devtmpfs 487M 0 487M 0% /dev tmpfs 497M 0 497M 0% /dev/shm tmpfs 497M 320K 496M 1% /run tmpfs 497M 0 497M 0% /sys/fs/cgroup /dev/vdb 50G 52M 47G 1% /www tmpfs 100M 0 100M 0% /run/user/0
教程结束
备注:升级到7.5 、7.6语句
yum update --release=7.5.1804
yum update --release=7.6.1810