With a Rescue ISO/DVD you can fix or salvage your machine from a system failure. It’s more common to fix a hard drive that is serving /boot or /, or resize root LVM.

Grub Options

  1. Boot into your Rescue ISO/DVD.
  2. Select Troubleshooting.
  3. Highlight Rescue a Rocky Linux System.
  4. Press e to get the grub options, and append inst.sshd=1 and ip=dhcp.
  5. Then press Ctrl+x to the start.
  • On the rescue environment menu choose one that’s appropriate to your situation.
  • Continue will mount the / filesystem under the directory specified, usually mnt/sysroot or /mnt/sysimage(the same directory I recommended you use if you have to run chroot)
  • Skip to shell if you don’t want to mount the / filesystem and prefer to do things your own way in a shell(that’s what I did).

Once you get a shell, run ip a s to view your IP, and SSH into the machine as root with an empty password:

[anaconda root@localhost ~]# df -hT
Filesystem          Type      Size  Used Avail Use% Mounted on
devtmpfs            devtmpfs  432M     0  432M   0% /dev
tmpfs               tmpfs     472M   12K  472M   1% /dev/shm
tmpfs               tmpfs     472M   25M  447M   6% /run
tmpfs               tmpfs     472M     0  472M   0% /sys/fs/cgroup
/dev/sr0            iso9660   1.9G  1.9G     0 100% /run/install/repo
/dev/mapper/live-rw ext4      2.9G  2.2G  711M  76% /
tmpfs               tmpfs     512M  1.2M  511M   1% /tmp
[anaconda root@localhost ~]#

The live image is mounted on /.

Configure SSH and an IP Address manually

Once you get a shell, configure the IP and ping your gateway to test connectivity:

# View IP info and Network Device
ip link 

# Set an IP to the device shown above
ip a add 192.168.100.120/24 dev ens33 

# Set your gateway
ip route add default via 192.168.100.1 

# Verify the Changes
ip link; ip route 

# Test Connectivity
ping 192.168.100.1 -c 5 

For SSH

Find the configuration file:

[anaconda root@localhost ~]# find / -name "*sshd_config*"
/etc/ssh/sshd_config.anaconda
[anaconda root@localhost ~]#
[anaconda root@localhost ~]# cat /etc/ssh/sshd_config.anaconda
PermitRootLogin yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd yes
SyslogFacility AUTHPRIV
PasswordAuthentication yes
PermitEmptyPasswords yes
PermitUserEnvironment yes

You can change the options according to your needs. Make a copy of the configuration file to something that SSH can read and start SSH:

cp /etc/ssh/sshd_config.anaconda /etc/ssh/sshd_config
systemctl start sshd

Once done, ssh into the machine:

[anaconda root@localhost ~]# df -hT
Filesystem          Type      Size  Used Avail Use% Mounted on
devtmpfs            devtmpfs  432M     0  432M   0% /dev
tmpfs               tmpfs     472M   12K  472M   1% /dev/shm
tmpfs               tmpfs     472M   13M  459M   3% /run
tmpfs               tmpfs     472M     0  472M   0% /sys/fs/cgroup
/dev/sr0            iso9660   1.9G  1.9G     0 100% /run/install/repo
/dev/mapper/live-rw ext4      2.9G  2.2G  711M  76% /
tmpfs               tmpfs     512M  1.4M  511M   1% /tmp

Mount LVM and Chroot

If your partitions or filesystems are managed by LVM, you’ll have to activate it first:

[anaconda root@localhost ~]# pvs
  PV         VG Fmt  Attr PSize  PFree
  /dev/sda3  rl lvm2 a--  18.41g    0
[anaconda root@localhost ~]#
[anaconda root@localhost ~]# vgs
  VG #PV #LV #SN Attr   VSize  VFree
  rl   1   2   0 wz--n- 18.41g    0
[anaconda root@localhost ~]#
[anaconda root@localhost ~]# lvs
  LV   VG Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root rl -wi------- 16.41g
  swap rl -wi-------  2.00g
[anaconda root@localhost ~]#
[anaconda root@localhost ~]# vgchange -ay
  2 logical volume(s) in volume group "rl" now active

Mount root filesystem on /mnt/sysimage:

[anaconda root@localhost ~]# mount /dev/mapper/rl-root /mnt/sysimage/
[anaconda root@localhost ~]#
[anaconda root@localhost ~]# ls /mnt/sysimage/
bin   dev  home  lib64	mnt  proc  run	 srv  tmp  var
boot  etc  lib	 media	opt  root  sbin  sys  usr

Mount /dev, /dev/shm, /usr, /sys, and /proc:

[anaconda root@localhost ~]# for i in dev usr sys dev/shm; do mount -o bind /$i /mnt/sysimage/$i; done
[anaconda root@localhost ~]#
[anaconda root@localhost ~]# mount -t proc /proc /mnt/sysimage/proc
[anaconda root@localhost ~]#
[anaconda root@localhost ~]# mount | grep sysimage
/dev/mapper/rl-root on /mnt/sysimage type xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)
devtmpfs on /mnt/sysimage/dev type devtmpfs (rw,nosuid,seclabel,size=442124k,nr_inodes=110531,mode=755)
/dev/mapper/live-rw on /mnt/sysimage/usr type ext4 (rw,relatime,seclabel)
sysfs on /mnt/sysimage/sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
tmpfs on /mnt/sysimage/dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
/proc on /mnt/sysimage/proc type proc (rw,relatime)

Mount /boot and /boot/EFI(if you’re using MBR, just mount /boot):

[anaconda root@localhost ~]# mount /dev/sda2 /mnt/sysimage/boot/
[anaconda root@localhost ~]# mount /dev/sda1 /mnt/sysimage/boot/efi/

Change root filesystem to /mnt/sysimage:

[anaconda root@localhost ~]# chroot /mnt/sysimage/
[anaconda root@localhost /]#
[anaconda root@localhost /]# df -hT
Filesystem          Type      Size  Used Avail Use% Mounted on
/dev/mapper/rl-root xfs        17G  2.3G   15G  14% /
devtmpfs            devtmpfs  432M     0  432M   0% /dev
/dev/mapper/live-rw ext4      2.9G  2.2G  709M  76% /usr
tmpfs               tmpfs     472M   12K  472M   1% /dev/shm
/dev/sda2           xfs      1014M  236M  779M  24% /boot
/dev/sda1           vfat      599M  5.8M  594M   1% /boot/efi

To reboot, type exit and press enter in your main terminal(not over ssh).

“The person, be it gentleman or lady, who has not pleasure in a good novel, must be intolerably stupid.”Jane Austen, Northanger Abbey