Header RSS Feed
 
If you only want to see the articles of a certain category, please click on the desired category below:
ALL Android Backup BSD Database Hacks Hardware Internet Linux Mail MySQL Monitoring Network Personal PHP Proxy Shell Solaris Unix Virtualization VMware Windows Wyse

resolvconf is not always helpful, especially in a chroot rescue system
Wednesday - Feb 22nd 2017 - by - (0 comments)

Yesterday I needed to completely re-partition a server (going from 12 separate partitions on /dev/sda to a two-disk setup with LVM). In order to have ensure data-integrity I booted from a live CD (Knoppix), mounted the old partitions inside /mnt and mounted the new (target) partitions in /mnt2.

The mounts inside /mnt2 looked the following:

/dev/sda1 /mnt2
/dev/mapper/vgsystem-lvvar /mnt2/var
/dev/mapper/vgsystem-lvtmp /mnt2/tmp
/dev/mapper/vgdata-lvdb /mnt2/db
/dev/mapper/vgdata-lvwww /mnt2/www

Once I synced /mnt to /mnt2, I mounted procfs, sysfs and dev into /mnt2:

mount --bind /dev /mnt2/dev
mount --bind /proc /mnt2/proc
mount --bind /sys /mnt2/sys

And then went into the "new system":

chroot /mnt2 /bin/bash

I adapted /etc/fstab to have the new UUID's of the real partitions and the logical volumes pointing to the correct mount points. And then I knew I had to create a new initramfs because I now use LVM. But none of the lvm commands worked, because lvm2 was not installed. So I configured the network card and wanted to run apt-get install lvm2 but got errors from apt that the dns resolution didn't work.

I checked /etc/resolv.conf and it was a symlink:

/etc/resolv.conf -> ../run/resolvconf/resolv.conf

Of course ../run was empty. And even when I added it with yet another bind mount inside /mnt2, the resolvconf folder didn't exist of course (/run was mounted from the Knoppix live image and resolvconf inside chroot wasn't started).

Because my maintenance window narrowed, I deleted the symlink and simply created a plain simple /etc/resolv.conf with a nameserver entry. With that change I was finally able to run apt-get install lvm2. Once this package was installed, it automatically updated the initramfs. Well, thanks! Note: I would have run "update-initramfs -u" if apt didn't do it automatically.

The only thing left was to update the GRUB bootloader:

update-grub

This generated the new grub config file in /boot/grub/grub.cfg. And then install the bootloader itself on the new OS disk:

grub-install /dev/sdb

TL;DR: resolvconf package may be helpful in a "normal" start of the OS, but when doing some maintenance tasks as I did (in a rescue or repair mode) then a classic and static /etc/resolv.conf file does the job better because it does not depend on another script (resolvconf).

 

Add a comment

Show form to leave a comment

Comments (newest first):

No comments yet.

Go to Homepage home
Linux Howtos how to's
Monitoring Plugins monitoring plugins
Links links

Valid HTML 4.01 Transitional
Valid CSS!
[Valid RSS]

7576 Days
until Death of Computers
Why?