Why can’t grub find the disk by UUID?

I’m trying to troubleshoot why I can’t boot to Windows.

The relevant entry in grub.cfg is:

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Boot Manager (on /dev/sda3)' --class windows --class os $menuentry_id_option 'osprober-efi-BC6E-0415' {
        insmod part_gpt
        insmod fat
        set root='hd0,gpt3'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  BC6E-0415
        else
          search --no-floppy --fs-uuid --set=root BC6E-0415
        fi
        chainloader /efi/Microsoft/Boot/bootmgfw.efi
}

Best I can tell, everything here is correct:
/dev/disk/by-uuid/BC6E-0415 is indeed the Windows boot manager partition.

However I’m slightly confused by the references to (hd0,gpt3) because that’s a completely different partition on a completely different physical disk. hd0 is the disk on which grub is installed though, in case that’s relevant.

The actual error I get when I try and boot Windows is:

error: no such device: BC6E-0415
error: file `/efi/Microsoft/Boot/bootmgfw.efi' not found

I do notice that in grub, if I drop to a grub command prompt and do an ls, the only hard disk I see listed is hd0 when my system actually has 4 hard disks. As I mentioned above, hd0 is the hard disk that has grub and my Linux installs.

So I think my question might be: why, when I boot to grub, can’t grub see any hard disks besides the one grub is on?

If I boot into Linux (Ubuntu 20.04.1) I can see all my hard disks just fine.

Go to Source
Author: Bridgey

mysql client auto reconnect in case of ERROR 2013

I’m searching for a way how to instruct mysql client to reconnect in case of ERROR 2013. I’m testing PXC with ProxySQL and want to keep sql statements flowing from the client in case when the writer node get killed and new one is promoted. Is it possible for mysql client to reconnect when server goes down during the query? Can mysql client rerun the sql query (insert, update, …)? With Sysbench it is possible if setting the –mysql-ignore-errors=all parameter.

Go to Source
Author: Sevak

How to count spaces in text?

In the following example, there are 4 spaces before inet.

wolf@linux:~$ ip address show eth0 | grep 'inet '
    inet 10.10.10.10/24 brd 10.10.10.255 scope global dynamic eth0
wolf@linux:~$ 

How do I count the number of spaces like this example.

This sample is easy as it only has 4 spaces.

What if it has more than that? Hundreds, thousands?

Is there an easy way to do this?

Go to Source
Author: Wolf

Deployment of Docker containers on ECS(Tcp Server Java)

The given problem:

  • Created a Java Tcp Server with Eclipse vertx(Toolkit for building
    reactive,event driven)applications on JVM. The applicatino has two
    Tcp Servers which are running on port numbers:
    server1(port:5050);server2(5051)

  • I created a Docker image and was running the application inside a
    container and all works fine locally.

  • I want to deploy the docker container on ECS(Amazon Container
    Service) and to use Network Load balancer,the question is how can i
    assign different ports to different containers if in the Java code i
    was setting up explicity

//tcp server 1 listens on port 5050

server..listen(5050)
  • and how does ECS manages what ports to assign to what container?

    The tcp client is always targeting one ip adress and one port number
    it cannot be changed.

    Thanks!

Go to Source
Author: user581026

Refactor unit tests?

When we work with legacy code and need to do changes, we first write tests on the current behavior. That way we can implement new changes with confidence. We can even refactor the code.

Legacy code is often bad code, and after some refactoring the code may be simpler, easier to test. Since the refactor has been validated by the tests should we also refactor the tests if we can make them simpler/clearer or keep them as they were written?

Go to Source
Author: JayZ

Deleting child record doesn’t delete foreign key reference

I am using postgreSQL 10.7. I have this strange occurrence where I fail to see the problem.
Whenever I delete all child-records referring to a parent, somehow the reference between these two tables persists.

I have a child and parent table:

CREATE TABLE IF NOT EXISTS parent
(
    ID SERIAL NOT NULL CONSTRAINT PK_parent PRIMARY KEY,
    reference VARCHAR(100) NOT NULL
);

CREATE TABLE IF NOT EXISTS child
(
    ID SERIAL NOT NULL CONSTRAINT PK_child PRIMARY KEY,
    parentID INT NOT NULL,
);

ALTER TABLE child
ADD CONSTRAINT FK_child_parent_ID FOREIGN KEY (parentID) REFERENCES parent (ID) MATCH FULL;

I delete all the records from the child table referring to the parent:

DELETE FROM child WHERE parentID = 1;

I select all the records from the child table referring to the parent:

SELECT * FROM child WHERE parentID = 1; // 0 records returned

I try to delete the parent record from the parent table

DELETE FROM parent WHERE ID = 1;

// result
ERROR: update or delete on table "parent" violates foreign key constraint "fk_child_parent_id" on table "child" Detail: Key (id)=(1) is still referenced from table "child".

I know about the ON DELETE option on the FOREIGN KEY constraint, but I just want to do this once…

What do I fail to see?

Go to Source
Author: leon de vries

Why .deb packages never add desktop and start menu shortcuts, even if installed software is graphical UI only?

Sorry if it’s a lame question but why installing software from .deb package never seems to add any shortcuts to desktop and start menu, even if installed software is a graphical UI program?

For example, try installing Chrome on fresh Ubuntu 20.20. You go to official chrome page where it will point you to the latest .deb package. Great. You download and install the package. Perfect. But then what?

No shortcut on desktop, no icon in start menu and -if you happened to close the package installer window – you even have no clue where the software was installed.

Is this fundamentally impossible due to some technical limitations of the package manager or is it just laziness of package creators which don’t care about auto creating those launcher shortcuts on desktop?

I’ve just installed new Ubuntu, installed Chrome and was puzzled how counter-intuitive and user-unfriendly the whole process is. I had to 1) find where the stuff from .deb was physically installed 2) create launcher manually 3) assign an icon to the shortcut manually.

Go to Source
Author: PawelRoman

Cannot start GUI applications “Error: cannot open display: :0”

I am getting this error when trying to launch Thunderbird (or any other program, such as evince):

❯ thunderbird
Unable to init server: Unable to create socket: Permission denied
Error: cannot open display: :0

❯ thunderbird -v
Thunderbird 68.10.0

Any ideas?

❯ cat /etc/linuxmint/info
RELEASE=20
CODENAME=ulyana
EDITION="Cinnamon"
DESCRIPTION="Linux Mint 20 Ulyana"
DESKTOP=Gnome
TOOLKIT=GTK
NEW_FEATURES_URL=https://www.linuxmint.com/rel_ulyana_cinnamon_whatsnew.php
RELEASE_NOTES_URL=https://www.linuxmint.com/rel_ulyana_cinnamon.php
USER_GUIDE_URL=https://www.linuxmint.com/documentation.php
GRUB_TITLE=Linux Mint 20 Cinnamon

Go to Source
Author: Philippe Massicotte

RDS Monitoring using PMM2, Missing Host Metrics for Postgres

I am using PMM2 for monitoring all my RDS instances.

I added Postgres as a remote database, But by adding a database as remote in PMM2 we miss host-level metrics like CPU, Memory etc. What is the recommended way of adding Postgres (RDS) or a way to inject missing metrics to get the complete Node Summary?

Go to Source
Author: xrage

What term describes a list of exactly length 1?

A container having 2 or more elements could be called a “plural container”. A container with no elements could be called an “empty container”.

But what is the terminology for a container whose current size is exactly 1 element?

I would use the term “unary” but that refers to operators that take exactly 1 argument.

The reason I would like a term for this is that I am writing a boolean method to check if two data structures are both of size exactly one and I want a good name for the method. Currently I have:

def length_is_1(self, x, y):
    return len(x) == 1 and len(y) == 1

Go to Source
Author: Terrence Brannon

Minify HTML with voku / HtmlMin?

I want use voku/HtmlMin in wordpress functions.php, i install composerr in theme folder and i use code:

class WP_HTML_Compression

{
    // Settings
    protected $compress_css = true;
    protected $compress_js = true;
    protected $info_comment = true;
    protected $remove_comments = true;

    // Variables
    protected $html;

    public function __construct($html) 
    {

        if (!empty($html)) {
         $this->parseHTML($html);
        }
    }

    public function __toString()
    {
        return $this->html;
    }

    protected function bottomComment($raw, $compressed)
    {
        $raw = strlen($raw);
        $compressed = strlen($compressed);

        $savings = ($raw-$compressed) / $raw * 100;

        $savings = round($savings, 2);

        return '<!--HTML compressed, size saved '.$savings.'%. From '.$raw.' bytes, now '.$compressed.' bytes-->';
    }

    protected function minifyHTML($html)
    {
      require('vendor/autoload.php');
    $htmlMin = new vokuhelperHtmlMin();

        return $htmlMin->doRemoveComments->doSortCssClassNames()->doSortHtmlAttributes()->minify($html);

      
    $htmlMin = vokuhelperHtmlMin;
        $htmlMin = new HtmlMin();
      
    }

    public function parseHTML($html)
    {
        $this->html = $this->minifyHTML($html);

        if ($this->info_comment) {
            $this->html .= "n" . $this->bottomComment($html, $this->html);
        }
    }

    protected function removeWhiteSpace($str)
    {
        $str = str_replace("t", ' ', $str);
        $str = str_replace("n",  '', $str);
        $str = str_replace("r",  '', $str);

        while (stristr($str, '  ')) {
            $str = str_replace('  ', ' ', $str);
        }

        return $str;
    }
}

function wp_html_compression_finish($html) {
    return new WP_HTML_Compression($html);
}

function wp_html_compression_start() {
    ob_start('wp_html_compression_finish');
}
add_action('get_header', 'wp_html_compression_start');

but it’s not work. How add voku/htmlmin correct?

Go to Source
Author: johm

How to iterate over array indices in zsh?

In bash we can iterate over index of an array like this

~$ for i in "${!test[@]}"; do echo $i; done

where test is an array, say,

~$ test=(a "b c d" e f)

so that the output looks like

a
b c d
e
f

However, when I do the same in zsh I get an error:

➜ ~ for i in "${!test[@]}"; do echo $i; done
zsh: event not found: test[@]

What is going on?

What is the proper way of iterating over indices in zsh?

Go to Source
Author: Gao Zheng

vncserver not opening port

I have been trying to get my vncserver fixed, it seems that I broke something when I was trying to get it working with the ubuntu gnome desktop, basically, I’m pretty new to linux and I no longer know what I did but I had someone with more experience look into it and they couldn’t figure it out either.
The issue is that the vncserver runs and the ports appear to be open on the linux machine to which I only have access via ssh, but when I try to access those ports from another machine or even scan the server (its local) for open ports the only ones I get are the ssh and port 80 for nginx.
I’ve tried resetting the vncserver several times and I’ve also ensured that the firewall wasnt blocking them.

Go to Source
Author: Vlad Duh

Failing ZFS Raid-Z2, need to build new pool but lack a SAS port. Can I disconnect one drive from Raid-Z2?

I have a Raid-Z2 pool with 6 * 4TB drives. All the drives have a bit over 40 000 hours running time. Now they all seem to be degrading at the same time. The pool is degraded, and all drives are marked as degraded with to many errors. But luckily no lost data at the moment.

        NAME        STATE     READ WRITE CKSUM
        File        DEGRADED     0     0     0
          raidz2-0  DEGRADED     0     0     0
            sda     DEGRADED     0     0     0  too many errors
            sdb     DEGRADED     0     0     0  too many errors
            sdc     DEGRADED     0     0     0  too many errors
            sdd     DEGRADED     0     0     0  too many errors
            sde     DEGRADED     0     0     0  too many errors
            sdf     DEGRADED     0     0     0  too many errors

I would like to build a new pool with Raid-Z1 and 3 * 6TB drives as I don’t need all the space as in the original pool. My problem is that the old pool has 6 drives and my pool will have 3, but my SAS controller only has 8 ports. So I would like to disconnect one disk from my Raid-Z2 pool, connect my 3 new drives and create a new pool with them and then save my data by copying to the new pool before the old pool fails.

Is that possible? My thinking is that the old pool should work with one disk missing. But when I tried disconnecting a disk I’m unable to access any data in the old pool.

Anyone know how to solve this?

Go to Source
Author: Northern Brewer