1. 程式人生 > 實用技巧 >3,aliyun 實際工作掛載

3,aliyun 實際工作掛載

1,阿里雲主機預設一般都不掛載資料盤的:
	需要手動操作如下: 
		1,新增資料盤
		2,分割槽
		3,格式化
		4,掛載

1,新增資料盤
[liuqi@alicloud-hb3-flume13-192176 ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G  5.5G   32G  15% /
devtmpfs        7.8G     0  7.8G   0% /dev
tmpfs           7.8G     0  7.8G   0% /dev/shm
tmpfs           7.8G  364K  7.8G   1% /run
tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup
tmpfs           1.6G     0  1.6G   0% /run/user/607
tmpfs           1.6G     0  1.6G   0% /run/user/601


2,分割槽
[root@alicloud-hb3-flume13-192176 ~]# 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: 0x0008de3e
   Device Boot      Start         End      Blocks   Id  System
   /dev/vda1   *        2048    83884031    41940992   83  Linux
Disk /dev/vdb: 214.7 GB, 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


[root@alicloud-hb3-flume13-192176 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Aug 18 03:51:14 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=59d9ca7b-4f39-4c0c-9334-c56c182076b5 /                       ext4    defaults        1 1


[root@alicloud-hb3-flume13-192176 ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).
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
Building a new DOS disklabel with disk identifier 0x94768908.
Command (m for help): m
Command action
   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)
 
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-419430399, default 2048): (直接跳過,按回車跳過)
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399): (直接跳過,按回車跳過)
Using default value 419430399
Partition 1 of type Linux and of size 200 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@alicloud-hb3-flume13-192176 ~]# ll /dev/vd
vda   vda1  vdb   vdb1  


3,格式化
[root@alicloud-hb3-flume13-192176 ~]# mkfs.xfs /dev/vdb1
meta-data=/dev/vdb1              isize=512    agcount=4, agsize=13107136 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=52428544, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=25599, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

 
4,掛載
[root@alicloud-hb3-flume14-192177 /]# mount /dev/vdb1 /opt/
[root@alicloud-hb3-flume14-192177 /]# blkid
/dev/vda1: UUID="59d9ca7b-4f39-4c0c-9334-c56c182076b5" TYPE="ext4"
/dev/vdb1: UUID="32ad877a-3973-4a78-b6a4-024c025350d5" TYPE="xfs"
[root@alicloud-hb3-flume14-192177 /]#
[root@alicloud-hb3-flume14-192177 /]# cat /etc/fstab
# Created by anaconda on Fri Aug 18 03:51:14 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=59d9ca7b-4f39-4c0c-9334-c56c182076b5 /                       ext4    defaults        1 1
UUID=32ad877a-3973-4a78-b6a4-024c025350d5 /opt xfs defaults 1 1
[root@alicloud-hb3-flume14-192177 /]# ok了!!