chroot in linux

Chroot is a very useful feature in Linux systems: you can update a Linux installation on your PC not within that installation, as usually we can do, but from another installation.

I.g. if you have Linux1 on /dev/sda2 and Linux2 on /dev/sda3 and you cannot login into Linux2, you can try to solve the problem by doing an update of Linux2 from Linux1. Using chroot.

There are very good guides on the web, but, let us repeat the essential steps

  • first of all be sure of the correct name of the partition you want chroot in (i.g. /dev/sda3, or /dev/sdb2)
  • create a /mnt where you will mount that installation, i.g. /mnt/chroot
  • mount that installation in /mnt/chroot: sudo mount -t ext4 /dev/sda3 /mnt/chroot (note that etx4 is if that is the filesystem, but it could be btrfs as well or another filesystem)
  • mount efi partion (if you have efi): sudo mount -t vfat /dev/sda1 /mnt/chroot/boot/efi/
  • mount virtual folders of that installation: for i in dev proc sys run; do sudo mount --bind /$i /mnt/chroot/$i; done
  • Do the chroot: sudo chroot /mnt/chroot

What you do now, within the terminal where you did the chroot is what you could do if you were in that installation (Linux2).
Typically you should do these commands

  • apt update (without sudo before apt: you are already acting as superuser)
  • apt upgrade (or apt full-upgrade)
  • update-grub

Afterwards you can exit with:

  • for i in /dev /proc /sys /run /; do sudo umount -l /mnt/chroot/$i; done
  • and: sudo umount /dev/sda2 /mnt/chroot/boot/efi/
  • and: sudo umount /dev/sda3 /mnt(chroot

Note that these last two commands could be not necessary.

monitor hdmi never sleeping

It’s a known bug in Linux: when a monitor is connected with an hdmi cable, there are “sleeping” problems (monitor not sleeping as expected or sleeping but with annoying error/crash messages).

While we expect an hardware solution, a scripting workaround could be this code

bash -c 'sleep 0.1 && xset dpms force off'

Linux KDE: add an app to the panel (no pin it)

To have an application (a program, such as Firefox, or Thunderbird) in your KDE desktop bottom bar, not as “pinned”, but as an icon, you can a) add to desktop that app, and then b) copy it (with the mouse) into the left part of the bottom bar (not in Icon only task manager, but at its left).

See TV channels from Decoder to Smartphone

With a Linux decoder such as Octagon (with Openatv e Kodi) you can see your TV on your smartphone. Provided that you have Kodi both on decoder and on smartphone.

  • Both decoder and smartphone should be under the same network (such as samba).
  • Install on your smartphone Kodi app,
  • in Kodi install a PVR client such as enigma2,
  • configure the correct IP of your decoder (something like 192.168.1.166) and your decoder Kodi credentials.
  • You should be able to see your TV, as in the following image

    kodi

clone an installation with DD

Today I managed to clone a mounted linux installation with DD. This was the code:

 dd if=/dev/sdb3  of=/dev/sdb2 

/dev/sdb2 was mounted, but I let it inactive. In this way I got a perfecft and working clone of my first operative system. Of course I had to

  • fix a problem in the new partition (with GParted: check and fix partition): I noticed that fstab was not recognized as text file, i.g..
  • change /etc/fstab according to the UUID of the new installation (UUID of /dev/sdb2 is different from UUID of /dev/sdb3, as I saw in GParted)

Maybe I was very lucky. I’m not saying that you should follow my example: the best thing is to work on unmounted partitions.

upgrade problem with chroot

If you have to re-sume an interrupted upgrade in a KDE-Neon installation, and the only possible way is to use chroot, it could happen that you cannot use pkcon update (nor apt update).

In this case you could try with apt full-upgrade

I tried it successfully (2024-08-23).

Flatpack and the space of the hard disk

Flatpack has the big advantage that you can a) run apps that couldn’t run the “normal” way (integrated with the system), because of lack of dependencies or b) have automatic updates of apps otherwise upgradable only via ppa or manually.

But its big disadvantage is the space occupied on your hard disk: indeed any app in Flatpack is a “world” in itself, regardless not only of the system, but also other apps in Flatpack itself.

Therefore, be careful to add Flatpack apps, unless you need really them (and them via Flatpack).

unblock linux update (attempted overwriting)

If an update is blocked because of an attempted overwriting problem, you can try to solve this problem by this code:

sudo dpkg -i --force-overwrite /var/cache/apt/ar
chives/your-package.deb

where your package could be something like libpipewire-0.3-modules_1.0.7-3~ubuntu22.04_amd64.deb

Fast pre-boot

If your pre-boot (when you can choose among different SO) is too slow, you can reduce the time before the start of boot, modifying the file grub (in /etc/default), adding a line like this:

GRUB_RECORDFAIL_TIMEOUT=1

Indeed GRUB_TIMEOUT=0 could not work.