AWS块设备映射以在创建单独的根时装入快照

时间:2021-06-01 00:01:56

I want to create a new instance with root mounting from its AMI (sda1), while at the same creating a secondary volume (sda2) from a snapshot.

我想从其AMI(sda1)创建一个具有根安装的新实例,同时从快照创建一个辅助卷(sda2)。

I am using the following block device mapping to add sda2:

我使用以下块设备映射来添加sda2:

[
    {
        "DeviceName": "/dev/sda2", 
        "Ebs": {
            "DeleteOnTermination": false, 
            "SnapshotId": "snap-0daafbeb9409cb652"
        }
    }

]

]

However, while an sda1 volume is created from the AMI, it appears that sda2 is mounted as root

但是,虽然从AMI创建了sda1卷,但似乎sda2以root身份挂载

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   8G  0 disk 
└─xvdb1 202:17   0   8G  0 part /

What should be different to cause xvda1 (which links to sda1) to mount as root instead? I do not want to modify the AMI to do this, the starting point for this process is a stock Ubuntu image.

应该有什么不同导致xvda1(链接到sda1)以root身份挂载?我不想修改AMI来执行此操作,此过程的起点是库存Ubuntu映像。

aws ec2 run-instances --image-id ami-c80b0aa2 ... --block-device-mappings file://mappings.json

1 个解决方案

#1


0  

This problem is caused by the volume labels of the partitions being mounted. In this specific case, both volumes have the same label, indicating they are the root partition, which is confusing the boot process.

此问题是由正在安装的分区的卷标引起的。在这种特定情况下,两个卷都具有相同的标签,表明它们是根分区,这使引导过程混乱。

The solution here is to clear the label of the volume that is not being mounted as the root filesystem.

这里的解决方案是清除未作为根文件系统安装的卷的标签。

#1


0  

This problem is caused by the volume labels of the partitions being mounted. In this specific case, both volumes have the same label, indicating they are the root partition, which is confusing the boot process.

此问题是由正在安装的分区的卷标引起的。在这种特定情况下,两个卷都具有相同的标签,表明它们是根分区,这使引导过程混乱。

The solution here is to clear the label of the volume that is not being mounted as the root filesystem.

这里的解决方案是清除未作为根文件系统安装的卷的标签。