ebs
create an EBS volume and attach to an EC2 instance
aws ec2 create-volume --availability-zone ap-northeast-1a --volume-type gp3 --size 1 --encrypted --tag-specifications 'ResourceType=volume,Tags=[{Key=Name,Value=test_volume}]'
aws ec2 describe-volumes --volume-id vol-xxxx
aws ec2 attach-volume --device /dev/xvdb --instance-id i-xxxx --volume-id vol-xxxx
make partition and make filesystem
$ lsblk
$ sudo parted /dev/nvme1n1 print
$ sudo parted /dev/nvme1n1 mklabel gpt
$ sudo parted /dev/nvme1n1 mkpart home ext4 1MB 100%
$ sudo mkfs -t ext4 /dev/nvme1n1p1
$ sudo tune2fs -L homefs /dev/nvme1n1p1
$ ls -l /dev/disk/by-label/
edit /etc/fstab and reboot
$ sudo mount /dev/nvme1n1p1 /mnt
$ sudo cp -pri /home/ubuntu /mnt
$ sudo cp -pri /etc/fstab /etc/fstab.000
$ sudo vi /etc/fstab
$ diff /etc/fstab /etc/fstab.000
3d2
aws ec2 reboot-instances --instance-ids i-xxxx --dry-run
extend disk size
aws ec2 modify-volume --volume-id vol-xxxx --size 2
extend partition and filesystem
$ lsblk
$ sudo growpart /dev/nvme1n1 1
$ df -hT /home
$ sudo resize2fs /dev/nvme1n1p1
create snapshot
aws ec2 describe-snapshots --owner-id xxxx
aws ec2 create-snapshot --volume-id vol-xxxx --description 'test snapshot of homefs' --tag-specifications 'ResourceType=snapshot,Tags=[{Key=Name,Value=homefs}]'
aws ec2 describe-snapshots --owner-id xxxx --filters 'Name=volume-id,Values=vol-xxxx'
create new EBS volume from snapshot
aws ec2 create-volume --availability-zone ap-northeast-1a --snapshot-id snap-xxxx --volume-type gp3 --encrypted --tag-specifications 'ResourceType=volume,Tags=[{Key=Name,Value=test_volume}]'
aws ec2 describe-volumes --volume-id vol-yyyy
attach new volume and detach old volume
aws ec2 attach-volume --device /dev/xvdc --instance-id i-xxxx --volume-id vol-yyyy
aws ec2 stop-instances --instance-ids i-xxxx
aws ec2 detach-volume --no-force --instance-id i-xxxx --volume-id vol-xxxx
aws ec2 start-instances --instance-ids i-xxxx
delete volume
aws ec2 delete-volume --volume-id vol-yyyy
aws ec2 describe-volumes
delete snapshot
aws ec2 describe-snapshots --owner-id xxxx
aws ec2 delete-snapshot --snapshot-id snap-xxxx