简体   繁体   English

将带有AWS市场代码的CentOS根卷附加到其他CentOS EC2实例时,另一个实例将使用附加的根卷启动

[英]On attaching CentOS root volume with AWS marketplace code to other CentOS EC2 instance, the other instance boots up using the attached root volume

I screwed up root volume of my system in ec2 instance so I attached root volume of the instance to other ec2 instance so that I could access the bad root volume and rectify my error. 我在ec2实例中弄乱了系统的根卷,因此将实例的根卷附加到其他ec2实例上,以便可以访问错误的根卷并纠正错误。 When I start the other instance, the screwed up root volume becomes the root volume of the instance. 当我启动另一个实例时,搞砸的根卷将成为该实例的根卷。 I attached the volume as /dev/sdb (kernel changed it to /dev/xvdf ) and the instance original root volume is at /dev/sda (kernel changed it to /dev/xvde ). 我将卷附加为/ dev / sdb(内核将其更改为/ dev / xvdf),实例原始根卷位于/ dev / sda(内核将其更改为/ dev / xvde)。 So kernel should load /dev/xvde as root filesystem but its loading scrwed up root volume (/dev/xvdf) . 因此内核应将/ dev / xvde作为根文件系统加载,但其加载会破坏根卷(/ dev / xvdf)。

The snippet of system logs of the system is as following: 系统的系统日志片段如下:

dracut: Starting plymouth daemon dracut:启动普利茅斯守护进程

xlblk_init: register_blkdev major: 202 xlblk_init:register_blkdev专业:202

blkfront: xvdf: barriers disabled blkfront:xvdf:禁用障碍

xvdf: unknown partition table xvdf:未知分区表

blkfront: xvde: barriers disabled blkfront:xvde:禁用障碍

xvde: unknown partition table xvde:未知分区表

EXT4-fs (xvdf): mounted filesystem with ordered data mode. EXT4-fs(xvdf):已安装的文件系统,具有有序数据模式。 Opts: 选择:

dracut: Mounted root filesystem /dev/xvdf dracut:挂载的根文件系统/ dev / xvdf

OR 要么

The simple way is to attach Centos root volume to a amazon linux machine and fix the issue. 简单的方法是将Centos根卷附加到亚马逊linux计算机上并解决问题。 Don't attach Centos root volume to another ec2 instance running Centos. 不要将Centos根卷附加到另一个运行Centos的ec2实例。 Centos in AWS marketplace have "centos" as label for root volume . AWS市场中的Centos使用“ centos”作为根卷的标签。 So when we attach centos root volume to another centos machine, AWS gets confused as to which root volume to mount and anomaly happens. 因此,当我们将centos根卷附加到另一台centos机器上时,AWS对于要挂载和发生异常的根卷感到困惑。

As the screwed up root volume and the original instance root volume has the same label attached to the volume partition (in my case my OS is centos6.5 and the label is centos_root ) , so we have to change the label of our instance so that next time it boots it doesn't look for label centos_root and instead it will look for our changed label. 由于拧紧的根卷和原始实例根卷在卷分区上具有相同的标签(在我的情况下,我的操作系统是centos6.5,标签是centos_root),因此我们必须更改实例的标签,以便下次启动时,它不会查找标签centos_root,而是会查找我们已更改的标签。

First, change the root volume partition label by the command ex. 首先,通过命令ex更改根卷分区标签。 e2label /dev/xvde your_label , here /dev/xvde is the root partition e2label / dev / xvde your_label,这里/ dev / xvde是根分区

Second, change the label in "/etc/fstab and /boot/grub/grub.conf" with your_label. 其次,使用your_label更改“ / etc / fstab和/boot/grub/grub.conf”中的标签。

Third, Stop the instance 三,停止实例

Fourth, Attched the screwed up root volume to the instance 第四,将拧紧的根卷附加到实例

Fifth, Start the instance 五,启动实例

Sixth, Voila now you can see the screwed up root volume partition and mount it to some mount point to fix your issue . 第六,Voila现在您可以看到拧紧的根卷分区并将其挂载到某个挂载点以解决您的问题。

deattach the "screwed up" volume from the other ec2 instance 从其他ec2实例上拆下“压缩的”卷

boot the other instance normally 正常启动另一个实例

attach the EBS to the running instance see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-attaching-volume.html 将EBS附加到正在运行的实例,请参见http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-attaching-volume.html

do fdisk -l as root and find the device name of the new instance 以root身份执行fdisk -l并找到新实例的设备名称

make a "mount point" (a directory) and mount the desired disk partition on it 创建一个“挂载点”(目录)并在其上挂载所需的磁盘分区

once it is fixed, use the umount command on the mount point and then deattach the volume 固定后,在安装点上使用umount命令,然后拆下卷

If the AMI has a marketplace code try the steps given in this answer https://serverfault.com/questions/522173/aws-vol-xxxxxxx-with-marketplace-codes-may-not-be-attached-as-as-secondary-dev 如果AMI有市场代码,请尝试执行此答案中给出的步骤https://serverfault.com/questions/522173/aws-vol-xxxxxxx-with-marketplace-codes-may-not-be-attached-as-as-二次开发

PSA: don't use CentOS in AWS. PSA:请勿在AWS中使用CentOS。

You can no longer attach a root volume for a CentOS instance to another instance. 您不能再将CentOS实例的根卷附加到另一个实例。 This is by design, to prevent people from circumventing licensing agreements. 这是设计使然,以防止人们绕过许可协议。 Even though CentOS is technically free, because it's a marketplace AMI, the rule applies. 尽管CentOS在技术上是免费的,但由于它是市场上的AMI,因此该规则仍然适用。 It's a good rule in general, but it makes recovery of a failed configuration impossible. 通常,这是个好规则,但是它使恢复失败的配置成为不可能。

Use Amazon Linux. 使用Amazon Linux。 It's basically CentOS anyways. 无论如何,基本上都是CentOS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM