伺服器雲盤挂載
由于需要存儲大量資料,怕原先的磁盤容量不夠,又新買的了一塊200G的磁盤,記錄下雲盤挂載操作
備份
這個步驟不可少,萬一挂載失敗還可以回撤,阿裡雲伺服器可以建立快照
阿裡雲盤快照
資料庫備份,還有網站備份,直接下載下傳下來備份檔案
開始
- 檢查網站的磁盤狀态,确認是否有沒有分區的磁盤。 使用 fdisk -l 檢視磁盤資訊
磁盤容量
發現有磁盤,路徑為/dev/sdb。然後使用fdisk指令進行建立分區
[root@localhost ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.32.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 0x44a58d0f.
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):
First sector (2048-419430399, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-419430399, default 419430399):
Created a new partition 1 of type 'Linux' and of size 200 GiB.
Command (m for help): wq
Syncing disks.
一直回車最後一步輸入wq儲存即可
- 檢查是否分區成功 使用fdisk -l指令檢視,已經有分區了
[root@localhost ~]# 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: 0xea870d90
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 83886046 83883999 40G 83 Linux
Disk /dev/vdb: 200 GiB, 214748364800 bytes, 419430400 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: 0x44a58d0f
Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 419430399 419428352 200G 83 Linux
- 建好分區後要格式化分區,建立檔案系統
[root@localhost ~]# mkfs.ext4 /dev/vdb1
- 分區挂載添加到開啟動,就完成了操作。這樣檔案系統就建好了,然後選擇一個挂載點挂上就可以了,我挂載在/www/data 下了,這個可以按照你的需求去挂載
[root@localhost ~]# cd /www
[root@localhost ~]# mkdir data
[root@localhost ~]# echo "/dev/vdb1 /www/data ext4 defaults 0 0" >> /etc/fstab
- 重新挂載所有分區使用這個指令。mount -a
[root@localhost ~]# mount -a
或者單獨挂載一個
[root@localhost ~]# mount /dev/vdb /www/data
- 最後确認檢查磁盤是否挂載成功,使用DF指令檢視。
[root@localhost www]# df -l
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 3812180 0 3812180 0% /dev
tmpfs 3830572 8 3830564 1% /dev/shm
tmpfs 3830572 508 3830064 1% /run
tmpfs 3830572 0 3830572 0% /sys/fs/cgroup
/dev/vda1 41103804 11699596 27500500 30% /
tmpfs 766112 0 766112 0% /run/user/0
/dev/vdb1 205313000 28 194810880 1% /www/data
可以看到新的存儲盤/dev/vdb1已經挂載到了/www/data上面了。
###開機啟動挂載
# blkid
/dev/vda1: UUID="072bc37c-xxxx-xxxx-xxxx-dbd8b6d2fc0d" TYPE="ext4"
/dev/vdb: UUID="29f2c03f-xxxx-xxxx-xxxx-2a42120b4757" TYPE="ext4"
設定開機mount
vim /etc/fstab
UUID=29f2c03f-xxxx-xxxx-xxxx-2a42120b4757 /u01 ext4 defaults 1 1
結束:重新開機看下挂載正常