Skip to main content

Error related to disk while changing instance type from c4.large to c5.xlarge for ubuntu linux mach [Resolved]

I am providing user data to linux machine by cloudformation and its working fine when i am using c4 class type(example: c4.large, c4.xlarge) while it stop working when i am changing instance type in cloudformation and deploying on server by running jenkin job.

i am using c4.large and when i changed instance type to c5.xlarge it was not working so for testing when i change to c4.xlarge, it was working so problem is only with c5 instance type. i also checked both instance type using optimized EBS volume so there is no big different on disk level.

Logs:

Mar 28 05:50:30 ip-10-116-54-180 cloud-init[1876]: Setting up python3-botocore (1.4.70-1~16.04.0) ...
Mar 28 05:50:30 ip-10-116-54-180 cloud-init[1876]: Setting up python3-s3transfer (0.1.9-1~16.04.0) ...
Mar 28 05:50:31 ip-10-116-54-180 cloud-init[1876]: Setting up awscli (1.11.13-1ubuntu1~16.04.0) ...
Mar 28 05:50:31 ip-10-116-54-180 cloud-init[1876]: Processing triggers for libc-bin (2.23-0ubuntu11) ...
**Mar 28 05:50:32 ip-10-116-54-180 cloud-init[1876]: Error: Could not stat device /dev/xvdb - No such file or directory.
Mar 28 05:50:32 ip-10-116-54-180 cloud-init[1876]: #015                                                                          #015Error: Could not stat device /dev/xvdb - No such file or directory.**
Mar 28 05:50:39 ip-10-116-54-180 systemd[1]: Created slice User Slice of ubuntu.
Mar 28 05:50:39 ip-10-116-54-180 systemd[1]: Starting User Manager for UID 1000...
Mar 28 05:50:39 ip-10-116-54-180 systemd[1]: Started Session 1 of user ubuntu.
Mar 28 05:50:39 ip-10-116-54-180 systemd[8734]: Reached target Sockets.
Mar 28 05:50:39 ip-10-116-54-180 systemd[8734]: Reached target Timers.
Mar 28 05:50:39 ip-10-116-54-180 systemd[8734]: Reached target Paths.
Mar 28 05:50:39 ip-10-116-54-180 systemd[8734]: Reached target Basic System.
Mar 28 05:50:39 ip-10-116-54-180 systemd[8734]: Reached target Default.
Mar 28 05:50:39 ip-10-116-54-180 systemd[8734]: Startup finished in 8ms.
Mar 28 05:50:39 ip-10-116-54-180 systemd[1]: Started User Manager for UID 1000.
Mar 28 05:50:55 ip-10-116-54-180 amazon-ssm-agent.amazon-ssm-agent[1800]: 2019-03-28 05:50:55 INFO [HealthCheck] HealthCheck reporting agent health.
Mar 28 05:53:32 ip-10-116-54-180 systemd[1]: Started Session 2 of user ubuntu.

User Data for instance:

#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y awscli python-pip python-dev python-virtualenv
mkdir /var/log/nginx
parted /dev/xvdb mklabel gpt
parted -a opt /dev/xvdb mkpart primary ext4 0% 100%
echo '/dev/xvdb1 /var/log/nginx ext4 defaults 0 0' >> /etc/fstab
sleep 10
while [ ! -e /dev/xvdb1 ]; do sleep 1; done
mkfs.ext4 /dev/xvdb1
mount /var/log/nginx
chown root:adm /var/log/nginx
tar zxvf aws-ss-routing.tar.gz
chmod +x nginx/install.sh
cd nginx && ./install.sh

As c5 class is advance level class for c4 class type so i need to use this and solve this problem.


Question Credit: user2682305
Question Reference
Asked April 16, 2019
Posted Under: Network
24 views
1 Answers

The error message stated could not found the device name Error: Could not stat device /dev/xvdb - No such file or directory.. You may want to check if the device name is still /dev/xvdX, most of the newer version of EC2 are using NVMe EBS, so the naming convention has changed to /dev/nvme[0-26]n1, refer to here https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/device_naming.html You need to update the User Data to map the right naming convention of the EBS.


credit: Sithter
Answered April 16, 2019
Your Answer