2

I have already installed gparted because I want resize some partitions on a box running centos 7 minimal. So I can ssh into the box and only have access to the terminal.

I run the command gaprted to try and start it but it says:

(gpartedbin:23033): Gtk-WARNING **: cannot open display:

How can I start gparted so the actaully GUI will appear so I can resize partitions through the GUI??

Joey Corkey
  • 133
  • 1
  • 5

3 Answers3

3

The 'g' indicates that it would be a "GNOME" based partition editor.. that would need a graphical environment

"parted" would be an equivalent command line version of that. Look into that command.

While we're on the subject of resizing partitions, I might suggest looking into LVM.

Erik
  • 160
  • 4
3

If you've installed gparted using a package manager, it has pulled any necessary X11 and GNOME libraries along with it as dependencies. You may need to install the xauth package separately.

So, if you want to use gparted GUI, you'll need to have a X11 server running on the system that has your physical display, keyboard and mouse, and then establish a SSH connection with X11 forwarding enabled. This will allow gparted to send its GUI back along the SSH connection to your local system, where the X11 server will draw it onto your local display.

For Windows, VcXsrv is a reasonably up-to-date free X11 server software that is fairly easy to install. For use with SSH X11 forwarding, you don't typically have to configure it in any way: just make sure it's started before you start your SSH client, and make sure X11 forwarding has been enabled in your SSH client options.

The first time you establish a SSH connection with X11 forwarding, there should be a message like:

/usr/bin/xauth:  file /root/.Xauthority does not exist

This indicates sshd at the remote host is using xauth to prepare the connection, but since this is the first time, the .Xauthority file in your home directory won't exist yet. This is normally just an informational message: the xauth tool will automatically create the file if it does not exist.

In order to modify partitions using a X11 GUI tool, you'll need root permissions, so it will be simplest if you can log in directly as root. If that is not possible, you can log in as some other user, run echo $DISPLAY to view the value of the DISPLAY environment variable, then switch to root user and make sure the DISPLAY variable is still set to the same value (re-set it if necessary). You will also need to set the XAUTHORITYenvironment variable to point to the .Xauthority file in your original home directory, i.e. something like

export XAUTHORITY=/home/<username>/.Xauthority
telcoM
  • 4,153
  • 12
  • 23
  • If you insist on using a GUI, this a good way of achieving that. My pro-CLI bigotry prevented me from seeing this solution :) – Erik Dec 15 '17 at 15:53
  • 2
    Personally I would definitely use CLI too... but as the original poster had already installed `gparted`, most of the pieces required at the server side were already in place. And for a possible newbie, this was a way to introduce the X11 concept of "you don't have to have any active GUI service processes on the server to use GUI programs remotely". – telcoM Dec 15 '17 at 16:24
  • Thank you indeed! You saved my day. Though I am a CLI person myself, a GUI is helpful now and then. Plus I was looking for a simple way to open GUI-based applications on my linux VMs through my Windows display since quite some time. Who knew I would stumble on it in such an unexpected place? – alwayslearning Aug 31 '20 at 20:25
  • 1
    @alwayslearning The X11 way of using applications remotely is so different from the (possibly more familiar) VNC/RDP-style solutions that figuring out the right question to ask can be difficult. Seeing a bare-bones example can be helpful. – telcoM Sep 01 '20 at 09:58
0

Use parted (sudo parted) instead.

You can use gaprted only with GUI.

Command reference here.

Overmind
  • 2,970
  • 2
  • 15
  • 24