• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

disk

GCP Find Instance Boot Disk

April 13, 2022

How to find a boot disk from an instance.

gcloud compute instances describe servername \
--format='get(disks[0].source)' \
--zone=us-central1-c \
--project project-id

gcloud compute instances describe servername \ --format='get(disks[0].source)' \ --zone=us-central1-c \ --project project-id

Result

https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/disks/servername-boot

https://www.googleapis.com/compute/v1/projects/project-id/zones/us-central1-f/disks/servername-boot

Filed Under: Cloud Tagged With: boot, disk, find, gcp

GCP Keep Disk

May 6, 2021

Keep your disks when a VM is deleted.

gcloud compute instances set-disk-auto-delete server --no-auto-delete --disk=server-disk-1
gcloud compute instances set-disk-auto-delete server --no-auto-delete --disk=server-disk-2

gcloud compute instances set-disk-auto-delete server --no-auto-delete --disk=server-disk-1 gcloud compute instances set-disk-auto-delete server --no-auto-delete --disk=server-disk-2

To delete.

gcloud compute instances set-disk-auto-delete server --auto-delete --disk=server-disk-1
gcloud compute instances set-disk-auto-delete server --auto-delete --disk=server-disk-2

gcloud compute instances set-disk-auto-delete server --auto-delete --disk=server-disk-1 gcloud compute instances set-disk-auto-delete server --auto-delete --disk=server-disk-2

Filed Under: Cloud Tagged With: deleted, disk, gcp, instance, keep, vm

AWS Copy Snapshot to another Region

March 2, 2021

If you need to copy a snapshot from one region to another, here’s the AWS CLI command.

aws ec2 copy-snapshot \
    --region us-east-1 \
    --source-region us-east-2 \
    --source-snapshot-id snap-xxxxxxxxxxxxxxxxx \
    --description "This is the DR snapshot copy"

aws ec2 copy-snapshot \ --region us-east-1 \ --source-region us-east-2 \ --source-snapshot-id snap-xxxxxxxxxxxxxxxxx \ --description "This is the DR snapshot copy"

Output:

{
    "SnapshotId": "snap-xxxxxxxxxxxxxxxxx"
}

{ "SnapshotId": "snap-xxxxxxxxxxxxxxxxx" }

Filed Under: Cloud Tagged With: aws, copy, disk, region, snapshot

iotop

November 22, 2020

iotop is a Linux command similar to top but instead of CPU and memory it will display and monitor your disk IO usage.

To install, run the following command based on your Linux ditro.

yum install iotop
apt install iotop
dnf install iotop

yum install iotop apt install iotop dnf install iotop

To use.

iotop
iotop -o

iotop iotop -o

Output:

Filed Under: Linux Tagged With: disk, io, iotop, top, usage

GCP UEFI Compatible

June 8, 2020

When trying to boot from a disk created from snapshot and you’re getting an “UEFI feature is not available for this project” error, you’ll need to create a boot image with the –guest-os-features option set to “UEFI_COMPATIBLE.”

gcloud compute disks create new-server-disk-2 \
--project=project-name \
--source-snapshot=server-disk-2 \
--zone=us-central1-b \
--guest-os-features="UEFI_COMPATIBLE"

gcloud compute disks create new-server-disk-2 \ --project=project-name \ --source-snapshot=server-disk-2 \ --zone=us-central1-b \ --guest-os-features="UEFI_COMPATIBLE"

It’s about enabling guest operating system features on custom images. The guest operating system features let you configure networking, security, storage, and operating system options on custom images to be used on boot disks.

Filed Under: Cloud Tagged With: compatible, create, disk, gcp, guest-os-features, snapshots, uefi

GCP Create Instance From Snapshot

September 17, 2019

There are two steps in creating an instance from a snapshot.

  1. Create a disk from snapshot
  2. Create an instance from the disk

Create a disk from snapshot.

gcloud compute disks create "hostname-boot" \
--project "project-id" \
--zone "us-central1-a" \
--source-snapshot "snapshot-name" \
--type "pd-standard" \
--size "100"

gcloud compute disks create "hostname-boot" \ --project "project-id" \ --zone "us-central1-a" \ --source-snapshot "snapshot-name" \ --type "pd-standard" \ --size "100"

Create an instance from disk.

gcloud beta compute instances create hostname \
--project=project-id \
--zone=us-central1-a \
--subnet=your-subnetwork \
--machine-type=n1-standard-1 \
--no-address \
--maintenance-policy=MIGRATE \
--service-account=service.account@developer.gserviceaccount.com \
--disk=name=instance-1,device-name=instance-1,mode=rw,boot=yes,auto-delete=yes \
--reservation-affinity=any \
--labels=builtby=john.doe \
--tags=web \
--scopes= \
--metadata=

gcloud beta compute instances create hostname \ --project=project-id \ --zone=us-central1-a \ --subnet=your-subnetwork \ --machine-type=n1-standard-1 \ --no-address \ --maintenance-policy=MIGRATE \ --service-account=service.account@developer.gserviceaccount.com \ --disk=name=instance-1,device-name=instance-1,mode=rw,boot=yes,auto-delete=yes \ --reservation-affinity=any \ --labels=builtby=john.doe \ --tags=web \ --scopes= \ --metadata=

Filed Under: Cloud, Linux Tagged With: create, disk, gcp, instance, snapshot

GCP Convert Standard to SSD

August 20, 2019

How to convert Persistent Standard disk to SSD.

First create a snapshot of the disk.

gcloud compute disks snapshot your-server \
--snapshot-names manual-snapshot-disk-1 \
--project your-project \
--zone us-central1-c

gcloud compute disks snapshot your-server \ --snapshot-names manual-snapshot-disk-1 \ --project your-project \ --zone us-central1-c

Restore snapshot to SSD format.

gcloud compute disks create disk-1-ssd \
--source-snapshot manual-snapshot-disk-1 \
--project your-project \
--zone us-central1-a \
--type pd-ssd \
--size 10GB

gcloud compute disks create disk-1-ssd \ --source-snapshot manual-snapshot-disk-1 \ --project your-project \ --zone us-central1-a \ --type pd-ssd \ --size 10GB

Swap disks using GCP attach and detach.

Filed Under: Cloud Tagged With: create, disk, gcp, restore, snapshot, ssd

Chroot A Boot Disk

August 19, 2019

Here’s a quick way to chroot another boot disk. Attach the rescued boot disk first. Run lsblk and mount.

lsblk
mount -t xfs -o nouuid /dev/xvdf2 /mnt
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
mount --bind /dev /mnt/dev
chroot /mnt
cd /mnt
exit

lsblk mount -t xfs -o nouuid /dev/xvdf2 /mnt mount --bind /proc /mnt/proc mount --bind /sys /mnt/sys mount --bind /dev /mnt/dev chroot /mnt cd /mnt exit

Unmount when done.

umount /mnt/proc
umount /mnt/dev
umount /mnt/sys
umount /mnt

umount /mnt/proc umount /mnt/dev umount /mnt/sys umount /mnt

Filed Under: Cloud, Linux Tagged With: attach, chroot, disk, rescue

  • Go to page 1
  • Go to page 2
  • Go to Next Page »
  • Home
  • About
  • Archives

Copyright © 2023