• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

attach

Linux Screen

December 26, 2022

Just documenting the Linux Screen command.

Install screen first.

yum install screen
dnf install screen
apt install screen
zypper install screen

yum install screen dnf install screen apt install screen zypper install screen

Start a new screen.

screen -S one
screen -S two
screen -S three

screen -S one screen -S two screen -S three

Detach from screen.

Ctrl+a+d

Ctrl+a+d

List active screens.

screen -ls 
There is a screen on:
        15575.one   (Detached)
        15581.two   (Detached)
        15593.three (Detached)
1 Socket in /var/run/screen/S-root.

screen -ls There is a screen on: 15575.one (Detached) 15581.two (Detached) 15593.three (Detached) 1 Socket in /var/run/screen/S-root.

Reattach to an existing screen.

screen -r one
screen -r two
screen -r three

screen -r one screen -r two screen -r three

If there’s only one active screen, you can run screen -r without the name.

screen -r

screen -r

To exit or quit a screen, reattach and run exit.

screen -r three
# exit
[screen is terminating]

screen -r three # exit [screen is terminating]

Filed Under: Linux Tagged With: attach, detach, list, screen

Linux Screen

May 7, 2020

If you don’t have it installed.

yum install screen
apt install screen

yum install screen apt install screen

Before you run a process, run screen, and detach.

screen
# run the command
ping yahoo.com
# ctrl-a and ctrl-d to detach

screen # run the command ping yahoo.com # ctrl-a and ctrl-d to detach

To reattach, get a list of screen sessions, and attach to it.

screen -ls
# result is somewhat similar to below
4452.hostname
# attach to it
screen -dr 4452.hostname

screen -ls # result is somewhat similar to below 4452.hostname # attach to it screen -dr 4452.hostname

To stop, just type exit from the screen terminal.

Filed Under: Linux Tagged With: attach, detach, screen

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

AWS CLI Lightsail

May 19, 2019

Get instance details

aws lightsail get-instance --instance-name your-server

aws lightsail get-instance --instance-name your-server

Get instance state

aws lightsail get-instance-state --instance-name your-server

aws lightsail get-instance-state --instance-name your-server

Create a snapshot

aws lightsail create-instance-snapshot \
--instance-snapshot-name your-server-new-snapshot-201905192200 \
--instance-name your-server

aws lightsail create-instance-snapshot \ --instance-snapshot-name your-server-new-snapshot-201905192200 \ --instance-name your-server

Create disk from snapshot

aws lightsail create-disk-from-snapshot \
--disk-name your-server-new-boot-disk \
--disk-name your-server-new-snapshot-201905192200 \
--availability-zone us-east-1a
--size-in-gb 50

aws lightsail create-disk-from-snapshot \ --disk-name your-server-new-boot-disk \ --disk-name your-server-new-snapshot-201905192200 \ --availability-zone us-east-1a --size-in-gb 50

Attach Disk

aws lightsail attach-disk \
--disk-name your-server-new-boot-disk \
--instance-name your-server \
--disk-path /dev/sda1

aws lightsail attach-disk \ --disk-name your-server-new-boot-disk \ --instance-name your-server \ --disk-path /dev/sda1

Create instance from snapshot

aws lightsail create-instance-snapshot \
--instance-snaphot-name your-server-new-snapshot-201905192200
--instance-name your-server

aws lightsail create-instance-snapshot \ --instance-snaphot-name your-server-new-snapshot-201905192200 --instance-name your-server

Attach Static IP Address

aws lightsail attach-static-ip \
--static-ip-name your-ip-name \
--instance-name your-server

aws lightsail attach-static-ip \ --static-ip-name your-ip-name \ --instance-name your-server

Filed Under: Cloud, Linux Tagged With: attach, aws, cli, instance, lightsail, snapshot, static ip

GCP Attach Detach Disks

December 23, 2018

Google Cloud Platform just recently released a beta feature called detaching and attaching boot disks. Previously, boot disks were permanently attached to their VM instances. Now you have the ability to detach boot disk from your instance and attach it to another instance without deleting the original instance. You can also replace the boot disks for an instance rather than recreating the entire instance. I’ve tested it on my test account, and it works quite nicely.

I have 2 servers called blue-server and red-server. I’m detaching the disks on blue-server and attaching it to the red-server.

gcloud compute instances detach-disk blue-server --disk=blue-server-disk --zone us-central1-c
gcloud compute instances attach-disk cyan-server --disk=blue-server-disk --zone us-central1-c
gcloud compute instances detach-disk cyan-server --disk=blue-server-disk --zone us-central1-c
gcloud compute instances attach-disk blue-server --disk=blue-server-disk --zone us-central1-c

gcloud compute instances detach-disk blue-server --disk=blue-server-disk --zone us-central1-c gcloud compute instances attach-disk cyan-server --disk=blue-server-disk --zone us-central1-c gcloud compute instances detach-disk cyan-server --disk=blue-server-disk --zone us-central1-c gcloud compute instances attach-disk blue-server --disk=blue-server-disk --zone us-central1-c

Results:

GCP: Attach and Detach Disks

This new GCP feature is still beta. There might be a few quirks here and there, but overall, it’s a must have feature if you are managing OS.

Filed Under: Cloud Tagged With: attach, boot, detach, disks, gcp

Attach an EBS Volume to an Instance

October 10, 2018

Attaching an EBS volume to an existing instance is quite easy. You can easily add them via the AWS Console. With just a few clicks, you can add an EBS volume in no time. Just click the Create Volume button, indicate the size of the volume, choose which availability zone (preferably the same AZ where your instance resides), and enable encryption if you decide to do so. You can also add an EBS volume from an existing snapshot.

There are 2 steps to attaching an EBS volume to an existing instance.

Step 1. Attach an EBS volume.

How to attach an EBS to an existing Instance.

Step 2. Make the EBS volume available to your instance whether it’s Linux or Windows. This requires SSH access.

Making an EBS volume available to Linux.
Making an EBS volume available to Windows.

Filed Under: Cloud Tagged With: attach, ebs, instance

  • Home
  • About
  • Archives

Copyright © 2023