# Why does gpart not work for me



## dalpets (Sep 12, 2019)

When I use these 3 commands I get no response. Help please

```
*** Fatal error: open(show): No such file or directory.
[root@FreeBSD /home/brenton]# gpart show

*** Fatal error: open(show): No such file or directory.
[root@FreeBSD /]# gpart show

[root@FreeBSD /]# gpart show -l -v -p
Usage: gpart [options] device
Options: [-b <backup MBR>][-C c,h,s][-c][-d][-E][-e][-f][-g][-h][-i]
[-K <last sector>][-k <# of sectors>][-L][-l <log file>]
[-n <increment>][-q][-s <sector-size>][-t <module-name>]
[-V][-v][-W <device>][-w <module-name,weight>]
gpart v0.1h (c) 1999-2001 Michail Brzitwa <michail@brzitwa.de>.
Guess PC-type hard disk partitions.
```


----------



## yuripv (Sep 12, 2019)

dalpets said:


> gpart v0.1h (c) 1999-2001 Michail Brzitwa <michail@brzitwa.de>.



This is NOT correct `gpart` for sure.  What does `which gpart` return?


----------



## olli@ (Sep 12, 2019)

Use `/sbin/gpart`.
Obviously you have installed sysutils/gpart, and /usr/local/sbin precedes /sbin in your `$PATH`. That's not a good idea; /usr/local/{bin,sbin} should be last.


----------



## dalpets (Sep 12, 2019)

yuripv said:


> This is NOT correct `gpart` for sure.  What does `which gpart` return?


$ which gpart
/usr/local/sbin/gpart


----------



## dalpets (Sep 12, 2019)

olli@ said:


> Use `/sbin/gpart`.
> Obviously you have installed sysutils/gpart, and /usr/local/sbin precedes /sbin in your `$PATH`. That's not a good idea; /usr/local/{bin,sbin} should be last.


How do I accomplish that order? (sorry I'm a newcomer to unix)


----------



## yuripv (Sep 12, 2019)

dalpets said:


> How do I accomplish that order? (sorry I'm a newcomer to unix)


Default PATH (as set in /etc/login.conf) is `/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:~/bin`.

Was it a fresh install? If yes, what did you modify?

Or did you adopt the system after someone else? If yes, check the dot files in your ~ directory for any PATH overrides.


----------



## olli@ (Sep 12, 2019)

dalpets said:


> How do I accomplish that order? (sorry I'm a newcomer to unix)


Ok, I thought you changed that in the first place … Didn't think it was default.

Here's some background information …

PATH is an environment variable that lists the directories that are searched for commands if you don't specify the directory explicitly. For example, when you type `/sbin/gpart`, your shell knows that it has to look for the command in the /sbin directory. But when you type just `gpart` (without the /sbin directory), the shell starts searching for that command in a number of directories. Those directories are listed in your PATH environent variable, separated by colons.

You can view the contents of that variable with `echo $PATH`.

Usually, that variable is set by your shell's _profile_. That's a script that is executed automatically when the shell starts up. The name of the profile depends on which kind of shell you are using.

So, first, find out which command shell you are using (sh, csh, bash, zsh, …). `echo $SHELL` or `ps -p $$` should display it.

Then you might want to look at that shell's manual page: Type `man sh` if you're using sh, for example. You can also read the manual page online here: sh(1). In this case, it will tell you that the shell reads the file .profile in your home directory when you log in (other shells use different file names). So have a look at that file and try to find the line where it sets or changes the PATH variable.

As mentioned above, the local directories should be last. For example:
`export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin`

*Note:* When you work as the root user, you might have a different shell than as normal user, depending on how you invoked the root shell.


----------



## dalpets (Sep 12, 2019)

yuripv said:


> Default PATH (as set in /etc/login.conf) is `/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:~/bin`.
> 
> Was it a fresh install? If yes, what did you modify?
> 
> Or did you adopt the system after someone else? If yes, check the dot files in your ~ directory for any PATH overrides.


Yes it was. All I did was simply install the gpart pkg. The default PATH I have  in the config file is the same as yours above. Does that then change any comments by you & other responders so far. if it does, where from here? Thanks.


----------



## olli@ (Sep 12, 2019)

dalpets said:


> All I did was simply install the gpart pkg.


Did you install it for a reason? Or did you confuse it with FreeBSD's gpart? Those two are not related. It's very unfortunate that they have the same name.
If you don't really need the gpart package, I recommend to remove it. FreeBSD's gpart command is part of the base system; you don't have to install any packages to be able to use it.


----------



## dalpets (Sep 12, 2019)

olli@ said:


> Ok, I thought you changed that in the first place … Didn't think it was default.
> 
> Here's some background information …
> 
> ...




```
The config file shows the default as :path=/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin ~/bin:\ 
$ echo $PATH
/usr/local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
$ echo $SHELL
/bin/sh
$ su
Password:
[root@FreeBSD /home/brenton]# echo $PATH
/usr/local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
[root@FreeBSD /home/brenton]# echo $SHELL
/usr/local/bin/bash
```
Do these outcomes pose a problem. If they do how do I fix? Thanks .


----------



## dalpets (Sep 12, 2019)

olli@ said:


> Did you install it for a reason? Or did you confuse it with FreeBSD's gpart? Those two are not related. It's very unfortunate that they have the same name.
> If you don't really need the gpart package, I recommend to remove it. FreeBSD's gpart command is part of the base system; you don't have to install any packages to be able to use it.


Yes, I was aware of the subtle name difference but i didn't know gpart was part of the base system. The reason i was fixating on gpart was to get a utility program to view &, if necessary & to manipulate partitions, but initially for the purpose of introducing and formatting a new usb drive, for the purpose of system backups. All this to eliminate the possibility, in the process, of screwing up my existing system disk .
I particularly want to expedite backups so that I can effect minor version upgrades that might be lost to me if I dither doing so.

I come from a 25 years Windows background & would like, if possible, a GUI partition interface similar to that I used there. Any recommendations?


----------



## `Orum (Sep 14, 2019)

dalpets said:


> I come from a 25 years Windows background & would like, if possible, a GUI partition interface similar to that I used there. Any recommendations?


I don't know of one for FreeBSD, but if you've ever used diskpart on Windows (or even if you haven't), now might be a good time to learn gpart.



dalpets said:


> All this to eliminate the possibility, in the process, of screwing up my existing system disk.  I particularly want to expedite backups...


The best way to *not* screw things up is two-fold.  First, double and triple check any commands you run before you run them.  Make sure you know exactly what everything you type does and make sure any arguments you give it are correct.  Second, script any task you're going to do more than once, as this avoids you mistyping something down the line.  Doing regular backups?  Write a script, make sure to test it on a system you _don't_ care about first (in case things go wrong), and then transfer it over to your main system. Alternatively, use one that was written by someone else, but again, test in a non-critical environment, make sure you know how to use it, etc.


----------



## George (Sep 14, 2019)

`bsdconfig` has a GUI like partition Editor. You can call that directly, too, with `sade`. I dont think it has a backup feature though...


----------

