阿里雲ECSLinux系統下掛載磁盤


最近公司服務器老是提示磁盤空間不足,原因是以前的業務負責人開了Tomcat的debug日志並且沒有做日志輪詢,所以日志量非常大。當我做了日志切割輪詢后發現磁盤還是太小才40G,按理外網服務器怎么可能這么低配置,於是登錄阿里雲控制台查看,果然有塊磁盤沒有掛載,便進行了手動掛載:

阿里雲ECS,需要掛載當前的磁盤

具體步驟如下:

1、查看是否已經分配

[root@iZ2ze1tefvghtbgkdur3xfZ /]# fdisk -l

[root@iZ2ze1tefvghtbgkdur3xfZ server]# 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: 0x0009e68a

Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83884031 41940992 83 Linux

Disk /dev/vdb: 64.4 GB, 64424509440 bytes, 125829120 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

 

 

2、發現有磁盤,路徑為/dev/vdb。然后使用fdisk命令進行建立分區

[root@iZ2ze1tefvghtbgkdur3xfZ /]#fdisk /dev/vdb

fdisk命令如下:

 

 

命令(輸入 m 獲取幫助):m

命令操作

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   g   create a new empty GPT partition table

   G   create an IRIX (SGI) partition table

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   q   quit without saving changes

   s   create a new empty Sun disklabel

   t   change a partition's system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit

   x   extra functionality (experts only)

 

 

3、然后先新建分區(我這里因為要存儲大數據庫文件   所以邏輯全部是一個分區)

 

 

命令(輸入 m 獲取幫助):n

Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

Select (default p):

Using default response p

分區號 (1-4,默認 1):

起始 扇區 (2048-3221225471,默認為 2048):

將使用默認值 2048

Last 扇區, +扇區 or +size{K,M,G} (2048-3221225471,默認為 3221225471):

將使用默認值 3221225471

分區 1 已設置為 Linux 類型,大小設為 1.5 TiB

 

 

 

 

 

4、最后保存分區

命令(輸入 m 獲取幫助):w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

正在同步磁盤。

 

5、使用fdisk -l命令查看,已經有分區了

 

磁盤 /dev/vdb:1649.3 GB, 1649267441664 字節,3221225472 個扇區

Units = 扇區 of 1 * 512 = 512 bytes

扇區大小(邏輯/物理):512 字節 / 512 字節

I/O 大小(最小/最佳):512 字節 / 512 字節

磁盤標簽類型:dos

磁盤標識符:0xe0bc0098

 

   設備 Boot      Start         End      Blocks   Id  System

/dev/vdb1            2048  3221225471  1610611712   83  Linux

 

 

 

6、建好分區后要格式化分區,建立文件系統

 
[root@localhost home]# mkfs.ext4 /dev/vdb1

meta-data=/dev/vdb1              isize=256    agcount=4, agsize=100663232 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=0        finobt=0

data     =                       bsize=4096   blocks=402652928, imaxpct=5

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=0

log      =internal log           bsize=4096   blocks=196607, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

 

 

 

7、這樣文件系統就建好了,然后選擇一個掛載點掛上就可以了,我掛載在/server 下了

[root@localhost home]# mount /dev/vdb /server/

 

8、查看一下掛載是否成功了

[root@localhost home]# df -TH /server

文件系統       類型  容量  已用  可用 已用% 掛載點

/dev/vdb1      xfs   1.7T   34M  1.7T    1% /home/data

 

 

9、修改一下系統配置加入下列行到/etc/fstab,讓系統啟動后自動掛載,否則有可能會掉

UUID=5392f2ec-3101-4c14-a817-a53ab48070ae /server       ext4 defaults,barrier=0 1 1

 

Linux磁盤分區UUID的獲取方法

 

         ① $ ls -l /dev/disk/by-uuid/

 

         ② 通過blkid命令   $ blkid  /dev/vdb1

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM