我似乎无法弄清楚如何使用Amazon's instructions将EBS卷安装到Ubuntu EC2实例。有人可以帮助我吗?
~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 16G 0 disk
└─xvda1 202:1 0 16G 0 part /
~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 492M 12K 492M 1% /dev
tmpfs 100M 340K 99M 1% /run
/dev/xvda1 16G 7.2G 7.8G 48% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 497M 0 497M 0% /run/shm
none 100M 0 100M 0% /run/user
~$ sudo file -s /dev/xvda
/dev/xvda: x86 boot sector
~$ sudo file -s /dev/xvda1
/dev/xvda1: Linux rev 1.0 ext4 filesystem data, UUID=da85f42e-5e55-40d1-95da-dea139db0d7f, volume name "cloudimg-rootfs" (needs journal recovery) (extents) (large files) (huge files)
~$ sudo mkfs -t ext4 /dev/xvda
mke2fs 1.42.9 (4-Feb-2014)
/dev/xvda is apparently in use by the system; will not make a filesystem here!
~$ sudo mkdir /data
~$ sudo mount /dev/xvda /data
mount: /dev/xvda already mounted or /data busy
答案 0 :(得分:1)
您似乎有一个磁盘xvda
,其中一个分区xvda1
。分区/dev/xvda1
已安装在/
。由于您只有一个磁盘,其中一个分区是作为根卷安装的,因此此时您无法执行任何其他操作。您是否尝试向EC2实例添加第二个EBS卷?如果是这样,您需要先将其附加到实例,然后查找它以显示在lsblk
输出中。
答案 1 :(得分:0)
这是一个适用于 Amazon Linux 2 的脚本,您可以为 Ubuntu 重新创建,只需在使用 yum 评论原始数据时尝试:
#!/bin/bash
sudo yum -y update
sudo yum -y upgrade
# Format and mount an attached volume
DEVICE=/dev/$(lsblk -rno NAME | awk 'FNR == 3 {print}')
MOUNT_POINT=/data/
mkdir $MOUNT_POINT
yum -y install xfsprogs
mkfs -t xfs $DEVICE
mount $DEVICE $MOUNT_POINT
# Automatically mount an attached volume after reboot / For the current task it's not obligatory
cp /etc/fstab /etc/fstab.orig
UUID=$(blkid | grep $DEVICE | awk -F '\"' '{print $2}')
echo -e "UUID=$UUID $MOUNT_POINT xfs defaults,nofail 0 2" >> /etc/fstab
umount /data
mount -a
# Change user for data operations / Non mandatory
chown -R ec2-user:ec2-user $MOUNT_POINT
来自here