-
Notifications
You must be signed in to change notification settings - Fork 1
AWS Work
Franknaw edited this page Aug 17, 2021
·
16 revisions
aws ec2 create-volume \
--availability-zone "us-gov-east-1a" \
--no-encrypted \
--volume-type "gp2" \
--size 500 \
--no-multi-attach-enabled \
{
"AvailabilityZone": "us-gov-east-1a",
"CreateTime": "2021-08-17T20:15:16.000Z",
"Encrypted": false,
"Size": 500,
"SnapshotId": "",
"State": "creating",
"VolumeId": "vol-028d6b278df87f027",
"Iops": 1500,
"Tags": [],
"VolumeType": "gp2",
"MultiAttachEnabled": false
}
aws ec2 create-tags \
--resources vol-028d6b278df87f027 --tags Key=Name,Value=vhd
aws ec2 describe-volumes --volume-ids vol-028d6b278df87f027
{
"Volumes": [
{
"Attachments": [],
"AvailabilityZone": "us-gov-east-1a",
"CreateTime": "2021-08-17T20:15:16.176Z",
"Encrypted": false,
"Size": 500,
"SnapshotId": "",
"State": "available",
"VolumeId": "vol-028d6b278df87f027",
"Iops": 1500,
"Tags": [
{
"Key": "Name",
"Value": "vhd"
}
],
"VolumeType": "gp2",
"MultiAttachEnabled": false
}
]
}
aws ec2 attach-volume \
--volume-id vol-028d6b278df87f027 \
--instance-id i-0cc1dba8c1367f336 \
--device /dev/sdf \
--dry-run
{
"AttachTime": "2021-08-17T20:18:14.689Z",
"Device": "/dev/sdf",
"InstanceId": "i-0cc1dba8c1367f336",
"State": "attaching",
"VolumeId": "vol-028d6b278df87f027"
}
aws ec2 detach-volume --volume-id vol-028d6b278df87f027
{
"AttachTime": "2021-08-17T19:42:56.000Z",
"Device": "/dev/sdf",
"InstanceId": "i-0cc1dba8c1367f336",
"State": "detaching",
"VolumeId": "vol-028d6b278df87f027"
}
aws ec2 delete-volume --volume-id vol-028d6b278df87f027
lsblk
sudo file -s /dev/nvme1n1
sudo lsblk -f
sudo mkfs -t xfs /dev/nvme1n1
meta-data=/dev/nvme1n1 isize=512 agcount=4, agsize=32768000 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=0
data = bsize=4096 blocks=131072000, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=64000, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
sudo mkdir /vhd
sudo mount /dev/nvme1n1 /vhd
sudo lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
nvme0n1
├─nvme0n1p1 xfs / 2c418186-ef58-4f8e-9e21-7c8de84723ed /
└─nvme0n1p128
nvme1n1 xfs 38e74e8c-385b-4a89-979f-008940e201c3 /vhd
sudo blkid
dev/nvme0n1: PTUUID="cd16d97e-8975-4d1b-bfd5-084d0c50dddf" PTTYPE="gpt"
/dev/nvme0n1p1: LABEL="/" UUID="2c418186-ef58-4f8e-9e21-7c8de84723ed" TYPE="xfs" PARTLABEL="Linux" PARTUUID="9c15d96e-4f19-40c7-9659-3b24b68717ad"
/dev/nvme0n1p128: PARTLABEL="BIOS Boot Partition" PARTUUID="df443f65-f9b3-4dfe-87a1-af35c999a39a"
/dev/nvme1n1: UUID="38e74e8c-385b-4a89-979f-008940e201c3" TYPE="xfs"
- Edit /etc/fstab
UID=38e74e8c-385b-4a89-979f-008940e201c3 /vhd xfs defaults,noatime 0 2
-
0 means to not dump the filesystem and 2 means its a non-root device
-
Verify
-
sudo umount /vhd
-
sudo mount -a
-
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html
-
https://docs.aws.amazon.com/cli/latest/reference/ec2/attach-volume.html
-
https://docs.aws.amazon.com/cli/latest/reference/opsworks/create-instance.html
-
https://docs.aws.amazon.com/cli/latest/reference/ec2/delete-volume.html
aws ec2 create-instance
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AmazonEBS.html
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-creating-volume.html
- https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ebs/index.html#cli-aws-ebs
- https://docs.aws.amazon.com/cli/latest/reference/ec2/create-tags.html
aws --version
ws-cli/1.16.253 Python/3.6.8 Linux/4.18.0-305.10.2.el8_4.x86_64 botocore/1.12.243
pip3 install awscli --upgrade --user
aws --version
aws-cli/1.20.22 Python/3.6.8 Linux/4.18.0-305.10.2.el8_4.x86_64 botocore/1.21.22