在EC2实例上验证安装点

发布于 2025-02-02 20:00:28 字数 541 浏览 4 评论 0原文

我在 ec2实例上安装多个EBS卷以执行一些验证和校验和检查,但问题是在安装在目标安装点上之前,我需要检查是否没有占用该安装由于我正在动态创建安装点,例如

test_lambda.py (例如)(例如)

device_prefixes = ['f','g','h','i','j','k','l','m','n','o','p']
        attached_volumes = []
        
        
        try:
            for index,volume_id in enumerate(created_volumes):
                
                MOUNT_POINT = "/dev/sd{}".format(device_prefixes[index])

我已经尝试使用 ssm Findmnt ,但它们正在显示分区和其他卷,但不像(/dev/sde,/dev/sdf etc)那样定位

i am mounting multiple ebs volumes on an ec2 instance to perform some validations and check-sums but the problem is that before mounting volumes on the target mount point , i need to check whether that mount is not occupied, since i am creating mount points dynamically e.g

test_lambda.py (e.g)

device_prefixes = ['f','g','h','i','j','k','l','m','n','o','p']
        attached_volumes = []
        
        
        try:
            for index,volume_id in enumerate(created_volumes):
                
                MOUNT_POINT = "/dev/sd{}".format(device_prefixes[index])

I have tried commands using SSM like /proc/mounts, findmnt, but they are displaying partitions and other volumes but not target like (/dev/sde,/dev/sdf etc)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静待花开 2025-02-09 20:00:28

多亏了约旦提供的提示,我能够清除对块设备映射的理解, boto3 ec2客户端有一种相关的方法,

`# where attribute can be one of the following`  `"""'|'kernel'|'ramdisk'|'userData'|'disableApiTermination'|'instanceInitiatedShutdownBehavior'|'rootDeviceName'|'blockDeviceMapping'|'productCodes'|'sourceDestCheck'|'groupSet'|'ebsOptimized'|'sriovNetSupport'|'enaSupport'|'enclaveOptions'|'disableApiStop',z"""`
        print(instance.describe_attribute(
    instance.describe_attribute(
                Attribute='blockDeviceMapping',
                DryRun=False,
                
                )

它确实为我们提供了有关某些资源的信息,如果我的问题不清楚,则表示歉意首先,

{'BlockDeviceMappings':[{'deviceName':'/dev/xvda','ebs':
{'factiontime':dateTime.dateTime(2022、5、27、12、4、1,
tzinfo = tzlocal()),'deleteonmention':true,'状态':'nacted',
'volumeid':'vol-05bb41df0e6bc4bf3'}},{'deviceName':'/dev/sdl',
'ebs':{'entacttime':dateTime.dateTime(2022、5、27、15、15、51,
tzinfo = tzlocal()),'deleteonmention':false,'状态':'nacted',
'volumeid':'vol-00be0e0f001fea1a9'}}},{'deviceName':'/dev/sdm',
'ebs':{'entacttime':dateTime.dateTime(2022、5、27、15、15、51,
tzinfo = tzlocal()),'deleteonmention':false,'状态':'nacted',
'volumeid':'vol-09c552e7777ba2a563f'}}},{'deviceName':'//dev/sdn',
'ebs':{'entacttime':dateTime.dateTime(2022、5、27、15、15、52,
tzinfo = tzlocal()),'deleteonmention':false,'状态':'nacted',
'volumeid':'vol-08d28a4ffe5e71dff'}},{'deviceName':'/dev/sdo',
'ebs':{'entacttime':dateTime.dateTime(2022、5、27、15、15、53,
tzinfo = tzlocal()),'deleteonmention':false,'状态':'nacted',
'volumeid':'vol-0e63fa17bd6185ee3'}}},{'deviceName':'/dev/dev/sdf',
'ebs':{'entacttime':dateTime.dateTime(2022、5、27、15、36、42,
tzinfo = tzlocal()),'deleteonmention':false,'状态':'nacted',
'volumeid':'vol-058de095fcfb1ef05'}}},{'deviceName':'//dev/sdg',
'ebs':{'atta

Thanks to the hint provided by jordan, i was able to clear my understanding about block device mapping , boto3 ec2 client has a method associated

`# where attribute can be one of the following`  `"""'|'kernel'|'ramdisk'|'userData'|'disableApiTermination'|'instanceInitiatedShutdownBehavior'|'rootDeviceName'|'blockDeviceMapping'|'productCodes'|'sourceDestCheck'|'groupSet'|'ebsOptimized'|'sriovNetSupport'|'enaSupport'|'enclaveOptions'|'disableApiStop',z"""`
        print(instance.describe_attribute(
    instance.describe_attribute(
                Attribute='blockDeviceMapping',
                DryRun=False,
                
                )

it does give us info about certain resources, apologies if my question was not clear in the first place,

{'BlockDeviceMappings': [{'DeviceName': '/dev/xvda', 'Ebs':
{'AttachTime': datetime.datetime(2022, 5, 27, 12, 4, 1,
tzinfo=tzlocal()), 'DeleteOnTermination': True, 'Status': 'attached',
'VolumeId': 'vol-05bb41df0e6bc4bf3'}}, {'DeviceName': '/dev/sdl',
'Ebs': {'AttachTime': datetime.datetime(2022, 5, 27, 15, 15, 51,
tzinfo=tzlocal()), 'DeleteOnTermination': False, 'Status': 'attached',
'VolumeId': 'vol-00be0e0f001fea1a9'}}, {'DeviceName': '/dev/sdm',
'Ebs': {'AttachTime': datetime.datetime(2022, 5, 27, 15, 15, 51,
tzinfo=tzlocal()), 'DeleteOnTermination': False, 'Status': 'attached',
'VolumeId': 'vol-09c552e77ba2a563f'}}, {'DeviceName': '/dev/sdn',
'Ebs': {'AttachTime': datetime.datetime(2022, 5, 27, 15, 15, 52,
tzinfo=tzlocal()), 'DeleteOnTermination': False, 'Status': 'attached',
'VolumeId': 'vol-08d28a4ffe5e71dff'}}, {'DeviceName': '/dev/sdo',
'Ebs': {'AttachTime': datetime.datetime(2022, 5, 27, 15, 15, 53,
tzinfo=tzlocal()), 'DeleteOnTermination': False, 'Status': 'attached',
'VolumeId': 'vol-0e63fa17bd6185ee3'}}, {'DeviceName': '/dev/sdf',
'Ebs': {'AttachTime': datetime.datetime(2022, 5, 27, 15, 36, 42,
tzinfo=tzlocal()), 'DeleteOnTermination': False, 'Status': 'attached',
'VolumeId': 'vol-058de095fcfb1ef05'}}, {'DeviceName': '/dev/sdg',
'Ebs': {'Atta

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文