Something is wrong with my RHEL networking configuration so I booted using my ISPs remote rescue kernel mode to fix my system. How do I mount and chroot into actual installation to fix the problem? How do I boot from any Live Linux CD and chroot into /dev/sda1 or /dev/md0 to fix the problem or recover the data?

Once booted into rescue kernel or using Live Linux CD you need to verify that your disks are detected. Type the following command to verify the same:
# fdisk -l
Next, create a directory to chroot and mount existing partitions:
# mkdir /chroot
# d=/chroot

Mount actual partition:
# mount /dev/sda1 $d
Mount /proc and other file system inside $d, enter:
# mount -o bind /dev $d/dev
# mount -o bind /sys $d/sys
# mount -o bind /dev/shm $d/dev/shm
# mount -o bind /proc $d/proc

Chroot and access your data:
# chroot $d
# df
# ls
# vi /etc/somefile

Exit and reboot the system:
# exit
# umount $d/proc
# umount $d/sys
# umount $d/dev/shm
# umount $d/dev
# umount /dev/sda1

Advertisement

A Note About Multiple /boot, /home, /tmp Partitions

Cosinder the following parition layout for /dev/sda

  • / – /dev/sda1
  • /boot – /dev/sda2
  • /home – /dev/sda3
  • /tmp – /dev/sda4

To mount all at /chroot, enter:
# d=/chroot
# mkdir $d
# mount /dev/sda1 $d
# mount -o bind /dev $d/dev
# mount -o bind /sys $d/sys
# mount -o bind /dev/shm $d/dev/shm
# mount -o bind /proc $d/proc
# mount /dev/sda2 $d/boot
# mount /dev/sda3 $d/home
# mount /dev/sda4 $d/tmp
# chroot $d

A Note About /dev/md0 (Software RAID)

Type the following command to mount /dev/md0 at /chroot/data (/dev/sda1 at /chroot):
# d=/chroot
# mkdir $d
# mount /dev/sda1 $d
# mount -o bind /dev $d/dev
# mount -o bind /sys $d/sys
# mount -o bind /dev/shm $d/dev/shm
# mount -o bind /proc $d/proc
# mount /dev/md0 $d/data
# chroot $d
# ls
# df

Now you can access software RAID too.

How Do I Recover Data?

Once /dev/md0 or /dev/sda1 mounted simply copy data using scp / rsync or external usb pen / hard disks.

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

3 comments… add one
  • Thomas Jun 24, 2010 @ 10:47

    Mounting of the directories via the bind option should be done AFTER mounting the partition on $d. Otherwise they are made invisible.

    • 🛡️ Vivek Gite (Author and Admin) nixCraft Jun 24, 2010 @ 10:55

      Thanks for the heads up!

  • Ram Mar 5, 2012 @ 6:59

    Thank you so much for your help. This is one of the many times your web site has saved me hours of headaches! So thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.