建立于: 7年前 ( 更新: 7年前 )
参考的官方原文数据:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html
以下是进行步骤完整日志:
1. 用lsblk命令查看可用的磁盘设备及他们的挂载点(if applicable)
所以就是说xvdb就是/dev/xvdb
2. 检测是否需要创建文件系统到卷中(Volumn)上。
4. 没数据的情况下透过下方命令,即可创建文件系统,就是Windows上的格式化意思,格式化为ext4文件系统,注意,如果有数据会被清空。
在这个例子中,我是挂载到了/opt数据夹
11. 确认新建的项目是有作用的,可用
如果出现任何错误,千万不要重开机,会造成系统无法重启。
请还原step 6的备份步骤,
或修正后,再使用sudo mount -a测试。
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html
以下是进行步骤完整日志:
1. 用lsblk命令查看可用的磁盘设备及他们的挂载点(if applicable)
ubuntu@ip-10-0-0-251:/$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 8G 0 disk
└—xvda1 202:1 0 8G 0 part /
xvdb 202:16 0 150G 0 disk
输出画面lsblk会移除前置/dev/的设备路径。所以就是说xvdb就是/dev/xvdb
2. 检测是否需要创建文件系统到卷中(Volumn)上。
ubuntu@ip-10-0-0-251:/$ sudo file -s /dev/xvdb
/dev/xvdb: data
在上例中,出现了data代表,没有文件系统给这个设备,因此要创建一个.4. 没数据的情况下透过下方命令,即可创建文件系统,就是Windows上的格式化意思,格式化为ext4文件系统,注意,如果有数据会被清空。
sudo mkfs -t ext4 /dev/xvdb
5. 完成后,及可挂载。 sudo mount device_name mount_point
在这个例子中,我是挂载到了/opt数据夹
sudo mount /dev/xvdb /opt
6. 设置自动挂载文件系统,不然reboot后要手动挂载 ,首先,先备份/etc/fstab
sudo cp /etc/fstab /etc/fstab.orig
7. 用编辑器开启/etc/fstab进行修改,使用如下的格式,可以用设备名称,例如 /dev/xvdb,但建议使用设备的128bit的UUID。
device_name mount_point file_system_type fs_mntops fs_freq fs_passno
8.找UUID的部骤,先用 df
列出可用设备.
ubuntu@ip-10-0-0-251:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 2014864 0 2014864 0% /dev
tmpfs 404524 5664 398860 2% /run
/dev/xvda1 8065444 1145048 6904012 15% /
tmpfs 2022604 0 2022604 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 2022604 0 2022604 0% /sys/fs/cgroup
/dev/xvdb 154687468 60864 146745900 1% /opt
tmpfs 404524 0 404524 0% /run/user/1000
ubuntu@ip-10-0-0-251:~$
9. 再来用下方命令去列出设备的UUID,例如我要看的是/dev/xvdb
ubuntu@ip-10-0-0-251:~$ sudo file -s /dev/xvdb
/dev/xvdb: Linux rev 1.0 ext4 filesystem data, UUID=dfd2866b-5600-4c20-80f5-d8a6f4786432 (needs journal recovery) (extents) (large files) (huge files)
10. 所以在/etc/fstab上进行如下的修改,让文件系统自动挂载。
UUID=dfd2866b-5600-4c20-80f5-d8a6f4786432 /opt ext4 defaults,nofail
最后注记: 低於 16.04的版本,要再加上nobootwait
Note
If you ever intend to boot your instance without this volume attached (for example, so this volume could move back and forth between different instances), you should add the nofail mount option that allows the instance to boot even if there are errors in mounting the volume. Debian derivatives, including Ubuntu versions earlier than 16.04, must also add the nobootwaitmount option.
If you ever intend to boot your instance without this volume attached (for example, so this volume could move back and forth between different instances), you should add the nofail mount option that allows the instance to boot even if there are errors in mounting the volume. Debian derivatives, including Ubuntu versions earlier than 16.04, must also add the nobootwaitmount option.
11. 确认新建的项目是有作用的,可用
sudo mount -a
如果运行上方命令,没有出现任何信息,没消息就是好消息( No news is good news ),那么代表/etc/fstab档没有设置错误,如果出现任何错误,千万不要重开机,会造成系统无法重启。
请还原step 6的备份步骤,
或修正后,再使用sudo mount -a测试。
No Comment
Post your comment