resolvconf is not always helpful, especially in a chroot rescue system

Written by - 0 comments

Published on - Listed in Linux


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.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder