Rescue linux from live

  • RescueLive

It is possible to emulate a running system via chroot on a live booted system. The steps primarily include booting a LiveCD and mount file systems AND MOST IMPORTANTLY mount the /etc/resolv.conf into the temporary chroot which resolves DNS (translates human-friendly domain names into the numeric IP addresses that are required for access to resources on the local area network or the Internet or something like that).

Boot into a live system and then drop into a terminal root shell:

List the disk partitions like below:

you can see, here /dev/sda1 is the root partition (where Debian is installed into) and /dev/sda2 is the EFI boot partition. You might have some other partitions too like an extra home partition etc. So now you need to mount those partitions to the running Live session. It can be done by the following way (very similar):

just assume /mnt as new / for now and everything will be fall under /mnt/var, /mnt/tmp, /mnt/home like that. You also need to bind mounts of /dev (device nodes), /proc (process information pseudo-file system), and /sys (kernel objects file system). For that, just issue the following loop:

also for getting your network work inside chroot environment, just mount /etc/resolve.conf into chroot by following way:

now you are almost done and you can access/operate your locally installed system from live cd and make changes to it. For that, just type:

from here, do whatever you want, reinstall packages, DE or somewhat else. After you are done, just upgrade the grub and regenerate initramfs if necessary (most probably you don’t have to).

Источник

System Rescue Homepage

About SystemRescue

Description: SystemRescue (also known as SystemRescueCd) is a Linux system rescue toolkit available as a bootable medium for administrating or repairing your system and data after a crash. It aims to provide an easy way to carry out admin tasks on your computer, such as creating and editing the hard disk partitions. It comes with a lot of Linux system utilities such as GParted, fsarchiver, filesystem tools and basic tools (editors, midnight commander, network tools). It can be used for both Linux and windows computers, and on desktops as well as servers. This rescue system requires no installation as it can be booted from a CD/DVD drive or USB stick, but it can be installed on the hard disk if you wish. The kernel supports all important file systems (ext4, xfs, btrfs, vfat, ntfs), as well as network filesystems such as Samba and NFS.

System and Networking Guides

In addition to the Quick Start Guide and SystemRescue documentation here are other guides:

Project documentation

This project comes with good documentation. Here are the most important pages:

For the impatient:

  • Quick start guide: please read this if this is the first time you are using this system recovery cd.

Chapters about basic usage:

Chapters about advanced usage:

System tools included

  • GNU Parted: creates, resizes, moves, copies partitions, and filesystems (and more).
  • GParted: GUI implementation using the GNU Parted library.
  • FSArchiver: flexible archiver that can be used as both system and data recovery software
  • ddrescue : Attempts to make a copy of a block device that has hardware errors, optionally filling corresponding bad spots in input with user defined pattern in the copy.
  • File systems tools (for Linux and Windows filesystems): format, resize, and debug an existing partition of a hard disk
  • Ntfs3g: enables read/write access to MS Windows NTFS partitions.
  • Test-disk : tool to check and undelete partition, supports reiserfs, ntfs, fat32, ext3/ext4 and many others
  • Memtest: to test the memory of your computer (first thing to test when you have a crash or unexpected problems)
  • Rsync: very-efficient and reliable program that can be used for remote backups.
  • Network tools (Samba, NFS, ping, nslookup, …): to backup your data across the network
Читайте также:  Журнал windows безопасность специальный вход

Browse the short system tools page for more details about the most important software included.

Browse the detailed package list for a full list of the packages.

It is possible to make custom versions of the system. For example, you can add your own scripts, make an automatic restoration of the system. It is also possible to burn a custom DVD, with SystemRescue and 4GB for your data (backup for example). Read the manual for more details.

You can use SystemRescue to backup data from an unbootable Windows computer, if you want to backup the data stored on a Windows computer that cannot boot any more.

It is very easy to install SystemRescue on a USB stick. That is very useful in case you cannot boot from the CD/DVD drive. You just have to copy several files to the stick and run syslinux. The install process can be done from Linux or Windows. Follow instructions from the manual for more details.

More information about this project

SystemRescue sources can be found on GitLab and these are licensed under the GPLv3 license.

Источник

Ubuntu Documentation

This page describes methods for using the Ubuntu Live CD for recovering from different kinds of problems. If you do not have an Ubuntu disk, please refer to GettingUbuntu. If you have any issues booting the LiveCD, please have a look at the BootFromCD page. Most of the methods described below can also be used from RecoveryMode

Lost Password

Here is how you can use the Live CD to change the administrative password on your machine if you have lost/forgot the current password. Please note that you can usually boot into RecoveryMode and run the passwd command directly.

    Boot the Ubuntu Live CD.

sudo mount /dev/sda1 /mnt

If you created a custom partition layout when installing Ubuntu you have to find your root partition using the fdisk utility. See the section Finding your root partition.

You can now use the passwd command to reset a password.

Note: In the mount command, /dev/sda1 will need to be replaced with the partition where the root of the file system resides.

Add User to a Group

If you have removed yourself from a group, you can use the following to add yourself again. Please note that you can usually use RecoveryMode and run the adduser command directly.

    Boot the Ubuntu Live CD.

sudo mount /dev/sda1 /mnt

sudo chroot /mnt

adduser username groupname

Update Failure

If there was an update that made your system non-bootable and they have fixed it in the repositories, you can use the Live CD to run apt-get to get the new files to fix your system.

    Boot the Ubuntu Live CD.

sudo mount /dev/sda1 /mnt

sudo mount —bind /dev /mnt/dev

sudo mount —bind /proc /mnt/proc

sudo mount —bind /sys /mnt/sys

sudo chroot /mnt

If you have trouble accessing your network after chroot, you probably use DHCP and can work around this by adding OpenDNS name servers to your /etc/resolv.conf after you use chroot:

Finding your root partition

If you created a custom partition layout during the Ubuntu installation, your root partition is probably not /dev/sda1 or /dev/sda1. If you do not know which partition corresponds to your root partition you can use the following procedure to find your root partition. We assume you have booted the live cd and are at the terminal.

If you are not using a software raid setup or have setup your partitions using LVM/2 or EVMS your IDE/SATA/SCSI devices should be accessible through the files /dev/hd[a-z] and /dev/sd[a-z]. /dev/hda corresponds to the primary master device on your IDE bus, while /dev/sda is your first SCSI/SATA device. If you are using software raid, LVM, LVM2 or EVMS, your devices may be listed in the following directories:

with their device (software raid) or partition name. You can learn more about Linux partitions here: http://tldp.org/HOWTO/Partition

Now use the fdisk utility to list the partitions on a device. Let’s assume that you installed Ubuntu to the fist IDE disk. Type the following:

This will produce some output like this:

That means you have two standard Linux partitions on your disk: /dev/sda6 and /dev/sda7. You can now try to mount them and see if your Ubuntu installation is there. In this case /dev/sda7 is probably not the root partition, because it is only about 50MiB in size (see the Blocks column). Therefore we mount /dev/sda6:

Читайте также:  Linux с максимальной совместимостью windows

Now show the files on the partition:

If this command shows something like:

it is a partition holding a Linux distribution. You can check if it really is Ubuntu (if you have multiple linux installations on your disk) using the following command:

That will give you some information about the distribution (if this file does not exist, it is probably not Ubuntu). If it is the wrong partition, just unmount it: sudo umount /mnt and try another partition on the same disk or choose a different partition on another disk (using fdisk as before).

Recover Grub 2

Recover Grub

If you install some other system, or change drives and lose your Grub bootloader. For more information please have a look at the Grub page.

    Boot the Ubuntu Live CD.

Press Ctrl-Alt-F1
Find the partition where your /boot directory is (normally the root partition) check the previous tip for that.

sudo mount /dev/sda1 /mnt

sudo chroot /mnt

find /boot/grub/stage1 (will output a partition name like (hd0,3) )

quit

  • Now restart the system and remove the Live CD
  • The GUI Way: Reinstalling Grub

    1. Boot your computer with the Ubuntu CD
    2. Go through the installation process until you reach «[. ] Disk Partition»
    3. Select Manual Partition
    4. Mount your appropriate linux partions:
      • /
      • /boot
      • swap
      • .

    DO NOT FORMAT THEM.

  • Finish the manual partition
  • Say «Yes» when it asks you to save the changes
  • It will give you errors saying that «the system couldn’t install . » after that
  • Ignore them, keep select «continue» until you get back to the Ubuntu installation menu
  • Jump to «Install Grub . «
  • Once it is finished, just restart your computer
  • See also

    LiveCdRecovery (последним исправлял пользователь tsimonq2 2016-03-22 04:04:08)

    The material on this wiki is available under a free license, see Copyright / License for details
    You can contribute to this wiki, see Wiki Guide for details

    Источник

    How to: Chroot into a broken system via live CD/ISO or alternate Linux system

    Occasionally, you may need to rescue a broken/unbootable TurnKey server. Perhaps you have had a hardware failure, or perhaps you’ve inadvertently broken something, or perhaps you’ve installed a buggy update that has broken things?

    Often these issues can be fixed by «chrooting» into the broken system from a functioning (Linux) system, then taking the required steps to resolve the issue (reinstall grub, reinstall a kernel, rebuild an initramfs, etc). Obviously the steps to fix a broken system will depend on what has actually broken. If you’re not sure, then you’re probably best to start a new thread in the forums (requires free website user account to start new thread) so we can assist to diagnose the issue.

    In this doc, I will just advise up until the point where you enter the chroot, and won’t go into the details of how to resolve any specific issue (although, if/when I get a chance, perhaps I’ll write up doc pages for some of the most common issues?!).

    Note: This guide assume that you are logged in with the root user account. If not, most (if not all) the commands run outside the chroot may need to be prefaced by ‘sudo’. If you enter the chroot via sudo, then it should not be required once within the chroot.

    So first up; a little background. If you’d rather just jump straight into setting up the chroot, please feel free.

    What is a «chroot»

    According to Wikipedia, a chroot:

    changes the apparent root directory for the current running process and its children. A program that is run in such a modified environment cannot name (and therefore normally cannot access) files outside the designated directory tree.

    As a Linux user, there are 2 types of chroot you may encounter. What I call a «standard» chroot (what this doc page covers), then there is also a «chroot jail».

    The purpose of a chroot jail to to lock a user or process within a certain part of a directory tree. E.g. a program may be «chrooted» into it’s own directory (Postfix is set up like this for example), with no access to the rest of the filesystem. Or a limited user may be «chrooted» into their home directory, so they can use (for example) SFTP, but cannot browse the whole filesystem.

    A «standard» chroot can be used to investigate and possibly repair a unbootable system. It is also commonly used to build new Linux systems. For example, TurnKey uses a «standard» chroot (on TKLDev) to build the TurnKey appliances. That is the sort of chroot I’ll document here.

    Setting up a chroot

    Preparation

    The first thing to do is to ensure that the filesystem of the broken system is accessible from the working system. In the case of a bare metal install or a VM, the easiest way to do this is often to just boot from a Live CD/USB/ISO. As a general rule, it’s usually best to use the same OS as what the broken system is. In the case of TurnKey, you can use Core (or any other server; just Core is the smallest) of the same major version. E.g. v15.0 Core is fine to use to fix any v15.x appliance. If that’s not an option, a Debian Live system is also a good option. Worst case scenario, you could get away with any relatively recent Linux distro, although TurnKey (or Debian) of a matching version is preferable.

    Whatever you do DO NOT install over the top of your broken system! That will make it unrecoverable!

    Alternatively, you could move the disk (physical or virtual) to another (working) machine (with TurnKey/Debian/etc as above running). For an AWS server that is also essentially what you’ll need to do (i.e. detach the primary volume from the broken system and reattach to a working system).

    Finding the right volume to mount

    After you’ve attached the broken primary volume to a working system, the next step is to mount it. To mount it, you’ll need to ensure that you have a clean mount location and you’ll also need to work out which disk/volume/partition(s) you need to mount.

    One easy way to ensure that you have a clean mount location to use, is to create it! So something like this:

    Ensuring that you find the correct drive/volume/partition(s) can be a little trickier, but one tool you can use is fdisk. To view all attached volumes, run:

    Here is the output on an AWS server I’m currently working on. It has a secondary drive (the root volume of another server) attached as /dev/xvdf, the default root volume (i.e. the root volume of the working server) is /dev/xvda. That may be different for you (although if you’re on AWS is likely the same). Here is the full output:

    If you are unsure which volume is the one, check which volumes are already mounted. Do that like this:

    That will check for all lines from the mount output that start with /dev. In my case, this confirms what I know already, the voume I already have mounted is /dev/xvda:

    Mounting the broken system ready to chroot

    So once you’ve worked out which partition you’ll need to mount it. That’s pretty simple. In my case, the partition that I need to mount is /dev/xvdf2 (i.e. the second partition on /dev/xvf). If you look above, at my output from fdisk, you’ll see that /dev/xvdf1 is type «BIOS boot» and /dev/xvdf2 is «Linux filesystem». To mount that is as easy as this:

    If you now check in /rescue (i.e. ls /rescue), you should see something like this:

    Obviously the dates will be different, but otherwise, that shows that the system is mounted as expected. All current builds of TurnKey include the /boot partition, although in some older releases, if the install used LVM, then the /boot partition may need to be mounted separately. In that case, after the main OS is mounted, mount the boot directory. I.e. something like this (adjust to suit):

    Where /dev/sdXN is the partition where the boot info resides.

    But wait there’s more. Once the main OS has been mounted, you then also need to mount some special directories from the host so that the chroot will function properly. Primarily these are /dev, /proc and /sys. /dev/pts is also worth mounting too. In my experience, you can get away without mounting that, but you will often get errors, so it’s worth mounting that to reduce the noise.

    Chrooting in

    Now you simply need to chroot in. That’s done like this:

    Now do whatever you need to do to fix your system. Once you are happy (or just ready to test) then you can exit the chroot like this:

    Источник

    Читайте также:  Windows logon sound windows 10
    Оцените статью