date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,459,528,977,000 |
I want to read the contents of the file into the paste buffer and stdout it to the screen.
I did this:
screen -X readbuf /home/nitro/file|screen -X writebuf|cat /tmp/screen-exchange
but the cat command showed me the screen-exchange file with the previous result of the readbuf command. If I do these commands separately, everything will be correct and I'll get the modified screen-exchange file.
How can I perform all three commands readbuf, writebuf and cat at once?
|
Those commands:
screen -X readbuf /home/nitro/file
screen -X writebuf
cat /tmp/screen-exchange
do not act as parts of a pipe, but your composite command attempts to treat them that way. That is, each step does not read the previous step's standard output, so there is less causal relationship among them than if you had typed
screen -X readbuf /home/nitro/file; screen -X writebuf; cat /tmp/screen-exchange
or
screen -X readbuf /home/nitro/file && screen -X writebuf && cat /tmp/screen-exchange
| Screen command for buffer |
1,459,528,977,000 |
There is a program that takes unexpectedly long to run. Before I started it, I did not start screen. So I dont know how to detach the process now. Is there any way to keep this process running on background even if I quit the current ssh session without killing it first?
|
The typical way to do this is with CTRL-z to suspend the process, and then bg to resume it in the background. Once running as a background process, you can disconnect and it will keep running.
If you need to reattach the process to a terminal later, you can use reptyr, which should be in your distributions repositories.
| put a running program into background like screen |
1,459,528,977,000 |
I have a screen session running on my local machine:
~/[email protected]$screen -S pair
Then, turn on multiuser:
ctrl-a:multiuser on
Finally, allow the user pair to connect to the session:
ctrl-a:acladd pair
So far so good. A remote user can log into the machine as pair and connect to the session:
~/$ssh [email protected]
pair@example~/$screen -x test/pair
But, if I open a split:
ctrl-a:|
The user pair cannot see the split.
Is it possible to have multiple splits open in a shared session?
|
Turns out screen now has a layout facility that will keep track of splits. In order for the pair to see the current layout just save it as the default:
ctrl-a:layout save default
| Why doesn't GNU Screen split show up for remote user? |
1,459,528,977,000 |
I promise I've been searching thoroughly for an answer...
So, my goal is to emulate the standard urxvt "tabbed" behaviour with screen keybinds, i.e. map three keybinds and that's ctrl+left (prev), ctrl+right (next), ctrl-down (new(?)).
Now I've found the keybinds for left and right on several comments like here and here.
So it seems that Oc and Od equal "right arrow" and "left arrow" keys.
But I can't figure out where to look up the rest of the keybinds. I tried getting the keys via xev and the output looks like
KeyPress event, serial 36, synthetic NO, window 0x2000001,
root 0xac, subw 0x0, time 50192748, (212,-106), root:(213,319),
state 0x4, keycode 116 (keysym 0xff54, Down), same_screen YES
I guess the answer is somewhere in this output, but I can't find the appropriate value (octal? hex? or is it something different for urxvt entirely?).
Maybe someone can point me to the right solution?
.screenrc should look like
bindkey "^[Oc" next
bindkey "^[Od" prev
bindkey "^[DOWN" new
thank you and cheers
Stefan
|
Rather than xev, if you use cat -v, you can find the characters sent by urxvt:
bindkey "^[Oc" next
bindkey "^[Od" prev
bindkey "^[Ob" new
xev shows X events, which are interpreted by the terminal emulator, and sent to your application (such as screen) as characters. To set up bindings for screen, you have to work with those characters rather than the original X events.
Further reading:
How can I see what my keyboard sends? (ncurses FAQ)
How can I use shift- or control-modifiers? (ncurses FAQ)
| screen with urxvt keybindings |
1,459,528,977,000 |
I use GNU Screen on occasion, and my Emacs keybinding muscle memory is hard to overcome. I know that I can send a control-a (i.e. "go to beginning of line") by hitting "c-a a", but I'm wondering if it's possible to remap the keybindings so that c-a c-a so that sends the c-a.
I've tried a simple "bind ^a ^a" in the .screenrc, but that doesn't seem to do the trick.
I suspect there's some way to do it with the combination of bind and bindkey, but the answer isn't obvious to me.
|
You want:
escape ^a^a
or
bind ^a meta
(since meta sends the command character, i.e. here ^a).
But since ^a is typically more useful than ^z in GNU Screen, you could use ^z as the command character. This is what I do:
escape ^z^z
| Gnu screen: remap "c-a c-a" to send "c-a" |
1,459,528,977,000 |
I use screen on a daily basis. My caption line in ~/.screenrc looks like this:
caption always '%{= dg} %H %{G}| %{B}%l %{G}|%=%?%{d}%-w%?%{r}(%{d}%n %t%? {%u} %?%{r})%{d}%?%+w%?%=%{G}| %{B}%M %d %C:%s '
I like but when I connect via ssh to a remote host and reattach a screen session on it I get this - 2 caption lines (this image turned not to be quite good, press it and open in a new tab to make it bigger and see what's the problem):
How can I kill an outer session or at least hide the caption line on outer session?
|
Captions are fairly limited - once a caption is added, there is no known command to remove them. One thing you can do is hide the text in them by replacing the caption in the outer session:
<ctrl>-a :caption string '%{kk}'
(where kk is black/black.) You'll still have a wasted line of real estate but the outer session's caption line will be cleared and hopefully not distracting you.
And you'll still have the problem that you're nested - you can't kill the outer without killing the ssh process that you started from it. All of your screen commands to the inner screen will have to be prefixed with an extra 'a'.
| GNU screen - kill outer nested session |
1,649,348,039,000 |
One of my first questions. Please comment if further explanation or information is required or if the question is not like it's supposed to be here
I'm using screen to automatically start servers (minecraft server in this example).
I'm spawning a screen like
screen -S 'server_1' -d -m "java -Xmx4G -Xms4G -jar spigot.jar"
Then setting the logfile and enabling logging with
screen -S 'server_1' -X logfile /srv/serverinstalls/1/stdout.txt
screen -S 'server_1' -X log
The contents of stdout.txt are then read in via NodeJS.
Output of "cat stdout.txt" look fine, but if I view the file with "less stdout.txt" every line starts with
>ESC[2K^M
where ^M and ESC are control characters (^M is the \r character)
I think this is the way screen logs the prompt (starting with '>') of the interactive shell the server provides
Is there some way the screen-command can be configured to ommit those control character and not log the interactive part of the shell?
If needed, I can execute additional commands every time I read the logfile or somehow replace the unwanted characters using NodeJS, but the prompt doesn't look the same on every server.
I'm running on Debian 9.9 (stretch) with screen 4.05.00
|
Have tried anyone below?
ansifilter
less -r
strings
| screen logging - How to ommit interactive shell control characters and prompt? |
1,649,348,039,000 |
# tmux Start Script Need To Work!!
if which tmux >/dev/null 2>&1; then
#if not inside a tmux session, and if no session is started, start a new session
test -z "$TMUX" && (tmux attach || tmux new-session)
fi
fine on arch wiki site:
https://wiki.archlinux.org/index.php/Tmux
it differences now then what it was before
|
Screen doesn't have an environmental variable like TMUX however TERM is set to "screen", so you can check that. Screen has a way of reattaching/creating all in one flag set.
-d -R Reattach a session and if necessary detach or even create it first.
# screen Start Script Need To Work!!
if which screen >/dev/null 2>&1; then
#if not inside a screen session, and if no session is started, start a new session
[ "$TERM" != "screen" ] && screen -d -R
fi
| how convert with startupScript from tmux to gnu-screen? |
1,649,348,039,000 |
I upgraded recently to OpenSuSE 12.1 from 11.3 and now when I open any files in emacs from inside a screen session, I get a blank buffer. Let's say I open it as:
emacs myFile.txt
it will open to an empty buffer, not the file, and when I attempt to save something, it will ask for a file name to write to. This worked before the upgrade.
I assume screen is the issue here since emacs works fine outside of screen. Is there something I'm missing in the screen settings or is this a bug in something?
|
I'm posting this answer based on the discussion in the comments.
Trial and error indicates that changing $TERM from linux to xterm works around the problem.
I don't know why this would matter. From your description, with TERM=linux it's opening an empty buffer rather than the file, which is not the behavior I'd expect from a bad $TERM setting. And the default $TERM under screen should be "screen" anyway, unless one of your startup scripts changes it.
| GNU Screen and Emacs |
1,649,348,039,000 |
I have a very simple chat-like tool that runs within a GNU screen session. The screen window is split, the top part is running tail -f file.txt and the bottom part is running a script with the following content:
#!/bin/bash
while : ; do
read -p "Message: " msg
ctime=$(date +"%H:%M:%S")
echo "[${ctime}] User: ${msg}" >> file.txt
done
Very simple, but gets the job done with the requirements I have. There's only one problem: When I press the ESC or any of the arrow keys, it inserts an escape-sequence, like ^[[D for example. And this messes up the file, resulting in terrible output.
So my question is simple: How can I escape the input from read so it's safe to write to the file?
I've tried echo "[${ctime}] User: ${msg}" | strings >> file.txt which made it a lot better, there were no big mess-ups anymore (e.g. nothing was overwritten or wrongly put out), but things are still not perfect (e.g. entering te^[[Dst would turn into te\n[Dst (the \n being an actual new line)).
|
How about a slightly different approach? Rather than remove the escape characters and sequences, you can allow users to use them to edit the input line with read -e.
If you want, you can take this even further by recording chat message history, like this:
...
read -e -p "Message: " msg
history -s "$msg"
...
With this, if someone makes a typo in a message, they can hit up-arrow, use left- and right-arrow to edit and fix the typo, then hit return to send the corrected message.
| How to safely escape a variable string (user input) in bash? |
1,649,348,039,000 |
I setup $HOME/root/.screenrc with
caption always "%3n %t%? @%u%?%? [%h]%?%=%c"
This is supposed to show the title at the bottom
When I launch a new screen with
screen -t testtitle
I see a different title
0 root@SERVERNAME:~
I can then set the title with ctrl-a A
Why can't I specify the title when launching screen?
|
This is from the category "It's not a bug, it's a feature!"
The problem is the bash (maybe the same or similar in other shells) variable PROMPT_COMMAND which is set by default in your distribution.
This variable is used to communicate with a lower level software (like a terminal emulator) by writing escape sequences (which you do not see because they are caught by screen) every time a prompt is created.
I just had a look at man screen in order to point you at the relevant parts and noticed that it seems not to be necessary to unset PROMPT_COMMAND because this behaviour can be disabled within screen:
defdynamictitle off
That should be enough. You can quickly test for this being the problem by disabling the init files:
screen -t testtitle /bin/bash --norc
See man -P 'less -p "^TITLES \(naming windows\)"' screen for an explanation.
| screen -t <titlename> , does not set screen title properly |
1,649,348,039,000 |
Is there a simple way of disabling this? I don't have any power saving constraints currently, as my desktop is always plugged in and I don't mind having it running forever. All of the explanations on xset I've found so far are so long and convoluted...
|
The quickest way is to:
xset -dpms
xset s off # if you also want to disable the screen saver
You can put that inside your .xinitrc so, every time you log in, that's executed. There are more efficient ways of making this programmatic though, one of them is mentioned at the end of one of Brodie Robertson's videos.
DPMS stands for Display Power Management Signaling.
You could also customize your Standby, Suspend and Off times with something like:
xset dpms 200 300 400
| How to disable screen going blank/off in X11? [duplicate] |
1,649,348,039,000 |
There are multiple questions about this sprinkled around the network, but what I could find has one of two things in common:
They give the manual solution, which only prints the current running program (with no arguments)
The use zsh preexec feature (though I am not sure how that interacts with screen). I am looking for a Bash solution.
How do I get my screen title to show the entire command run, so if I run 3 long running Python scripts for example, I can see the script names in the title as well? For bonus points, if I can get this to keep displaying the last command run that would be even better.
My current setup:
export PROMPT_COMMAND='/bin/echo -ne "\033k\033\0134"'
PS1 ends with >
shelltitle ">|bash"
I tried:
Adding stuff between \033k and \033 - breaks with ${BASH_COMMAND}
Using trap debug to set an external additional title since for XTERM with no screen I know the solution. This breaks badly with the PS1.
and variations of the above. I want a solution to be through screen, so both the window title and the screen window list show the full command.
As a bonus, I would really like it if Screen interacts nicely with Vim, so changing buffers/opening new files/etc. would dynamically updated in the screen title.
|
An year later, here is my solution, using traps. This display the hostname, corrent PWD and command (and screen stuff if on screen). This is easily customized in set_screen_window below. Everything should sit in your .bashrc.
First some helper function to check if I'm on screen or not:
export PROMPT_COMMAND=''
if [[ "$TERM" == "screen"* ]]; then
screen_title_slicer() { echo "${1:0:40}"; } # Arbitrary cut off. use echo $1 for full.
screen_title_format='\ek%s\e\\'
else
screen_title_slicer() { echo "${1//[^[:print:]]/}"; }
screen_title_format='\033]0;%s\007'
fi
The meat of building the command, relying on the useful BASH_COMMAND. I do some custom stuff for fg (such as displaying the original command) and cd (to get real directory):
ready="Ready!"
set_screen_window() {
title_string=$1
[ -z "$title_string" ] && title_string=$(screen_title_slicer "$BASH_COMMAND")
[ "$title_string" = "fg" ] && read -ra job < <( jobs %% 2> /dev/null )
[ "$title_string" = "fg " ] && read -ra job < <(jobs "${title_string:3} 2> /dev/null")
if [ ${#job[@]} -gt 0 ]; then
title_string=$(screen_title_slicer "${job[2]}")
fi
cwd=$PWD
if [ "${title_string::3}" = "cd " ]; then
cwd=$( eval cd "$(awk '{print $2}' <<< "$BASH_COMMAND")" &> /dev/null && pwd)
[ -z "$cwd" ] && cwd=$PWD
title_string="$ready"
fi
[ "$title_string" = "cd" ] && title_string=$ready && cwd=$HOME
printf "$screen_title_format" "$HOSTNAME -- ${cwd//$HOME/\~}> $title_string" > "$(tty)"
unset job
unset title_string
}
Now initialize the terminal head with my ready string, and trap both error and debug to update the terminal window:
set_screen_window "$ready"
trap "set_screen_window $ready" ERR
trap set_screen_window DEBUG
Finally, in .vimrc we have vim specific stuff:
function! Filename()
if @% == ""
return "noname"
endif
let is_tracked=system("git ls-files " . expand("%"))
if is_tracked == ""
return expand("%:t")
endif
return gitbranch#name() . "/" . expand("%:t")
endfunction
let &titlestring = hostname() . " -- vim " . Filename()
if &term[:5] == "screen"
set t_ts=^[k
set t_fs=^[\
set title
endif
autocmd TabEnter,WinEnter,BufReadPost,FileReadPost,BufNewFile * silent execute '!printf "\033]0;'.hostname().' -- vim '.Filename().'\007"'
autocmd TabEnter,WinEnter,BufReadPost,FileReadPost,BufNewFile * let &titlestring = hostname() . ' -- vim ' . Filename()
Here Filename can be customized to get your own header flavor. autocmd makes sure things get reloaded when moving between buffers, windows and the like. gitbranch in my example is a plugin available for git generating (as you might expect) the branch name when editing files in repositories.
| Display full command on GNU screen with bash in title, and interact properly with Vim buffers |
1,649,348,039,000 |
Problem Statement:
A bash script is being used to create a new screen session for each name from a list of names. At every name, a python script is run using that name as an input. The bash script sets the path containing the correct version of python (python 3 in the anaconda package):
#!/bin/sh
export PATH=~/anaconda3/bin/python:$PATH
while read p; do
screen -dm -S $p bash -c "cd /inside/home/thjmatth/essential; python3 essentialpairs_ttest_tissue_1.py; exec sh"
done <cells.txt
Setting the path as above didn't allow the correct version of python to run, so I added the following shebang to the python script to run:
#!~/anaconda3/bin/python python3
Still no dice: /usr/bin/python is still being used when it shouldn't. How can I have this program run the version of python according to the path I specify?
Attempt 1:
new shebang:
#!/inside/home/thjmatth/anaconda3/bin/python/
new bash script:
#!/bin/sh
export PATH=~/anaconda3/bin/python:$PATH
while read p; do
screen -dm -S $p bash -c "cd /inside/home/thjmatth/essential; python3 essentialpairs_ttest_tissue_1.py; exec sh"
done <cells.txt
new permissions on the python script:
chmod +x essentialpairs_ttest_tissue_1.py
error:
bash: python3: command not found
running which python in that screen still shows /usr/bin/python
Solution:
Same as Attempt 1 above, but changed line 3 of the bash script to make it a directory rather than an executable:
export PATH=~/anaconda3/bin/python:$PATH
|
export PATH=~/anaconda3/bin/python:$PATH
This seems like the path to an executable. PATH should contain directories:
export PATH=~/anaconda3/bin:$PATH
#!~/anaconda3/bin/python python3
Shebang lines need actual paths and do not perform tilde expansion (that's in your shell). Write the actual path to the executable, starting with /.
This shebang line would be running ~/anaconda3/bin/python with the argument python3, followed by the script name. You probably don't want that, but instead to run either python or python3.
#!/home/thomas/anaconda3/bin/python
screen -dm -S $p bash -c "cd /inside/home/thjmatth/essential; python3 essentialpairs_ttest_tissue_1.py; exec sh"
If you were still running this line after updating the shebang line, it would be ignored; the python3 from your PATH (which is not the same as python!) would be executed and would run the script in turn, and would just skip the shebang line as a comment. If you make the script executable (chmod +x essentialpairs_ttest_tissue_1.py), you could run it directly:
./essentialpairs_ttest_tissue_1.py
and the shebang line would be processed.
In this case, you can probably get away with just fixing the PATH variable from the first section, unless you have Bash startup configuration that resets the variable. If the executable name is python, make sure you update your screen command line to use that instead of python3 as well.
| Path Variable and script's shebang will not run correct version of python |
1,649,348,039,000 |
In GNU screen, the shortcut Ctrl-A + Ctrl-K or just K is mapped to kill the current window. I was wondering is there a shortcut to clear the current characters input so far in the prompt, just like the bash Ctrl-U or Ctrl-A + Ctrl-K would. I haven't been able to find it in the documentation.
|
If by "prompt" you are referring to the GNU screen prompt by Ctrl-A and :, that gets cleared by Ctrl-U. That is standard for most command-line applications; the others are bash-specific.
| How to delete current line in GNU-screen (bash equivalent of Ctrl-K)? |
1,649,348,039,000 |
I connect to Host1 using ssh and start a screen session. From one of those windows I ssh into the Host2, which launches a screen session on login.
How can I create new/switch between screen windows on Host2?
Is there a way to escape the first screen(Host1) and send the command to the second screen(Host2)
|
What you have is a nested screen session (using screen within a screen session).
By default, to send commands to the nested session, you hit a second a first:
Ctrl + a a command
For example, to create a new window in the nested session:
Ctrl + a a c
From the screen documentation:
(C-a a)
Send the command character (C-a) to the process in the current window.
| Working with screen via another screen session |
1,649,348,039,000 |
I need to toggle logging from outside of a detached screen session. Interactively you do this by pressing ctrl-a H.
Their octal codes are \001 and \110. (source)
What I tried:
$ screen -S test
then from other terminal I tried to push these codes to the screen:
$ screen -S test -X stuff $'\\001\\110\\r'
However instead of the expected Appending to logfile screenlog.0 I got bash: h: command not found
Please tell me how to push 'Ctrl-a H' to a detached screen session.
|
You've injected the characters Ctrl+A, H and Return into the application (bash) running in the Screen window. The string that is passed to stuff is not parsed for Screen escapes.
screen -S test -X log on seems to work, or screen -S test -X log to toggle as you want.
| failed to stuff "ctrl-a H" to a screen session |
1,649,348,039,000 |
Sometimes I'll start doing something fast. I've got something to do, and I need to get it done now.
Then of course i realize that I need to do something else to help me finish what I started, so I want to add a new shell using tmux (or screen)... but I forgot to start tmux right off....
My question is this:
How can I put a task to the background, start a tmux (or screen) session, and then resume my original task in tmux?
|
I believe you can do what you want using either reptyr ore retty. With either tool you can start up either screen or tmux and pull processes that have been backgrounded/disowned into either. For example:
$ reptyr <pid>
-or-
$ retty <pid>
References
Move a running process to a new screen shell
| Resume bash session in new TMUX or SCREEN? [duplicate] |
1,649,348,039,000 |
I'm trying to run a minecraft server on linux. Running the server starts an important interactive session. I can run the server in the background by appending & at the end of the command and log off the server. But then I don't know how to get back to that interactive session when I log back in.
I know about screen, but it seems like there should be a better way of running processes in the background and being able to go into them later.
|
screen (or tmux) is the best option for this and written for exactly this purpose.
| How to run linux process and come back to it later? |
1,649,348,039,000 |
I want to run a private Minecraft and Teamspeak server on my little vServer. When I start all manually, it works quite well but I want my servers to start automatically on server startup.
As I run two servers, I use screen to get multiple windows. But I don't know, how I can start a screen session with two windows and execute one server in each window with a single script, running at startup.
Isn't there any possibility to start a detached screen session, send a command to execute to it, open a new window in that session and send another command to it?
I thought of something like this:
screen -dmS test -t win1 # create new screen session, name it test
# and name the first window win1
screen -S test -X mcStart.sh # start the minecraft server
screen -S test -X screen -t win2 # create a new window, name it win2
screen -S test -X tsStart.sh # start teamspeak server
This doesn't sound bad in my opinion but it simply doesn't work... All I get is a screen session with two empty windows, named "win1" and "win2".
Please tell me what I have to do, to get this thing to work.
And by the way: If it is possible, I don't want to run each server in a single screen session.
|
The reason the -X doesn't work is because it's a screen command you're executing - in order to get it to run mcStart.sh and tsStart.sh, you should use:
screen -dmS test -t win1 mcStart.sh
screen -rS test -X screen -t win2 tsStart.sh
| Debian Server - Autostart two Servers in one Screen Session |
1,699,902,364,000 |
I have an arduino communication via Serial port at /dev/ttyACM0 and I can open it via screen:
$ screen /dev/ttyACM0 115200
But for some reason I have no privileges to open it via minicom:
$ minicom /dev/ttyACM0 -b 115200
minicom: cannot open /dev/tty8: Άρνηση πρόσβασης
My user is in dialout group:
$ groups
pcmagas adm dialout cdrom sudo dip plugdev lpadmin sambashare wireshark kvm docker
$ whoami
pcmagas
Any ideas why? AFAIK arduino uses an FTDI chip and the module used by kernel is cdc_acm one:
$ udevadm info --query=all --name=/dev/ttyACM0
P: /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/tty/ttyACM0
N: ttyACM0
S: android0
S: serial/by-id/usb-Arduino__www.arduino.cc__0043_7533131313335170A061-if00
S: serial/by-path/pci-0000:00:14.0-usb-0:3:1.0
E: DEVLINKS=/dev/serial/by-id/usb-Arduino__www.arduino.cc__0043_7533131313335170A061-if00 /dev/android0 /dev/serial/by-path/pci-0000:00:14.0-usb-0:3:1.0
E: DEVNAME=/dev/ttyACM0
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/tty/ttyACM0
E: ID_BUS=usb
E: ID_MM_CANDIDATE=1
E: ID_MODEL=0043
E: ID_MODEL_ENC=0043
E: ID_MODEL_FROM_DATABASE=Uno R3 (CDC ACM)
E: ID_MODEL_ID=0043
E: ID_PATH=pci-0000:00:14.0-usb-0:3:1.0
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_3_1_0
E: ID_PCI_CLASS_FROM_DATABASE=Serial bus controller
E: ID_PCI_INTERFACE_FROM_DATABASE=XHCI
E: ID_PCI_SUBCLASS_FROM_DATABASE=USB controller
E: ID_REVISION=0001
E: ID_SERIAL=Arduino__www.arduino.cc__0043_7533131313335170A061
E: ID_SERIAL_SHORT=7533131313335170A061
E: ID_TYPE=generic
E: ID_USB_CLASS_FROM_DATABASE=Communications
E: ID_USB_DRIVER=cdc_acm
E: ID_USB_INTERFACES=:020201:0a0000:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=Arduino__www.arduino.cc_
E: ID_VENDOR_ENC=Arduino\x20\x28www.arduino.cc\x29
E: ID_VENDOR_FROM_DATABASE=Arduino SA
E: ID_VENDOR_ID=2341
E: MAJOR=166
E: MINOR=0
E: SUBSYSTEM=tty
E: TAGS=:systemd:
E: USEC_INITIALIZED=9517655754
Though by passing the -D parameter into minicom does open:
minicom -D /dev/ttyACM0 -b 115200
But I do not understand the reason why -D parameter is required. Is that because for the device plugdev group is used?
ll /dev/ttyACM0
crw-rw---- 1 root plugdev 166, 0 Αυγ 11 13:05 /dev/ttyACM0
|
minicom does not actually accept a device name on the command line without the -D option. If a non-option argument is specified, it will be used as a suffix for the Minicom configuration file.
If you specify minicom /dev/ttyACM0, it actually attempts to read a configuration file at either /etc/minicom/minirc./dev/ttyACM0 or ~/.minirc./dev/ttyACM0.
The intended use is something like this:
Start Minicom in setup mode, giving the desired name for your new configuration, e.g. minicom -s arduino. Optionally, you could use other options to specify the port and speed here, e.g. minicom -D /dev/ttyACM0 -b 115200 -s arduino.
Go to the Serial port setup menu and change the "Serial Device" (item A) to /dev/ttyACM0 and the BPS/Parity/Bits (item E) to 115200 8N1 (or whatever your device requires. Also set the hardware and software flow control (items F and G) as required.
Press Esc to return to the configuration menu, and select Save setup as arduino, then select Exit from Minicom
Now Minicom is configured, and you can start it using the port, speed and flow control settings you saved, with just minicom arduino.
If you do the configuration as root, the settings will be saved to /etc/minicom/minirc.arduino, and will be available to all users on the system (assuming /etc/minicom is readable to all); if you do it as a regular user, the settings will be saved to ~/.minirc.arduino and will be available for that user account only.
| Why I can open serial via screen but cannot open via minicom? |
1,699,902,364,000 |
I have run multiple ANN training processes under multiple screen sessions. When I enter a screen, I see a training process running.
Now, I want to kill a specific process inside the screen without killing the screen.
I can press CTRL + C. But, that produces some unwanted garbage text on the screen.
How can I do it cleanly?
If I try to kill the process using the process-ID, I become confused. For me, it is impossible to recognize individual processes. Coz, they are running files with the same file names.
How to do that?
N.B. I am using TensorFlow and Keras.
N.B.#2, I am using SSH.
|
If you are able to ssh in to the remote host (the one running screen), then you could modify my script from a similar question that I had to give you the pid of the process and then just kill it.
Find the number of the window that you want to kill the process under. If you are viewing the window, Ctrl+a N will make it appear for a couple of seconds in the bottom left corner of the window.
Note: That is hold Ctrl, press a, release Ctrl, then capital N
If you have multiple screen sessions running, figure out which session you're targeting. I won't go into detail here, because I'm assuming that you're only running one session. You can check by running this on the remote host: screen -ls
Run the modified script below, passing in the window number that you found in step 1.
Note: you must save the script to a file and make it executable [chmod +x <script-name>] before you can run it [./<script-name> <window-number>])
Double-check that what it returned looks like what was running on that window
On the remote host, run kill <pid-from-first-column-that-script-returned> (replacing the brackets with the actual pid returned by the script)
You're done!
The modified script:
#!/bin/bash
# Accept a GNU/screen window number and return the process running in its shell.
# It assumes that you only have 1 session. If you have multiple sessions,
# pass in session name as the second argument.
TargetTabNum=$1
SessionName=$2
if [ -z "$SessionName" ]; then
SessionName=.*
fi
# This finds the session PID given the session name.
# The screen command prints the list of session IDs
# Example output of screen command:
# There is a screen on:
# 29676.byobu (12/09/2019 10:23:19 AM) (Attached)
# 1 Socket in /run/screen/S-{username here}.
# Example output after sed command: 29676
SessionPID=$(screen -ls | sed -n "s/\s*\([0-9]*\)\.$SessionName\t.*/\1/p")
# This gets all the processes that have the session as a parent,
# loops through them checking the WINDOW environment variable for
# each until it finds the one that matches the window number, and
# then finds the process with that process as a parent and prints its
# pid, command, and arguments (or null if there are no matching processes)
ProcessArray=( $(ps -o pid --ppid $SessionPID --no-headers) )
for i in "${ProcessArray[@]}"
do
ProcTabNum=$(tr '\0' '\n' < /proc/$i/environ | grep ^WINDOW= | cut -d '=' -f2)
if [ ! -z "$ProcTabNum" ] && [ "$TargetTabNum" -eq "$ProcTabNum" ]; then
ProcInTab=$(ps -o pid,args --ppid $i --no-headers)
if [[ $? -eq 1 ]]; then
ProcInTab=NULL
fi
echo $ProcInTab
exit 0
fi
done
echo "Couldn't find the specified Tab: $TargetTabNum" >&2
exit 1
| How can I kill a specific process running inside a screen session, without killing that screen session? |
1,699,902,364,000 |
I was going through the GNU Screen manual and it says
When a program terminates, screen (per default) kills the window that
contained it. If this window was in the foreground, the display
switches to the previously displayed window; if none are left, screen
exits
However in practice doesn't seem so. Neither for the screen nor for the windows. For example if I start a screen and run the program who or any other program, the program runs and terminates but the screen or window is still there. What am I reading wrong?
|
If you start screen, then type who at the prompt, then it is the shell that runs in screen that executes who. screen will therefore not terminate until that shell terminates.
To make screen run who instead of your shell, invoke screen like
screen who
The same behavior may be observed with tmux:
tmux new-session who
... where new-session (or just new for short) is a tmux command that initiates a new tmux session, and which takes a shell command to run in that session as an argument.
| GNU Screen behavior when the program running on it terminates |
1,699,902,364,000 |
I read the manual and online help, but still cannot grasp the idea of the screen command.
Lets say I SSH to my linux shell. Inside it I want to run a program that will run for 8 hours:
I create a "detached screen" by entering screen and then crtl+a, crtl+d to deattach it.
Then I run my program my_prog
What to do then? How do I return back to my normal terminal and continue my normal session started with?
If I just close the SSH window and reconnect, then my program stops.
My question is that exact steps I must make to:
Work in the shell as normal
Run screen to run a program in the background
Continue working in the old shell
Exit the SSH session
Establish a new SSH session and switch to my program that has worked while I was gone
Or is it the other way around? I enter my_prog &, then call screen and detach and then close the terminal window?
|
You start screen,
Run the program in screen,
And then detach it.
screen -R to attach it again.
If you run many independent screen sessions, then use the -S option to name your sessions and to attach named sessions, or use -ls to list existing sessions, and attach to those.
| How exactly to use screen in linux / SSH shell? |
1,699,902,364,000 |
I need a way to display two multiple running processes periodically on a system console so that I don't need to manually type commands to switch between the virtual terminals running them.
So for example, I can switch between my long running process and top every 10 seconds to watch both at the same time.
I thought gnu-screen would be ideal for this but can't find a way to automatically and periodically switch between two virtual terminals. Is there a command line switch that allows for this?
|
After starting your screen session, run this (in another terminal):
while sleep 10s ; do screen -X next ; done
The -X option sends commands to an existing screen session, and next simply advances to the next window. So if your session only has the two windows, then this will switch from one to the other.
| Can gnu-screen periodically toggle between two virtual terminals? |
1,699,902,364,000 |
Here's the workflow:
Open GNU screen: screen
Create a vertical split: C-a |
Switch to the newly created split: C-a TAB
Create a new window / terminal in this split: C-a c
How to do steps 3 and 4 at once? Is there an option that could be added to ~/.screenrc in order to achieve that?
(Note: I come from tmux, where splitting automatically spawns a terminal.)
|
I'm not very familiar with screen, so there may be better ways, but you can change the binding for | in your ~/.screenrc with the line
bindkey | eval "split -v" "focus" "screen"
This make the key run the 3 commands equivalent to your key sequence.
| GNU screen: how to automatically spawn a terminal after splitting? |
1,699,902,364,000 |
I'm trying to do this: if a GNU screen named worker already exists, then reattach to it, else create it by starting python example.py.
I tried:
if [ls /var/run/screen/S-root/ |grep -Fxq worker] then screen -r worker else cd /home/www/example/; screen -S worker python example.py fi
but it doesn't seem to work.
Is there something wrong in the syntax?
|
It makes more sense to use screen -ls or
screen -S worker -x || { cd /home/www/example; screen -S worker python example.py; }
But the errors in your code are
the unnecessary [ (which would have needed spaces around it)
if [ls /var/run/screen/S-root/ |grep -Fxq worker]
must be
if ls /var/run/screen/S-root/ | grep -Fxq worker
the missing ; / newline before then
|grep -Fxq worker] then
must be
| grep -Fxq worker; then
the missing ; / newline before else
then screen -r worker else
must be
then screen -r worker; else
the missing ; / newline before fi
python example.py fi
must be
python example.py; fi
| If GNU screen already exists, reattach to it, else create it |
1,699,902,364,000 |
I want to use GNU screen to run a single command in detached mode over serial console and save it's output to the log file on the host where screen is running. Basically, non-interactive equivalent of the following actions:
screen /dev/ttyUSB0 115200 # connect to serial console "/dev/ttyUSB0" using speed "115200"
ctrl+a H # start logging
some command
ctrl+a k y # quit
I know how to run a single command in detached mode in the current shell:
screen -d -m -L some command
# output is saved to screenlog.0
But I don't understand how to do the same thing while also attaching to a serial console.
|
I can't test this properly on a serial port, but I think this might work:
$ screen -S serial -L -d -m /dev/ttyUSB0
$ screen -S serial -X stuff 'some command\n'
My version of screen accepts an argument to -L, the name of the log file. Apparently not all versions do. Another way to set the log file name would be with screen -S serial -X logfile filename (if that works). screen buffers the output to the log for a while before writing. By default the timeout is 10 seconds, but see logfile flush NN to change that.
-X sends a command to a running screen, and stuff, well, "stuffs" the given string as input in the current window.
| How to run GNU screen in detached mode over serial console and save output? |
1,699,902,364,000 |
Is it possible to run source ~/.bashrc once but for all my N shell sessions (I'm talking about sessions related to one gnu screen of course) ?
Same question but for things like export TEST_VAR=whatever in one shell sessions.
|
If I understand your question correctly, you have N shell sessions in one GNU screen and you want to execute a given shell command (such as source ~/.bashrc or export TEST_VAR=whatever) in all shell sessions at once.
This can be done from inside your screen session with:
Ctrl-A:at "#" stuff "export TEST_VAR='whatever'\n"
This can be done from anywhere with:
screen -X at "#" stuff "export TEST_VAR='whatever'\n"
(you may want to specify a particular screen session with the -S option)
| source ~/.bashrc for all my shell sessions of my gnu screen at once |
1,699,902,364,000 |
Every couple of months I return to a gnu screen session just to find out that the running script was stalling for hours or days. My suspicion is, that I, while I try to detach, accidentally press some key combination that makes the process halt. When I attach later and notice the stalling I often see that my tries to detach have left command line input like D^[[D^[[D or ^[[. But I was not able reproduce it. Do you have an idea?
I experienced this behaviour with python scripts and C++ code.
|
The ^[[D is a key sequence normally created by pressing the cursor left key. This indicates you hit this key by mistake before detaching the session.
Screen pauses may be caused by pressing Control+S keys. This is using Xon/Xoff flow control. It can be restarted with Control+Q. Since the S key is next to the A key it's possible you hit this by mistake when detaching the session.
| Scripts stalling in `screen` session |
1,699,902,364,000 |
The X window system in a desktop Linux (where just one physical monitor is used) usually uses display 0, screen 0.
The output of who in Ubuntu 14.04 is
user1 :0 2016-06-15 14:25 (:0)
where :0 is the abbreviation for :0.0 (:display.screen). Here I logged in only from the GUI.
Then I opened a terminal emulator; I ran screen and I created two different windows (each of them simply contained bash). The resulting output of who was:
user1 :0 2016-06-15 14:25 (:0)
user1 pts/1 2016-06-15 14:26 (:0)
user1 pts/11 2016-06-15 16:31 (:0:S.0)
user1 pts/11 2016-06-15 16:31 (:0:S.1)
Why is this syntax used? It seems to be :display:display.screen.
Does screen emulate another display inside the physical display?
|
You're referring to the text at the end of the line. That is written by screen to indicate which pseudo-terminal connection it is using, as well as which window-number screen has assigned to it. Comments in the code indicate what it does:
/*
* Construct a utmp entry for window wi.
* the hostname field reflects what we know about the user (display)
* location. If d_loginhost is not set, then he is local and we write
* down the name of his terminal line; else he is remote and we keep
* the hostname here. The letter S and the window id will be appended.
* A saved utmp entry in wi->w_savut serves as a template, usually.
*/
and later
/*
* we want to set our ut_host field to something like
* ":ttyhf:s.0" or
* "faui45:s.0" or
* "132.199.81.4:s.0" (even this may hurt..), but not
* "faui45.informati"......:s.0
* HPUX uses host:0.0, so chop at "." and ":" (Eric Backus)
*/
concluding with the actual code which you might recognize:
sprintf(host + strlen(host), ":S.%d", win->w_number);
strncpy(u.ut_host, host, sizeof(u.ut_host));
which stores the string in the ut_host member of the utmp/utmpx structure.
Further reading:
utmp, wtmp - login records
who - show who is logged on
| Display used by screen in utmp |
1,699,902,364,000 |
I use tmux regularly to easily handle multiple terminals on my local machine. Sometimes, I need to connect to a remote machine and start a script in one the terminals (i.e. a pane or window in tmux). If my machine disconnects for any reason during this process, the remote script is killed and I cannot re-attach to the remote terminal that started the process.
Part of the purpose of terminal multiplexers is to deal with this precise scenario, but in my case, since I am running tmux on the local machine, I can't re-attach to the terminal that started the remote process.
One option would be to run tmux (or GNU screen) on the remote machine within one of the panes of my local tmux session, but I am concerned about running into keyboard shortcut conflicts when nesting either screen or tmux within tmux.
What is a good way of handling this problem? Is nesting console multiplexers a good idea? Is it the only solution to this problem?
|
One approach is to use a terminal multiplexer only on remote machines. Running each shell in a separate terminal emulator has the advantage that you can put multiple shell windows side by side. On a remote machine, resistance to disconnection is a big win that justifies terminal multiplexers, but locally, they have fewer advantages.
If you do want to nest terminal multiplexers, using different prefix keys locally and remotely would be the easy way to cope.
| Combining local and remote terminal multiplexing |
1,699,902,364,000 |
I have a scenario where I need to cd into a directory before running a script:
cd repos; python script.py
But it should be setup such that it automatically runs when screen is started. So in .screenrc I have this:
screen -t "cd repos; python script.py"
except this doesn't work because the cd repos is wrong. How do I cd into this directory?
|
If you want this to happen by default when you run screen, then you'll need to edit your .screenrc file. You can use the chdir directive to have a new screen window change directories upon opening it, but you'll want to explicitly reset that after your needs are met, so that newer windows are not affected.
# .screenrc settings to cd to repos and run python-script.py
chdir /full/path/to/repos
screen -t "Python Script" ./python-script.py
# reset the default directory for new windows.
chdir $HOME
screen -t "New Window" bash
screen -t "SSH Session" ssh [email protected]
Keep in mind that this will essentially set "./python-script.py" as the shell for that window, so when python-script.py is finished the window will close.
| How can I automatically run a script inside screen if the script is not in $PATH |
1,699,902,364,000 |
As far as I've seen, pressing Ctrl-Z on any terminal multiplexer, or trying to start them in the background, does nothing or crashes.
I know that, in a sense, terminal multiplexers are a "replacement" for job control, and usually, they have their own mechanisms for suspending and resuming. Still, I was wondering if I could integrate them in some way into a workflow based on the shell's job control.
Answer:
Screen suspends with "C-a z"
Tmux suspends with "C-b C-z"
Zellij suspends with "C-o d", but unlike the previous ones, it doesn't place the process on the shell's job control.
|
Do you want to suspend a job inside a screen window?
Just use Ctrl z inside the screen window (as usual). This doesn't suspend screen, though.
Do you want to suspend screen itself?
Use Ctrl az inside any screen window. But notice that although this suspends the user-facing part of the screen application, it doesn't suspend the applications being managed through screen. This is because screen is designed that its user-facing part can be detached with Ctrl ad, and the managed processes continue to run.
| Does any terminal multiplexer (screen, tmux, zellij) support job suspension (Ctrl-Z) in Bash? |
1,699,902,364,000 |
I could not figure out how to start a screen session, and in that attached screen session to run a command without human intervention. Expected behavior is:
[me@me ~]# screen -S name -L --mystery_flag 'hostname;echo yes;echo no'
#new screen session
[me@me ~]# hostname
me
[me@me ~]# echo yes
yes
[me@me ~]# echo no
no
[me@me ~]#
I looked by only found ways to send commands to a detatched session of screen, or to have the screen session close after it sends a command like screen -S name "command". I would like for the session to stay open, since it will be used to run an interactive script.
|
GNU screen takes a number of options, and then an optional command to start within the screen session. If no command is given, the screen session will contain an interactive shell session. The screen session terminates when the command that it runs terminates, no matter whether it's a command given on the command line of screen, or the shell that it otherwise runs.
You have two issues:
You want to run more than a single command.
You want the session to not terminate at the end, but instead leave you in an interactive shell session, within screen.
To solve the first of these, make the command that screen starts be
sh -c 'hostname; echo yes; echo no'
This is a single command that starts an in-line sh -c script. This script runs your commands. You may want to use bash -c in place of sh -c if the script you're running requires bash (your example does not).
To solve the second issue, consider starting an interactive shell as the last step in the list of commands that the sh -c script runs:
sh -c 'hostname; echo yes; echo no; exec bash -i'
The exec bash -i starts an interactive bash shell session (the exec makes it replace the sh -c shell).
Running this within a screen session:
screen sh -c 'hostname; echo yes; echo no; exec bash -i'
GNU screen will terminate once the bash -i shell session terminates.
| Running screen and immediately run other commands |
1,699,902,364,000 |
I have been running my code within a screen session on a remote server. I want to move the output directories generated within this session on the remote server to my local server using SCP but I am not able to.
Is there a way to do this?
If not, how can I copy my folders from the screen session to my remote server (so that I can SCP to my local server)?
Currently, this is what I do.
ssh [email protected]
[email protected]$ screen -r xxxx.pt
root@xxxxxx# ls media
Experiment_A
Local Server
scp [email protected]:/media/Experiment_A/features /Users/local/ExpResult
(Output)
scp: /media/Experiment_A/features: No such file or directory
|
It looks like you are re-attacing to a session started by root.
The files may be in /root.
Where ever they are you may have to change the file permissions to be able to read them. see What are the different ways to set file permissions etc on gnu/linux
They may also be on a mount-point that is restricted to a single user. If so then if the files are small, then copy them to yourself on the remote machine, then scp.
| Is it possible to copy directories from a remote session, to the local machine? |
1,699,902,364,000 |
I am attempting to get ANSI to display properly in a screen session using Iterm2 on OS X, the default TERM is set to
screen.xterm-256color
I tried
export TERM=vt100
and
export TERM=ansi
and
export TERM=xterm
w/ tmux
|
The issue isn't the terminal emulation - leave the TERM setting as is.
It's that the character set used by those part of the UI is CP437, but your terminal is set to another character set (probably UTF8).
You can either set iTerm2 to use CP437 if it supports that (the setting is under Terminal / Character Encoding), or you can use the cp437 utility to emulate a CP437 terminal on a UTF-8 terminal.
| ANSI in BitchX not displaying properly |
1,699,902,364,000 |
Whenever I move the cursor after the last/before the first character of the line, or I move before the first/after the last line in Vim there is a latency until I can control the cursor again.
It happens in bash too, but not in emacs.
It happens within konsole/terminator terminals but there is no problem while in a TTY out of X (only a colored refresh of the screen happens but I don't lose cursor's control).
Any hints ?
|
The likely problem is when using key-repeat to move continuously in in a terminal, when you reach the end, your key will have sent more characters than were needed to reach the end. The editor (or other application) still has to read and react to those extra characters. While it is doing that, you may notice that nothing seems to be happening.
Cursor keys send move than one character, usually 3, so key-repeat can fill up the program's input buffer more rapidly than you might expect.
Rather than using key-repeat to move around, vi was designed for slow terminals, providing single-character movement to useful points on the screen, e.g., ^ to move to the beginning of a line, H to move to the top of the screen, G to move to the end of the file.
| GNU screen latency when moving cursor on start/end of lines in Vim |
1,699,902,364,000 |
In my terminal I run a screen. Obviously I have several tabs and in one of them I connect to a remote server. In this one I have a detached running screen, I attach it but I can't switch its tabs.
PS: the remote running screen has been here since many months ago and is never killed. However the local one is killed every night (company policy)
|
Either use a different command character for the inner screen, for instance by starting it with:
screen -e'^Bb'
So that ^B be the command character instead of ^A and a literal ^B be entered ^Bb.
Or you'll need to enter ^Aa (assuming the outer screen was started with the default settings, that is as if with screen -e'^Aa') for the outer screen to pass that ^A to the inner screen.
That also means that to enter a literal ^A in the inner screen, you'd need to enter ^Aa^Aa.
From within screen, you can change the default command character with the escape command. So for your inner screen already started in an outer screen both using ^A as their command character, you'd enter ^Aa:escape ^Bb to change the command character to ^B
| screen inside screen [duplicate] |
1,699,902,364,000 |
screen offers this functionality:
bindkey -t foo stuff barfoo
Make "foo" an abbreviation of the word "barfoo".
Timeout is disabled so that users can type slowly.
I use(d) this for e.g.
bindkey -t .,u stuff user.name
bindkey -t .,U stuff User.Name
bindkey -t .,E stuff [email protected]
and so forth.
But now I moved to tmux, for various reasons, and am having difficulties replicating this behavior/functionality on tmux.
When trying to bind e.g. '.,E' I get an "unknown key" error from tmux.
|
tmux doesn't have this functionality. It uses a single key in each key-table, with modifiers. Some keys have names see here for a list.
If you are using a program such as bash that uses the gnu readline library
then you can use it to do the conversion.
Using bash
bind '".,u":"user.Name"'
bind '".,U":"User.Name"'
bind '".,E":"[email protected]"'
See readline manual for more information.
| tmux multi-key key binding like in screen possible? |
1,699,902,364,000 |
I'm trying to run an application sbopkg that uses a curses interface in an ssh session running under GNU Screen (Tmux also has the same behavior). If I run ssh directly from the terminal emulator (either iTerm2 or Terminal on OS X), then I don't see any blank spaces.
Why am I seeing these blank spaces? Is there a way to configure screen or ssh to avoid this?
|
You're using a terminal description that says that the terminal supports back color erase (bce), but it does not actually do this.
GNU screen is configurable (defbce for instance), but apparently tmux is not (see for instance Support background color erase (bce) [was: Vim copy & paste trailing space issue] #109)
Further reading:
My terminal shows some uncolored spaces
| Curses interface has blank spaces under GNU Screen and ssh |
1,699,902,364,000 |
I have a script that takes a while to run, and I'm using screen to run it.
ssh user@host screen -dm "python dostuff.py"
Now the question is, how do I make sure it kills the screen session after dostuff.py finishes execution? Whether it's because an error, or proper termination.
|
This might be in the "workaround" category, but I was able to achieve what I think your goal is by putting the command ("python dostuff.py" from your example) into a shell script, then running ... screen -d -m "/path/to/that/script"
Version info:
$ screen -v
Screen version 3.09.10 (FAU) 4-Sep-01
Looks like I have a pretty old version of screen on this system! Perhaps screen's behavior changed in more recent versions to automatically exit?
$ screen -ls
No Sockets found in /tmp/uscreens/S-username.
$ screen -dm "ls"
$ screen -ls
There is a screen on:
32112694.ls (Detached)
1 Socket in /tmp/uscreens/S-username.
(screen -r; exit)
$ screen -ls
No Sockets found in /tmp/uscreens/S-username.
$ cat runme
#!/bin/sh
sleep 6
ls > now
$ screen -d -m ./runme
$ ps -ef|grep sleep
username 9633926 9437204 0 14:55:23 pts/1 0:00 grep sleep
username 15532242 10223670 0 14:55:21 pts/6 0:00 sleep 6
(wait 6 seconds)
$ screen -ls
No Sockets found in /tmp/uscreens/S-username.
$ ls now
now
One thing I realized when going through this was that my version of screen seemed to expect a session name after -dm; I had to separate -d and -m in order to pass a command argument.
Try using:
ssh user@host screen -d -m python dostuff.py
with an optional -S to name the session something specific.
| Kill a screen session when script is done executing |
1,699,902,364,000 |
I have these in my .screenrc file:
screen -t ghci 0
screen -t bash 1
screen -t dev 4
Now, I put these in my my .screenrc file to split them:
split -v
focus
Now I want to switch to the window bash on the split screen. Right now that window is empty. How do I do that? I don't want to do that interactively. Is there any command which I can place in .screenrc which will achieve that?
|
The man page for screen has select, prev and next for window selection.
| GNU Screen switch to different window |
1,699,902,364,000 |
This is actually a problem that also goes on with screen. Here is what it looks like (in mutt):
mutt with browser visible behind http://s15.postimg.org/l4pupb7mx/muttmux.png
When running a terminal application that builds an updated interface from Guake, tmux and screen don't seem to display the default background colors that the displayed text have. (The effect is more subtle with, say, tilda, but the general idea is the same.)
This is a real killer for its usability/readability.
I messed around with the $TERM var as per this site's advice, but it didn't have any effect.
How can I force Guake to display the background provided by text interfaces like mutt?
other info
Strangely, this doesn't occur with dvtm, another multiplexer. I'm totally unfamiliar with it, though.
|
The question (and suggested answer) are a little obscure, but what is being described is mutt's use of the default color feature of ncurses (or slang). If your mutt color scheme uses the word "default" for the foreground or background, then at runtime mutt will ask ncurses/slang to use the terminal's default color.
Whether in an application such as mutt or in a multiplexer such as screen, it is implemented by SGR 39 (foreground default color, ^[[39m) and SGR 49 (background default color, ^[[49m). The multiplexer will use the terminal's actual SGR 39/49 support if it exists.
Applications such as the compositor can (relatively) easily detect the default foreground and background colors assigned to the terminal window and manipulate the background color to simulate a transparent window. Not everyone likes the effect (and because it detracts from readability, has not been implemented in xterm).
Default colors have their uses separate from transparent terminals, and mutt was one of the first applications where the feature was used (the result of a collaboration with Liviu Daia). It is coupled with the terminfo bce (back color erase) feature, which was originally not supported by GNU screen. That's been supported since 2002 (from the question it's unclear whether OP knew how to configure it).
If you want the background to be opaque, then
configure mutt without using the default color.
configure screen without enabling its bce support.
Further reading:
Default Colors (ded — directory editor)
What $TERM should I use? (xterm FAQ)
My terminal shows some uncolored spaces (ncurses FAQ)
GNU screen and white space, holy crap
| How to get guake to update background characters? |
1,699,902,364,000 |
I am using a laptop and Putty on a Windows system.
When I connect to my Debian Squeeze server in Bash environment, I can use the "Pos1/Home" or "End" (at the numlock part of the keyboard) to navigate through the commandline I am just writing.
However, when I create a "subshell" using screen, I cannot use Pos1/Home or End anymore. Pressing Num-Lock does not help.
|
I have found the reason why it didn't work.
In the PuTTy configuration I had to change the session settings as follows:
Connection -> Data -> Terminal details -> Terminal-type string
The value was: xterm
I changed it to linux
Now I can use the Home+End keys in Bash and in Screen as well.
echo $TERM will show linux outside screen and screen.linux inside screen.
UPDATE 23 Oct 2018
I have found a much easier solution!
Just start screen with this command:
TERM=linux screen
or put this line in your ~/.bashrc :
alias screen='TERM=linux screen'
| No numlock in screen? |
1,699,902,364,000 |
tl;dr: I have an irssi proxy screen session running in the background. I'm running byobu -R -S byobu;exit in ~/.bash_profile to start a second session instead of reconnecting to the irssi session, but it starts a third session when I log in twice (e.g. once through the local terminal and once through SSH). How can I make the secon login reconnect to the first?
I had previously enabled byobu on login for my server. This worked fine, and I would get the same underlying screen session no matter where I logged in from.
However, then I added a second screen session to the server's boot:
[alex@alex-ubuntu-server ~]$ cat /etc/rc.local
#!/bin/sh -e
# [clipped out default ubuntu rc.local header]
# run an irssi proxy under screen as user alex
sudo -H -u alex screen -d -m -S irssi-proxy irssi
exit 0
[alex@alex-ubuntu-server ~]$
From then on, this command (which was put in my ~/.bash_profile by byobu configuration):
_byobu_sourced=1 . /usr/bin/byobu-launch -S byobu
would connect to the already existing irssi screen session, instead of creating a new session. This was obviously not ideal, so eventually I settled on the following command:
byobu -R -S byobu;exit
Then intention was to name the screen session, thus allowing a reconnect to the same name when I logged in again through e.g. SSH. However, when I login again, I get a fresh screen session instead of the existing one (as you can see in the example below, this has already happened once).
[alex@alex-ubuntu-server ~]$ screen -ls
There are screens on:
18036.byobu (07/07/2013 04:26:44 PM) (Attached)
3869.byobu (07/05/2013 07:45:37 PM) (Attached)
1319.irssi-proxy (07/04/2013 05:01:54 PM) (Detached)
3 Sockets in /var/run/screen/S-alex.
[alex@alex-ubuntu-server ~]$ ssh localhost
Ubuntu 13.04
alex@localhost's password:
# at this point the screen redrew because of the new byobu session,
# so these weren't really one after another, as shown here
alex@alex-ubuntu-server:~$ screen -ls
There are screens on:
6216.byobu (07/07/2013 05:17:38 PM) (Attached)
18036.byobu (07/07/2013 04:26:44 PM) (Attached)
3869.byobu (07/05/2013 07:45:37 PM) (Attached)
1319.irssi-proxy (07/04/2013 05:01:54 PM) (Detached)
4 Sockets in /var/run/screen/S-alex.
alex@alex-ubuntu-server:~$
I'd prefer not to switch to tmux. How can I construct a byobu/screen command that reconnects to the existing second screen session if possible, but otherwise starts a new (second) session?
|
You could switch the irssi process to use tmux, instead of the login process.
| How can I set up byobu to use a second screen session on login? |
1,699,902,364,000 |
I want to start a long running custom script at boot.
The script must run under a specific username.
So far I have successfully used the screen command and switched to the user in the custom script. But I rather have the screen command run under that user so that I can later login to that user and resume the screen.
This one does work when run as root in the console but it does not work as a line in a startup script.
su -c "screen -S sessionname -d -m /path/cot/bash/script" username
|
Under GNU/Linux at boot, you should not use su (as it depends on PAM/dbus, which may not be available yet), but runuser:
runuser username -l -c "screen -S sessionname -d -m /path/to/bash/script"
When using runuser followed by the user name, the syntax is the same as su.
| Combined su and screen at startup |
1,699,902,364,000 |
Here's my .screenrc:
defscrollback 5000
vbell on
vbell_msg " dierre!!! ---- Wuff!! "
screen -t GRINDER ssh [email protected]
screen -t TRUNK
attrcolor b ".I"
termcap xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
defbce "on"
# caption always "%3n %t%? @%u%?%? [%h]%?%=%c"
# hardstatus alwaysignore
hardstatus alwayslastline '%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{=b kR}[%{W}%n%f %t%?(%u)%?%{=b kR}]%{= kw}%?%+Lw%?%?%= %{g}]%{=b C}[ %D %m/%d %C%a ]%{W}'
This will open two screen(s). The next step I have to do is:
Ctrl+A -> S to split the screen
Ctrl+A -> \t to go the the empty screen
Ctrl+A -> " to open the screen list
Now I can choose the other screen and therefore I have a terminal with two splitted screen.
Is there a way to create a macro for this? Really annoying to do it every time.
|
Add at the end of your .screenrc the following lines:
split
focus
other
To run multiple command, each in a separated split window:
screen -t title1 app1
split
focus
screen -t title2 app2
split
focus
screen -t title3 app3
and so on.
| Is it possible to have a screen macro for this? |
1,699,902,364,000 |
I like the experience that I get from using the terminal on a remote device where there is a visible lag between what I type and what happens on screen, because it forces me to trust the actions I'm taking. Sometimes I'd like to train my fingers a bit like this, and replicate this sort of lag on my local setup.
I use GNU screen for most of my work, and thought that this should be somehow possible. Glancing at the manual, I only see an option to set baud rate when starting screen on a tty, but I'm unable to completely grasp it and figure out how to modify the baud rate on a running screen session.
Does anyone know how to set and modify such a delay/baud rate on an open session, with screen or otherwise?
Thanks.
|
The answer - and explanation - comes from How to throttle bandwidth of SSH connection but I don't think it's a strict duplicate.
I started by considering a 150baud teletype (15 characters per second), but this timed out, taking too long for the ssh command to establish its credentials and set up the connection, and anyway on consideration the transport speed would need to be far higher to carry an effective load of 15cps:
ssh -o ProxyCommand='pv -qL 15 | nc %h %p | pv -qL 15' localhost; echo BACK
(I should point out that the echo BACK is simply to flag when the ssh localhost command has completed. It's not particularly relevant for day-to-day use, but very convenient when testing. I'll omit it from here on.)
Reading more about pv, which I usually use as a visual display of data transferred, I remembered that it's possible to control an existing instance. So we can run the initial ssh at full speed and then experiment with reducing the bandwidth permitted through the two instances of pv:
ssh -o ProxyCommand='pv -qP p1 | nc %h %p | pv -qP p2' localhost
The PIDs are written to the files p1 and p2 respectively.
p1=$(cat p1) p2=$(cat p2)
rm -f p1 p2
We can now apply restrictions to these processes, either symmetrically or asymmetrically depending on the effect required. (Remember these are limiters at the protocol level, not the throughput you yourself experience.)
for p in "$p1" "$p2"; do pv -R "$p" -L 1K; done # 1KB/s ≈ 8Kb/s
for p in "$p1" "$p2"; do pv -R "$p" -L 150; done # 150B/s ≈ 1.2Kb/s
Unfortunately this doesn't seem to slow things down far enough, so I looked instead at cstream. Here we're using a buffer of one byte and an output speed of 150 characters per second:
man cstream | head -n20 | cstream -b 1 -t 150
And applying that to ssh localhost we get this:
ssh -o ProxyCommand='cstream -b 1 -t -100 | nc %h %p | cstream -b 1 -t -100' localhost
Note that it will take up to a minute to establish the initial connection!
Unfortunately, it's still blocky, but I think that cstream is probably the way to go and I may update this answer as I get alternative approaches
| How to add delay to my terminal? |
1,699,902,364,000 |
I am trying to run gnu screen in a virtual machine. To create a new screen window, I press ctrl+a c, but this key combination makes the qemu monitor appear instead. How do I send these keystrokes to the guest?
|
QEMU in -nographic mode uses CtrlA as its own escape character.
To send CtrlA to the emulated system, you need to double it; so CtrlACtrlAc will create a new window in your screen session.
You can change QEMU’s escape character using the -echr option, followed by the ASCII code of the key you want to use; for example,
qemu -echr 2 ...
would use CtrlB.
| Prevent qemu from hijacking input |
1,699,902,364,000 |
With the screen command, the -X option allows you to execute a command in the specified screen session, but when you try to use it when creating a new screen, e.g:
screen -dmS -S downloader -X "wget https://google.com"
you get the error No screen session found.. So it's clear the the -X option only works for pre-existing screen sessions.
Is it possible to specify a command to be run on the creation of a new screen? If it's not possible in screen, is it possible in another multiplexer like tmux?
|
I found my answer, although it was under a different title and the question was slightly different, this does the job:
screen -d -S downloader -m wget https://google.com
It creates a new screen called downloader, detaches it and runs the command.
| Execute command when creating new screen session |
1,699,902,364,000 |
I found out today that both my friend and I use different ways of connecting to a screen. I've always used the form -x and he uses -r. I read the man pages but I wasn't able to come up with a test case that produced different results.
I opened two consoles on the same account and attached to it successfully with -r and -x.
What is the difference between these commands?
I could only find that the error message is different if I try to attach to the same screen I'm already attached to:
$ screen -r 1486
There is no screen to be resumed matching 1486.
and
$ screen -x 1486
Attaching from inside of screen?
| ERROR: type should be string, got "\nhttps://www.gnu.org/software/screen/manual/screen.html#Invoking-Screen\n-x attaches to a session even if you are attached to it already.\n-r attaches only to a session if it has no client currently attached to it.\nIf you want to test it (the test you did sounds rather like you tried to attach to the screen-session from inside the screen session, which you definitely should not do), you need two separate terminal sessions. In the first, do screen to start a screen session and attach to it. In the second, do screen -r:\nscreen -r\nThere is a screen on:\n 562503.pts-2.E595 (Attached)\nThere is no screen to be resumed.\n\nNow do screen -x and you will attach to the session. If you put both terminals side by side, you will also notice that what you do on one of the terminals will be visible also on the other terminal.\nSo in short: -r for attaching a detached session, -x to attach to an attached session without detaching the other session.\n" | What is the difference between -r and -x when attaching to a screen? |
1,612,926,048,000 |
I am building a dumb terminal with an arduino and I can now see the output of serial connections. How do I get a login/shell?
I have tried screen /dev/ttyACM0 and that lets me type on the host computer and see the results on the terminal screen, but no shell. Using screen's :exec /bin/sh command starts a shell on that controlling xterm window but no longer outputs to the serial line. various attempts with agetty -L /dev/ttyACM0 9600 just sit and hang for a minute then exits without ever having put anything on the screen. I have tried cu -l /dev/ttyACM0 -s 9600 and again it hangs with no screen interaction. I have connected minicom to echo keys onto the arduino similar to screen but could not figure out how to get a shell. To be clear I am trying to access my main computer via the arduino based terminal, and I can not find a way to make my main computer offer a shell session to the arduino over a USB serial connection.
|
agetty seems to be fairly quiet about problems. I tried:
$ strace -e open agetty -I 'hello\012' -L /dev/ttyS0 9600
and it opened /dev//dev/ttyS0, which failed of course. It then hung around a few seconds and stopped.
The man page does say it wants a relative filename, so I then tried:
$ strace -e open agetty -I 'hello\012' -L ttyS0 9600
and it opened the right device this time, but failed again:
open("/dev/ttyS0", O_RDWR|O_NOCTTY|O_NONBLOCK) = -1 EACCES (Permission denied)
Finally, this worked and wrote something on the tty:
$ sudo strace -e open agetty -I 'hello\012' -L ttyS0 9600
You should also add the setsid mentioned in the comments.
You can also use systemd (if you have it) to start the login with:
$ sudo systemctl start serial-getty@ttyACM0
This runs agetty with --keep-baud 115200,38400,9600.
If you systemctl enable the service, it might start automatically whenever device ttyACM0 is created.
| How do I host a shell for a serial terminal? |
1,612,926,048,000 |
I can split my screen window horizontally by typing Ctrl-A S (or vertically with Ctrl+A |), and then I can switch between windows with Ctrl-A Tab. I'd like to also be able to switch windows with Ctrl-A o (to parallel how you can switch windows in emacs with Ctrl-x o). I've tried reading the docs on screen's bindkey command, but I find them completely inscrutable. Can anyone help me make this change? Thank you!
Note: I'm not actually using Ctrl-A as my escape key, I've actually set my escape key to backtick, but backticks wreak havok on the formatting on stackchange, so I left the examples using the default Ctrl-A escape sequence to make this question easier to type out. I'm assuming the solution shouldn't care about what the escape sequence actually is, so long as I can set the key sequence to change windows to be <escape sequence> o
|
See the docs.
Add this to your .screenrc file:
bind o focus next
| Change "next window" keyboard shortcut in GNU screen |
1,612,926,048,000 |
I have an existing screen session and now I need to set some (more than one) environment variables to that session. These environment variables should not be visible to other screen sessions. I tried the solution in this answer which didn't work.
I tried
screen -r "myscreen" -X setenv x x_value;y y_value;z z_value
Here I got an error
-bash: x: command not found
-bash: y: command not found
then I tried
screen -r "myscreen" -X setenv x x_value;setenv y y_value;setenv z z_value
which gave me
-bash: setenv: command not found
-bash: setenv: command not found
How can I set multiple variables at once?
|
instead of the setenv command, try the export command
export myEnvVar="echo \"It works!\""
bash $~/ $myEnvVar
Output:
It works!
To make it permanent for your user:
in the .bashrc file (usually your your /home//folder)
add it at the last line, and reload the bash shell.
I.e you could add the following lines:
export myEnvVar="echo \"It works\""
echo $myEnvVar
$myEnvVar
And to reload the bash shell - reopen it(the terminal) or just type bash.
| Set multiple environment variables for existing screen session |
1,612,926,048,000 |
I am new to GNU screen and was wondering how to split window appropriately.
Start a session with screen command.
Split window with C-a S.
And I get the results of the terminal as shown in the image below.
I'm assuming that I'm logged into bash at the same time as the split screen, is this feasible?
I'm using
macOS 10.15.6
screen 4.00.03 (FAU) 23-Oct-06
|
I was able to solve this issue sing @Fox 's method.
| Could not start bash session after GNU screen window split command |
1,612,926,048,000 |
Our $HOME file system is an openAFS system. I log on to my desktop machine from my laptop at home and want to run a long job. Thus to protect it from a broken session, I open up
screen -S session_name
and run the script from there, and then disconnect the screen session. My problem is that after a relatively short time of a few hours, the session loses contact to the AFS file system, so I can't use any files there in the script stored on my $HOME. If I reconnect later to the session I can't list any files there or change directory to my home, I simply get a permission denied error.
I tried the following commands to try and reconnect, which usually work if I have left my desktop logged in too long:
fs checkservers
fs checkvolumes
fs flush
but that doesn't help the screen session to reconnect. Does anyone know how I can keep access to AFS in a disconnected screen session, or place a command in my bash/python scripts to keep it alive?
|
I suggest running krenew, which has the option to run a command with the -t flag, which by default is aklog. It’s usually packaged as part of the kstart package.
Run the krenew inside the screen session. Make sure you get renewable Kerberos tickets, and your institutions KDC might have limits on how long your ticket can be renewed. As long as the Kerberos ticket is valid, krenew will run aklog and get updated tokens.
If you want to keep the ticket for a long while, make sure that the credential cache is the same every time you log in (for example, use the KEYRING), that way every time you ssh in, the krenew process will have access to the refreshed tgt. You set the default ccache name in /etc/krb5.conf.
I basically do this with tmux, and I also use the kAFS client as well as OpenAFS for home directories.
| screen session loses contact to AFS file system |
1,612,926,048,000 |
I have a machine configured (via cron) to start a screen session on reboot. The session opens up a few screens and starts a server in one of them. All of this works fine. However, when I login and resume the screen session, I get a (PS1) prompt like this:
\u@\h [\j] \w\$
Terminal colors do not appear either. This is the PS1 string I explicitly set in my bashrc file, but the control sequences like \u are not being interpreted by the shell. I have ensured that my bashrc and profile get imported before the screen starts; the script called from cron:
#! /bin/bash
# This script initializes screen with a propert environment. It is intended to
# be run from cron.
# source the profile
if [ -r "$HOME/.profile" ]; then source "$HOME/.profile"; fi
if [ -r "$HOME/.bash_profile" ]; then source "$HOME/.bash_profile"; fi
if [ -r "$HOME/.bashrc" ]; then source "$HOME/.bashrc"; fi
exec screen -dmS initscreen
I tried adding the line "export TERM=screen.xterm-256color" and variants (e.g., export TERM=xterm-256color), but these changed nothing.
My assumption is that because there is not a real TTY when the screen gets started at reboot, somehow screen can't interpret my terminal correctly and ends up starting up without any terminal interpretation. When I quit screen and rerun the startup script from an ssh session (instead of from cron at reboot), everything work fine. How can I get screen to startup at reboot in a way that will let me attach it later with these terminal features working?
Thanks in advance.
|
The fact that magic characters like \w in PS1 are not being interpreted seems to suggest that the shell started by screen is not bash, but something simple like /bin/sh. I looked at /etc/crontab in one of the systems I had to hand and it had the line
SHELL=/bin/sh
at the start, but another distribution had SHELL=/bin/bash, so you probably need to set this explicitly somewhere to ensure you get a consistent result.
| How to start screen on reboot with an interactive TERM/TTY |
1,612,926,048,000 |
I'm running a Minecraft server as a systemd service. The service's ExecStart is the path to a script whose contents are:
screen -L -DmS minecraft java -Xmx4096M -Xms1024M -jar server.jar nogui
That is, this is running as a simple service, not forked.
I would like for the output of the java call to be logged via systemd's usual mechanism, in addition to being visible in the screen session. I am almost a total novice when it comes to systemd, so I'm not sure where to start with that. Can I tee the output of the java call into something?
|
I eventually solved this problem by changing the way I ran the server. I stopped using screen entirely and used Minecraft's RCON support to control the server (e.g. stopping it). I'm not sure it's precisely an answer this question as I've asked it, but it should work well for anyone specifically running a Minecraft server.
Full details here: Minecraft server startup/shutdown with systemd.
| Capture log output for a systemd service running in a screen session |
1,612,926,048,000 |
I have my computer start secure shell in a chroot system at boot. (All the normal directories are bind mounted in the chroot system /run, /dev, /dev/pts, /sys, /proc). After logging in to the chroot environment and trying to start screen, I receive the error.
Directory '/run/screen' must have mode 775
So I set chmod 775 /run/screen in my start scripts. Everything was working fine, but now I've run into a new problem. When I try to run screen on my computer host system, I receive the error.
Directory '/run/screen' must have mode 777
Mode 777 is the default permission at boot. So the permissions screen requires for the host and chroot are different for some reason. How can I get screen to run in both host and chroot environment?
Note: The host is Ubuntu Mate 18.04 LTS Bionic (graphical desktop), and the chroot is Debian 9 Stretch (headless personal server).
|
This sounds similar to this screen bug detailed for Ubuntu.
You are sharing the /run directory between your host and chroot, but I suspect they are running different versions of screen and the the Ubuntu one is exhibiting this bug and should be updated to a version that does not have this problem.
If that does not help fix things, post the versions and permissions of both of your screen binaries as well as the actual permissions of the shared /run directory.
| GNU Screen requires different permissions for chroot environment? /run/screen |
1,612,926,048,000 |
I write a bash file, which contains screen commands. This bash file is then called from a python script using subprocess. All works perfectly fine. However, the screen sessions don't close after the script has (successfully) run and stay open. This is unwanted behaviour.
Here is an example of the bash file:
#!/bin/bash
VIRTUAL_ENV_DISABLE_PROMPT=true
source generic_path/bin/activate
cd generic_directory
screen -dmS session_1
screen -S session_1 -X stuff "Rscript script_1.R\n"
I suspect, that I have to change something in the screen commands, right? Could you advise, what I have to change, so the screen session automatically close, after the script has run.
|
When you execute something like
screen -dmS session_1
screen -S session_1 -X stuff "Rscript script_1.R\n"
you send to the terminal (in previously created screen) the sequence of characters Rscript script_1.R\n. This way the shell will execute the command and, then, wait for the next command.
You need to execute something like Rscript script_1.R && exit to ask to the shell to exit when your command completes successfully (please, adapt to your shell syntax).
screen -dmS session_1
screen -S session_1 -X stuff "Rscript script_1.R && exit\n"
In any case, there is no need to create a window and then "remote control" it. You can simply ask to screen to execute a command for you.
screen -dm Rscript script_1.R
Last but not least, to use screen to put in background a script is one of the weirdest idea I ever heard. Please use cron or at or & instead (according to your needs).
If "Rscript" is not only a random example, please read Run R script from command line.
R CMD BATCH script_1.R &
| Screen session doesn't close after script has run |
1,612,926,048,000 |
I have a screen running with a number of sessions, and in one of them, I entered screen -D -m and now that session is just hung. I can't do an Escape, q, or Ctrl+C to terminate. Even after closing and resuming the screen screen -r screenName, this specific session is just in that same state.
How do I kill this session?
Thanks!
|
screen -D -m starts a new session in a detached state without forking a new process. The command will not terminate until that new screen exits.
You can still put the command in the background with Ctrl+Z followed by bg, and then check what name it got with screen -ls (it will say (Detatched) at the end and also mention the time it was created). The name is the first word on one of the lines and will likely contain some digits and your hostname.
Attach to the session with screen -r name (where name is the name shown by screen -ls for the started session that you'd like to end) and exit from it.
You don't need to exit or detach from the original screen session to do any of these things.
| Terminating a Screen session after running "screen -D -m" |
1,612,926,048,000 |
Suppose we need to run application in screen and keep it running when screen exits. The following command does the job, but only if "sleep 1" is appended to it. Why it does not work without "sleep 1"?
screen -d -m -L sh -c 'DISPLAY=:0 nohup zenity --info --text test >/dev/null 2>/dev/null &'
|
This seems to be a timing problem, in that nohup does not have time enough to disable signals before it is signaled by one of the parents. You can see this by adding strace -o /tmp/s -ff in front of the screen command and then in one of the log files /tmp/s.* you see
...
access("/bin/nohup", X_OK) = 0
stat("/bin/nohup", {st_mode=S_IFREG|0755, st_size=36696, ...}) = 0
--- SIGHUP {si_signo=SIGHUP, si_code=SI_KERNEL} ---
+++ killed by SIGHUP +++
You can simplify the startup. This works for me without the need for &.
DISPLAY=:0 screen -d -m -L nohup zenity --info --text test
Another solution seems to be to ask the parent shell to use job control. This seems to make it either disable SIGHUP to the background, or otherwise wait for the child nohup to be further on before exiting itself. Using sh -cm instead of sh -c on your original command should work better. For example, this works for me
screen -d -m -L sh -cm 'nohup zenity --info --text test >&/dev/null & echo'
whereas the -c verson does not. bash has a disown command that protects a background job from SIGHUP, if using job control, but you don't seem to need it even without nohup as this works too, without leaving a screen process running:
screen -d -m -L sh -cm 'zenity --info --text test >&/dev/null </dev/null & echo'
| Why application does not run from SCREEN without delay? |
1,612,926,048,000 |
In my .screenrc I have the following stanza:
# Change command key to ctrl+space
escape ^@a
I found this magic incantation in a forum I can no longer find; it allows me to hit ctrl+space to invoke screen commands, so ctrl+space c (or ctrl+space ctrl+c) will create a new window, and ctrl+space space (or ctrl+space ctrl+space) will switch to the last window, etc.
This is very useful in avoiding the problem of precluding the ctrl+a beginning-of-line terminal functionality, is easy to type and doesn't conflict with any standard keybindings.
Can anyone explain why and how this works? I have searched through https://www.gnu.org/software/screen/manual/screen.html for any reference to the character @ and found nothing relevant.
|
With a lot of terminal programs (but not every one), control-SPACE sends the ASCII 00 character (NUL).
You can see this, eg with od -cx and entering control-SPACE, RETURN, control_D. You'll see output similar to:
% od -cx
^@
0000000 \0 \n
0a00
0000002
Control-@ is also the NUL character (@ is ASCII 64, so control-@ is ASCII 00).
So mapping control-@ inside screen has the effect of mapping control-SPACE... because of how the terminal handles control-SPACE.
| Why does the .screenrc key binding ^@a map to ctrl+space? |
1,612,926,048,000 |
In a bash script I want to show the user a file with less, but I don't want less to take up the whole terminal: I need to keep some informations visible in the terminal while the user browses the file with less.
I googled for terminal split linux and all the results refer to the screen command.
After several hours of trials end errors I believe I've come up with a mostly working solution. I've created a screen.rc file containing:
split
screen 1 less /etc/passwd
focus down
resize 10
screen 2
exec !.. echo Informations area
focus up
Now, in my bash script, I can run
screen -c screen.rc
and it creates a split terminal with less /etc/passwd output in the top region and Information area in the bottom one and the top region is receiving user input, which is exactly the intended behavior. Almost perfect, except when the user hits q to terminate less, screen does not terminate, because there's still a running shell in the bottom region. The user now needs to focus the bottom region (CTRL+a TAB) and hit Ctrl+d to terminate the running bash.
So the sequence to exit my custom less file viewer has now become q CTRL+a TAB CTRL+d: quite a lot of keystrokes only to exit a text file viewer...
How can I make screen terminate immediately when the top region less command quits?
|
Sending the quit command will tell screen to quit, so replace the less command with:
screen 1 sh -c 'less /etc/passwd ; screen -S "${STY}" -X quit'
or something to that effect.
| using screen to split the terminal |
1,612,926,048,000 |
Related, but this is Gnome Terminal, not Screen
I closed a "tab" (pane? window? not sure the correct term) within my screen session. Is there a way to recover a "tab" lost in this way?
(not dissimilar ctrl+shift+t in a browser)
|
No. Once a shell session has terminated, it is gone, no matter whether it was running in GNU screen, in tmux, in a terminal emulator or directly on a console.
A web browser is different as it's able to just reload the page in a new tab if you ask it to reopen the most recently closed tab. A browser may additionally keep track of data that you may have entered into forms etc. before closing the tab, and restore this too. GNU screen does nothing of that.
| Can I reopen closed panes in GNU Screen |
1,612,926,048,000 |
I have a python script that I run by passing some arguments as environment variables:
param=1 length=5 python myscript.py
I want to run it inside a screen. I tried screen -m param=1 length=5 python myscript.py but this does not work, I get the error "Cannot exec param=1, no such file or directory". How can I still run this script within a screen?
|
Try:
param=1 length=5 screen -m python myscript.py
Example
$ cat myscript.py
#!/usr/bin/python
import os
print(os.environ["param"], os.environ["length"])
raw_input()
If we run this command:
$ param=1 length=5 screen -m python myscript.py
The output appears:
('1', '5')
(For python3, replace raw_input with input. Also, note that the output will display slightly differently.)
| screen a script with env variables |
1,612,926,048,000 |
Context
I often create a multiuser GNU screen session for demonstration purposes. I do it by creating a named session with:
screen -S tutorial
And then performing
^A:multiuser on
^Aaclchg student1,student2,student3,... -wx "#?"
And that works, the students can connect with screen -r grochmal/tutorial and can see what I do. (It even locks their PTS 'cause they do not have permission for ^Ad).
Question
What I'd like to do though is to setup aclumask so I could make my life easier since I sometimes forget to use aclchg and use acladd (and a funny student can write swear words on the terminal).
According to how I understand man screen the following should be equivalent to what I do above:
screen -S tutorial
^A:multiuser on
^A:aclumask ?-wx
^A:acladd student1,student2,student3,...
And then I could add the aclumask ?-wx to my .screenrc and never worry again about funny students.
Unfortunately that is not the case, and the aclumask line seems to have no effect on the permissions granted by acladd. I must be doing something wrong.
What is the proper way of using aclumask with users that are not yet known to screen?
|
OP got me to find the last bits of what I needed for my configuration, seeing it's a old question I stumbled in here and found little examples of it elsewhere so figure I could drop my solution here~ I found in the umask it's reading right->left as well between the | if you like to add permission for one and remove from all other try in .screenrc
aclchg * -w "#?"
aclchg root -w+w "#?"
aclumask [ -wx | root+wx ]
| GNU screen: how do I use :aclumask to set permissions to unknown users? |
1,612,926,048,000 |
When I used vim outside a unix screen to edit a file, vim displays the file correctly.
However , when I open the same file inside a unix screen, the indentation "seems" to become messy.
I say "seems" because the indentation is actually correct (if you see the highlighted cursor in the second image, it is actually at the correct begin-of-the-line)
What can be the issue here ?
EDIT : Not just my file, even the vim messages seems messy
I have tried all things possible, also chnaged code for CRLF in screen code, but couild not get rid of this issue. Finally switched to tmux, and it works well.
Outside screen:
Inside screen:
|
The picture appears to show these features working:
color (perhaps)
cursor-addressing (something moved the cursor to the right place)
tabs (unknown: if the terminal was claimed to support hardware tabs but did not at all, that second line would begin at the left margin)
But that second line is the problem. Vim could have attempted to move the cursor straight down from the curly brace (with a line-feed) and gotten a carriage-return / line-feed instead. That could explain the space, and vim does this type of optimization in screen.c:
else if (plan == PLAN_NL)
{
if (noinvcurs)
screen_stop_highlight();
while (screen_cur_row < row)
{
out_char('\n');
++screen_cur_row;
}
screen_cur_col = 0;
}
In your stty settings, that would be onlcr:
onlcr (-onlcr)
Map (do not map) NL to CR-NL on output.
which seems to be off normally. One of your stty settings may have confused vim (or screen) so the result is as shown.
For example, in a quick check I did this (with a literal tab character)
$ stty ocrnl
$ cat >foo
$ cat >foo <<EOF
if(a) {
/*then b */
}
EOF
$ vim foo
and see this (demonstrating that vim can be confused by the setting of ocrnl):
if(a) {
/*then b */
}
But then (quitting vim) and
$ stty -ocrnl
$ vim foo
shows
if(a) {
/*then b */
}
For what it's worth, vi-like-emacs does the right thing in this case.
| vim inside screen : Indentation displayed incorrectly |
1,612,926,048,000 |
Is there a way to list the windows of a screen session from a non-interactive terminal?
screen -S 'screen_name' -X windows
According to gnu.org, this command displays the list of windows using the message line.
That's fine and dandy for an interactive console, but I need this to print to standard output so I can read it into another program.
Any way to do this?
SOLUTION
I found that the best way to do this is to get the list of windows ids by using this command: (as posted by Stephen Harris)
screen -S 'pid.screen_name' -Q windows
Although this truncates the names of the windows when it prints, it doesn't actually truncate the total size of the output. So if I have like 20 windows in a screen session, this is what the output will be.
> screen -S 'pid.screen_name' -Q windows
0 bash 1 bash 2 bash 3 bash 4 bash 5 bash 6 bash 7 bash 8 bash 9 bash 10 bash 11 bash 12 bash 13 bash 14 bash 15 bash 16 bash 17 bash 18 bash 19 bash 20 bash
I have tried this up to an absurd number of windows.
With this you can parse how many windows there are in the screen session, and then issue a "title" command for each one using the following command:
screen -S 'pid.screen_name' -p %window_id% -Q title
Replace %window_id% with each window ID from the windows command.
This time the window title isn't truncated at all. So the full screen name is outputted to standard output.
|
You can use the -Q option
% screen -S 2908.pts-0.mymachine -Q windows
0- spam 1* news 6 ksh
Unfortunately this truncates if there's more than fits across the terminal width (basically it causes the command to run and displayed in the message line, but also copies it to the current stdout).
| Screen: List Windows in Session (Non-Interactive) |
1,612,926,048,000 |
The current work flow is like this, a user logs into a session and begins processing. At a later time that user's shift ends. At this point the user is still processing but able to detach from the session where upon a new user logs in and continues processing.
This is okay while there is only one unit of processing work to be done. This work includes the use of regular gui tools such as a browser and spreadsheet as well task specific tools (not necessarily gui).
When there is a second processing task needing to begin with another user they must wait to log into this resource and begin a new.
My question is there a screen like command or program which could be used to allow applications and processes to be started in one user's session and picked up by another user later?
Basically, can one user for sake of argument, in some kind of named container start Firefox. Then another user to access that container and find Firefox as the first user left it. Like screen but with X applications?
|
A simple way of sharing that might work for you would be to start a
Xvnc virtual X11 server with vncserver :1 on one machine, and
run your application in it, and then connect to it simultaneously from many different workstations with vncviewer -shared host:1. All users see the same desktop and share keyboard and mouse actions. When the users disconnect the server continues to run.
In your case, the server and workstations can be the same machine, and the different user sessions correspond to the sharing, as each will see what the previous left. You can even make the viewer full-screen if needed.
| gnu screen command for X |
1,612,926,048,000 |
I have added this to .profile:
[ -z "$STY" ] && screen -Rd "work"
When connecting to a remote machine via ssh, the automatic attachment to screen is hiding the server's motd (message of the day).
Can I tell Screen to show this message when first attaching, or at least insert a keypress block before hiding the motd?
|
You can try it this way:
[ -z "$STY" ] && read && screen -Rd "work"
It will postpone the screen attaching after you will press enter (or input something). If you enter Ctrl+D, screen will not be attached and you will end up in normal shell.
| Showing login message when connecting to Screen |
1,612,926,048,000 |
I am trying to compile GNU Screen in my home folder on a machine where I don't have super user rights. I am taking GNU Screen version used by Linux from Scratch.
tar xvzf screen-4.3.1.tar.gz
cd screen-4.3.1
./configure --prefix=$HOME
Its all good until that point and the Makefile is generated. Then the command make exists with
utmp.c:99:1: warning: "pututline" redefined
In file included from screen.h:30,
from utmp.c:34:
os.h:262:1: warning: this is the location of the previous definition
utmp.c: In function 'makedead':
utmp.c:602: error: 'struct __exit_status' has no member named 'e_termination'
utmp.c:603: error: 'struct __exit_status' has no member named 'e_exit'
make: *** [utmp.o] Error 1
After compiling a few files successfully.
Any ideas?
The code line it refers to looks like this
static void
makedead(u)
struct utmp *u;
{
u->ut_type = DEAD_PROCESS;
#if (!defined(linux) || defined(EMPTY)) && !defined(__CYGWIN__)
u->ut_exit.e_termination = 0; // Line 602
u->ut_exit.e_exit = 0; // Line 603
#endif
#if !defined(sun) || !defined(SVR4)
u->ut_user[0] = 0; /* for Digital UNIX, [email protected] */
#endif
}
I am on a linux machine though:
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
|
It looks like you're missing a few dependencies. That would be a bug in the configure script. You might want to file a bugreport to the screen maintainers.
| Trying to compile GNU Screen |
1,404,431,914,000 |
I recently installed Debian on my machine and made separate / and /home partitions. Yet my disk usage analyzer shows that my /home is inside /.
But gparted shows that /home is indeed in it's own partition, and has 500+ GB of free space.
I checked my /etc/mtab and it shows that /home is mounted at /dev/sdb6 whereas / is mounted at /dev/sda1.
I don't understand what is wrong. I'm going to keep reading about partitioning, but I'd like to leave this question here to simmer to see if anyone has a quick answer.
I put translations in the gparted window just in case.
|
You split your disk into (at least) two partitions - one for your home directories (/home) and another for everything else (/). It looks like you only allocated about 10GB for /, which is now full. The partition mounted as your /home directory is ~621GB, with plenty of free space, but that's not where most system files go. That's the danger of allocating too little space for /; if they're both on the same disk, there's rarely a good reason to split / and /home.
| Why is my hard drive out of space if gparted says I have 500+GB |
1,404,431,914,000 |
I have Linux Mint installed on an external hard drive, and I have the 4 main partitions (/boot, swap, /, and /home). I also have 600GB of unallocated space. I know there's always the chance of data loss, but would it be any more dangerous to add a partition while booted to that physical disk than it would while booted to another? Would adding a partition while booted to that disk be like erasing / as root?
|
Since "when booted" means that the OS that needs to make changes and write to the disk, is also running from the same disk, has a higher potential for problems/disaster if something goes wrong.
Following Murphy's Law, "Anything that can go wrong, will", you are safest to run the operation isolated from the operating system.
My suggestion would be to use the system boot disk (install), or a generic "Live CD".
And for what it is worth, I have partitioned and formatted partitions in the same manner you are describing without ever having an issue, only the flip side I could have been incredibly lucky all those times.
| Is it safe to use GParted while booted? |
1,404,431,914,000 |
I have the following partitions on my machine:
I want to resize /dev/sda5 and stick it to sda4, but gparted doesn't allow me.
How can I do it?
|
You can't, you need to unmount it first. And because it is your / filesystem, you need to use a LiveCD (GParted has a special LiveCD but you can use the Ubuntu installation image too).
Some filesystems can be resized when mounted and ext4 is one of them, but you don't want to just resize it, you also need to move the entire partition to the left, because partitions can be resized only to the right. This means copying the data and it cannot be done when the partition is mounted.
Note that the Resize/Move operation in GParted can be dangerous (for example losing power during it would be really bad) so make sure to backup your data first.
| resize mounted partition with gparted |
1,404,431,914,000 |
I seem to be unable to start gparted from the command line. I am using Trisquel 8 (based on Ubuntu 16.04) with LXDE. If I try to open it, I get the following error and nothing happens:
$ sudo gparted
(gpartedbin:7820): Gtk-WARNING **: cannot open display:
However, it seems to open fine from the graphical application menu.
I searched a bit online and one recommendation was to try:
xhost +localhost
However, that didn't help. Apparently, it seems there can be an issue with opening gtk applications from the command line as root in Wayland; however, I am using X11. This is just on a local laptop - no ssh-ing or remote systems involved.
It seems strange, because I have always been able to open gparted from the command line in the past. I have also tried re-installing gparted and that didn't seem to help.
Update:
Following meuh's suggestions in the comments, I added DISPLAY=:0 to the /etc/environment file, so it should be passed when using sudo. However, I am still experiencing an error, but it has now changed:
$ sudo gparted
No protocol specified
(gpartedbin:5549): Gtk-WARNING **: cannot open display: :0
It seems that the DISPLAY variable is now being passed, but I'm not sure what that 'no protocol' message means.
|
To access X you need environment variables DISPLAY and XAUTHORITY. Depending on setup, sudo may delete them. You can check that with sudo env to see the environment variables.
To preserve your users environment, you can use sudo -E. That has the pitfall setting HOME to your users home, and config files may get wrong file permissions. However, to avoid that, sudo -H sets HOME to /root.
Combine this for gparted:
sudo -EH gparted
Only desired variables can be set with:
sudo env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY gparted
Error messages:
cannot open display: means DISPLAY is empty or does not exist.
no protocol specified means DISPLAYis set and vaild, but XAUTHORITY pointing to authentication cookie is not set or the cookie is invalid. Alternativly, xhost +SI:localuser:root allows root temporary access to X until logout.
Similar goes for Wayland access with WAYLAND_DISPLAY and XDG_RUNTIME_DIR. Wayland root access issues can be solved with sudo -EH, too. For detail and a pitfall with XDG_RUNTIME_DIR see Will Wayland ever support graphical sudo?
| Why can I not open gparted from the command line? |
1,404,431,914,000 |
Apologies for this question but I am very new to Linux.
When I installed my Fedora distribution I only allocated 20GB of my hard drive space for its partition. I recently used GParted and tried to increase the size of the partition to around 40GB. I was under the impression that I was successful but today I tried to create a directory and I got the following error message:
mkdir: cannot create directory ‘b_scripts’: No space left on device
I checked the space on my disk and found out that I had used 20GB on my fedora-root.
derrick@dazza >> df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 253M 1.7G 14% /dev/shm
tmpfs 1.9G 1.5M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/fedora-root 20G 19G 0 100% /
tmpfs 1.9G 128K 1.9G 1% /tmp
tmpfs 386M 20K 386M 1% /run/user/42
tmpfs 386M 28K 386M 1% /run/user/1000
Is a partition different from a Filesystem? How come there are only 20GB in total allocated to my fedora-root?
What is my solution? How do I increase the size of my fedora-root Filesystem so that it is more than 20GB Size?
|
In this case, your file system is on the LV(Logical Volumne), which is on the partition. If you expand the partition, your LV will not be expanded.
Please run these commands :
pvresize <device name> <-- This will let the Physical Volume know that the partition it is on has been expanded.
And :
lvextend -l +100%FREE /dev/mapper/fedora-root <Physical Volume name> <-- This will extend the LV.
resize2fs /dev/mapper/fedora-root
PS: You can find the Physical Volume name using the command pvs
Thank you @Dani_l for the edit suggestions.
| How to increase size of filesystem to match partition |
1,404,431,914,000 |
I'm running a VM with Centos 7 in a virtual environment (Proxmox). I'm out of space. So I've added some from Proxmox, booted from Gparted Live CD to allocate that space to /dev/sda2, but it won't let me resize. Please advice what can be done.
|
You have a swap partition between /dev/sda2 and the free space. Turn off swap, remove the swap partition from /etc/fstab, then use Gparted to delete the swap partition /dev/sda3 and the extended partition /dev/sda4; you will then be able to extend /dev/sda2 in the adjacent free space.
| Gparted Live: Can't resize ext4 partition |
1,404,431,914,000 |
I am trying to somehow extend the unallocated partition (below sda1) into the sda2 partition to increase its total size. If it is relevant the sda1 is a Windows 10 parition and I'm dual-booting with Antergos (Arch Linux variant). Below is a screenshot from GParted.
|
Mounted file systems can't be resized. In the screenshot of gparted, there's a key symbol between /dev/sda2 and ext4; that key symbol indicates /dev/sda2 is mounted. It can't be unmounted while the Arch Linux system on sda2 is running.
To fix:
Reboot from a liveCD, (or USB equivalent), and run gparted from that, right click on /dev/sda2 and click 'Resize/Move', etc. Now /dev/sda2 won't be mounted, so it can be resized.
Usually after moving the root directory, grub should be updated, or it won't be able to find the system, and Arch wouldn't boot. So after the resize, (and still using the liveCD), open a terminal, do the appropriate chroot login to /dev/sda2, and run update-grub.
Reboot, remove liveCD. The system should now boot from the newly resized 120GB /dev/sda2 Arch Linux partition.
| Extend unallocated partition into linux partition |
1,404,431,914,000 |
I am working with an external HDD and trying to backup a logical partition within an extended partition using dd like this:
sudo dd if=/dev/sdb6 of=partition6.dd
it returns:
dd: opening `/dev/sdb6': No such file or directory
I used the exact same method to backup a different partition (primary) with no issues
sudo dd if=/dev/sdb1 of=partition1.dd
Both GParted and cfdisk show sdb6 but it seems dd can't see it.
How can I backup /dev/sdb6?
|
It appears that the device file does not exist. You can verify this by doing ls /dev/sdb6.
Try running the command partprobe, or sudo partprobe as user. This should detect the devices and create the according device files.
This may return the error
Error informing the kernel about modifications to partition /dev/sdb5 -- Device or resource busy
If it does, try to temporarily disable SELinux with setenforce 0, then try partprobe again, then don't forget to reenable SELinux.
For an external hard disk, you can also solve this error by unplugging the disk (once everything is unmounted!) and plugging it back in.
| dd can't see partition but cfdisk and GParted can |
1,404,431,914,000 |
I have a LVM primary partition at the end of my disk, Windows is at the beginning, there was an unused partition in between but I need some space for Linux so I removed it.
Now I'm trying to figure out if it is possible to resize my LVM from its add more space "on the left" of the partition.
fdisk -l
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 718847 716800 350M 7 HPFS/NTFS/exFAT
/dev/sda2 718848 256718847 256000000 122.1G 7 HPFS/NTFS/exFAT
/dev/sda4 325298176 488397167 163098992 77.8G 83 Linux
gparted can't move the LVM to the left, maybe it's because I need to unmount the partition, I'm not sure.
|
LVM (Logical Volume Manager) is a subsystem. At the lowest level is a PV (Physical Volume). Within the PV is a VG (Volume Group) and within the VG are the LVs (Logical Volumes).
You seem to be asking how to move or resize the PV corresponding to /dev/sda4. In order to do this you first need to deactivate the VG. (gparted > deactivate partition.) Note that when you deactivate a VG all its LVs must first be unmounted and will become unavailable until the VG is reactivated. Consequently it's highly likely that you'll need to perform this move/resize from outside the running system. (I can particularly recommend SystemRescueCd but I see that GParted now has its own LiveCD.)
| Resize LVM at the beginning |
1,404,431,914,000 |
This is my partition structure :
I want to create another primary partition from that unallocated space.
If I shrink sda2 to a size less than what I needed for to create another primary partition, will it move entire extended partition to right or just slices off extended space from it as it is contiguous ?
|
No it will not move the entire extended partition nor make the space contigious.
Although in theory the extended partition could just be recreated with the same
logical partitions, that would mean that the entries stay in place (with some zero size first, logical partition), or you would have to rearange the Extended partition information. Both that would free up space between sda1 and sda2, but I don't know about any tools that will do that for you, and I cannot recommend experimenting and possible loosing access to the data.
As this is only a small 300Gb disc, I recommend making a backup of all the data on the medium you normally use for the backup of your drive, then boot from USB/CD, re-partition to your liking and restoring everything.
| Moving unallocated space from Extended partition to create a Primary partition |
1,404,431,914,000 |
I have an Ubuntu 12.04 LTS server that has 6x600GB SAS drives in a RAID 5 configuration (Perc 6/i).
The partition scheme looks like this:
Partition File System Mount Point Size
/dev/sda1 ext2 /boot 243.00 MiB
/dev/sda2 extended 1.09 TiB
/dev/sda5 lvm2 1.09 TiB
unallocated unallocated 1.64 TiB
I want to extend the /dev/sda5 partition to include the unallocated space, and create one large partition. However, when I attempt to extend the partition, I get an error:
partition length of 5854484482 sectors exceeds the msdos-partition-table-imposed maximum of 4294967295
I believe that I need to create a new partition table. However, I have also read that doing so can cause problems.
My basic question is this: if I boot from the GParted Live CD, apply a new partition table, extend the /dev/sda2 partition, and increase the size of the LVM, is the system going to boot up afterwards, and will the LVM still be intact? I understand that there is always the possibility of data corruption, and I've backed everything up. The real question is whether this is the correct way to go about modifying the disk configuration.
Alternatively, is there a better way to incorporate the unallocated space into the LVM?
|
jordanm had the best suggestion. Although the msdos partition table cannot accomodate a single partition that is larger than 2TB, because I have a logical volume, I can create a new partition from the unallocated space (which is smaller than 2TB) and add it to the logical volume.
First I create a new, unformatted partition named /dev/sda3 in GParted from the unallocated space.
Now that a new partition exists, I need to create an LVM physical volume:
nalice@gerty:~$ sudo pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
Next I need to extend the Logical Volume to include the new physical volume:
nalice@gerty:~$ sudo lvextend -L2731.75G /dev/mapper/GERTY-root
Extending logical volume root to 2.67 TiB
Logical volume root successfully resized
Note that the -L paramter of lvextend indicates the total size of the Logical Volume, not the amount that the Logical Volume is extended.
Lastly, I extended the filesystem to include all of the available space in the Logical Volume:
nalice@gerty:~$ sudo resize2fs /dev/mapper/GERTY-root
resize2fs 1.42 (29-Nov-2011)
Filesystem at /dev/mapper/GERTY-root is mounted on /; on-line resizing required
old_desc_blocks = 67, new_desc_blocks = 171
Performing an on-line resize of /dev/mapper/GERTY-root to 716111872 (4k) blocks.
The filesystem on /dev/mapper/GERTY-root is now 716111872 blocks long.
And there you have it, a 2.9TB Logical Volume without having to change the partition table.
Source: http://www.howtogeek.com/howto/40702/how-to-manage-and-use-lvm-logical-volume-management-in-ubuntu/
| Change Partition Table with GParted |
1,404,431,914,000 |
I have an external (USB) disk, which has been working OK for some time and shows no errors whatsoever in /var/log/$relevantfiles (no errors on reading/writing, for example).
Here's the thing:
if I ask for sudo fdisk -l /dev/sda this returns:
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x24796452
Device Boot Start End Blocks Id System
/dev/sda1 63 1953520064 976760001 83 Linux
which is exactly how I did it.
Now, I want to recover a partition in this disk to use for some other purposes, which require hfs, instead of ext{2,3,4}.
So I turned myself to the old dear parted to resize the partition and create a new one.
Asking parted this returns:
(parted) print
Model: ST310005 28AS (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: mac
Number Start End Size File system Name Flags
1 512B 1535B 1024B partition map
2 368MB 371MB 2982kB OneClick-Ready
and if I run gparted I see all the empty space, and I cannot resize my partition, since it's not there.
Any pointers how to fix this things? I've never seen anything like it. The whole thing's running on a raspberry pi, using raspbian.
Thanks!
|
You appear to have both a dos and mac partition table on the disk, and parted is recognizing the mac one. You should be able to zap the mac partition table with:
sudo dd if=/dev/zero count=1 bs=2 of=/dev/sda
| parted not recognizing my current partition on external disk. How to fix without losing data? |
1,404,431,914,000 |
I am using GParted.
It shows partition name and a label.
I found their difference in What is the difference between a name and a label in gparted?
I found how to change Partition label in How do I change the “label” reported by lsblk?
I want to change Partition Name stored in the partition table (not label). How can I do that?
|
A) Make a list of partitions with lsblk -o NAME,FSTYPE,LABEL,SIZE,MOUNTPOINT
B) Unmount the partition with umount /xyz -l where /xyz is the partition to change.
If it's your boot partition you wish to rename, well, boot with a LiveUSB. The process for making a LiveUSB will vary depending on your distro, but here's a Windows and Ubuntu process.
C) Launch gparted and do Choose: Partition then pick /xyz and select Name Partition which will show Set partition name in the /path-to-partition dialog.
D) Type in the name you want to use, then Apply the change.
E) Remount the partition with /mount /newname -l.
| How to change partition name (not label) |
1,404,431,914,000 |
I have an ext4 img file containing an Android system partition files.
I mount it by using sudo mount -t ext4 -o loop,rw system.img system
When I'm done editing the files and umount the file, I notice that the resulting image is significantly larger than the content it has.
I checked with GParted, and it is indeed true : the image file is 2.0Gb, while its partition only has 1.51Gb used (and 506Mb unused).
I can use GParted to resize the partition and shrink the IMG size by 500Mb, but I would like to have it automated, in a script. How could I achieve this ?
|
You can use resize2fs -M system.img to shrink your filesystem to the minimum size. Note that this does not shrink the image file directly. You would need to use truncate to shrink the image file to the new filesystem size (carefully, so you don't chop data off the end).
| Automatically shrink an ext4 IMG file |
1,404,431,914,000 |
I booted to a live Ubuntu USB, wanting to delete partitions on an SD card, and ended up deleting all my partitions on my MacBook Pro's internal HD.
I have already tried gpart (which gets stuck at "Begin scan...") and testdisk (which can't create partitions since "Function write_part_mac not implemented"!).
I did try cmd+ R at boot, but gave it up as it was taking a long time. I thought there would be an easier and faster alternative.
Is there a way to recover data with partitions on my hd?
Here's my testdisk output for the Mac HD:
Partition Start End Size in sectors
> P DOS_FAT_32 40 409639 409600 [EFI]
> P HFS 409640 489972567 489562928
|
Intel MacBook Pro's use GUID partition table for disk partitioning which one can edit with gdisk.
A copy of the partition table metadata is usually stored as backup of the primary. You can read more detail about it on the Arch Wiki here
You need first to know the device name, /dev/sda, /dev/sdb of your Mac disk.
You can use the blkid, lsblk or dmesg commands to determine the exact name if you do not know.
From your Ubuntu Live USB, use gdisk /dev/sdX (where X is your device name)
e.g. /dev/sdb (assuming the USB is given sda and the Mac is the only other disk)
$ sudo gdisk /dev/sdb
GPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): `r`
Recovery/transformation command (? for help): `b`
Recovery/transformation command (? for help): `w`
And reboot
The b restores the backup GUID partition table and w writes it to disk
You way wish to also run the v verify after restoring the backup table and before writing it to the disk. gdisk is very sane about letting one create and modify the partition table, in memory, and nothing is written on disk until you write it with the w command. Be very sure you are happy with the recovery result before you write it to disk.
| Recover partitions Mac OS internal HD |
1,404,431,914,000 |
I was so dumb, to turn of the power on my Readynas Ultra 4 when it was installing the disk (3TB WD Green), I had no time to wait for it as I was going to return it (It was too damn noisy) The disk installation was at 0% and stayed like that for 2 minutes, so I decided to turn it off without really thinking about the consequences. Anyways, now it’s done, and I need to put it into my new NAS (Synology 413j), but that’s not going very good.
The disk is recognized in BIOS, and I get it up as /dev/sdc when I run gparted live on USB. But it is not shown in Windows device manager or in Ubuntu.
When I run sudo gparted on a live Ubuntu USB, I get Input/output error during read on /dev/sdc.
I have tried more stuff in gparted live, but to sum it up, it is very similar to what's happening here: http://ubuntuforums.org/archive/index.php/t-1492414.html
Up to the part where he runs badsectors, and get alot of errors, I ran badsectors -vs (I guess that is just read, and show output. I ran it for about 3000sectors, and for each block it counted the output was: (and so on)
1
2
3
4
5
6
7
8
9
10
11
12
13
140.00% done, 0:01 elapsed. (14/0/0 errors)
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
310.00% done, 0:02 elapsed. (31/0/0 errors)
In gparted(live) the /dev/sdc disk shows, but its all unallocated, and it shows an input/output read error when it scans all disks. When I try to create a new partition, I get an error with no partition table. I go to device - create partition table, and select gpt, I get about 5-6 errors with input/output read and also write on /dev/sdc.
When I enter gdisk on gparted(live) I get:
Warning! Read error 5; strange behavior now likely!
Warning! Read error 5; strange behavior now likely!
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries.
When I run smartctl:
ubuntu@ubuntu:~$ sudo smartctl --all /dev/sdc
smartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.2.0-29-generic] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net
=== START OF INFORMATION SECTION ===
Device Model: WDC WD30EZRX-00MMMB0
Serial Number: WD-WCAWZ2205xxxxx
LU WWN Device Id: 5 0014ee 25c5f8480
Firmware Version: 80.00A80
User Capacity: 3,000,592,982,016 bytes [3.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 8
ATA Standard is: Exact ATA specification draft version not indicated
Local Time is: Sat Sep 29 15:53:44 2012 UTC
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
General SMART Values:
Offline data collection status: (0x84) Offline data collection activity
was suspended by an interrupting command from host.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: (50700) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 255) minutes.
Conveyance self-test routine
recommended polling time: ( 5) minutes.
SCT capabilities: (0x3035) SCT Status supported.
SCT Feature Control supported.
SCT Data Table supported.
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x002f 200 200 051 Pre-fail Always - 0
3 Spin_Up_Time 0x0027 199 140 021 Pre-fail Always - 7050
4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 483
5 Reallocated_Sector_Ct 0x0033 200 200 140 Pre-fail Always - 0
7 Seek_Error_Rate 0x002e 200 200 000 Old_age Always - 0
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 572
10 Spin_Retry_Count 0x0032 100 100 000 Old_age Always - 0
11 Calibration_Retry_Count 0x0032 100 100 000 Old_age Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 142
192 Power-Off_Retract_Count 0x0032 200 200 000 Old_age Always - 31
193 Load_Cycle_Count 0x0032 198 198 000 Old_age Always - 8522
194 Temperature_Celsius 0x0022 114 095 000 Old_age Always - 38
196 Reallocated_Event_Count 0x0032 200 200 000 Old_age Always - 0
197 Current_Pending_Sector 0x0032 200 200 000 Old_age Always - 1
198 Offline_Uncorrectable 0x0030 200 200 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x0032 200 200 000 Old_age Always - 0
200 Multi_Zone_Error_Rate 0x0008 200 200 000 Old_age Offline - 0
SMART Error Log Version: 1
No Errors Logged
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed: read failure 90% 569 42084912
# 2 Short offline Completed without error 00% 388 -
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
My gdisk session under here: But the most usefull I got to in the end:
Warning! Main partition table overlaps the first partition by 34 blocks!
You will need to delete this partition or resize it in another utility.
user@debian:~$ sudo gdisk
GPT fdisk (gdisk) version 0.8.5
Type device filename, or press <Enter> to exit: /dev/sdc
Warning! Read error 5; strange behavior now likely!
Warning! Read error 5; strange behavior now likely!
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries.
Command (? for help): ?
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options (experts only)
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Command (? for help): n
Partition number (1-128, default 1): 1
First sector (34-5860533134, default = 2048) or {+-}size{KMGTP}: 2048
Last sector (2048-5860533134, default = 5860533134) or {+-}size{KMGTP}: 5860533134
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): l
0700 Microsoft basic data 0c01 Microsoft reserved 2700 Windows RE
4200 Windows LDM data 4201 Windows LDM metadata 7501 IBM GPFS
7f00 ChromeOS kernel 7f01 ChromeOS root 7f02 ChromeOS reserved
8200 Linux swap 8300 Linux filesystem 8301 Linux reserved
8e00 Linux LVM a500 FreeBSD disklabel a501 FreeBSD boot
a502 FreeBSD swap a503 FreeBSD UFS a504 FreeBSD ZFS
a505 FreeBSD Vinum/RAID a580 Midnight BSD data a581 Midnight BSD boot
a582 Midnight BSD swap a583 Midnight BSD UFS a584 Midnight BSD ZFS
a585 Midnight BSD Vinum a800 Apple UFS a901 NetBSD swap
a902 NetBSD FFS a903 NetBSD LFS a904 NetBSD concatenated
a905 NetBSD encrypted a906 NetBSD RAID ab00 Apple boot
af00 Apple HFS/HFS+ af01 Apple RAID af02 Apple RAID offline
af03 Apple label af04 AppleTV recovery af05 Apple Core Storage
be00 Solaris boot bf00 Solaris root bf01 Solaris /usr & Mac Z
bf02 Solaris swap bf03 Solaris backup bf04 Solaris /var
bf05 Solaris /home bf06 Solaris alternate se bf07 Solaris Reserved 1
bf08 Solaris Reserved 2 bf09 Solaris Reserved 3 bf0a Solaris Reserved 4
bf0b Solaris Reserved 5 c001 HP-UX data c002 HP-UX service
ef00 EFI System ef01 MBR partition scheme ef02 BIOS boot partition
fd00 Linux RAID
Hex code or GUID (L to show codes, Enter = 8300): ef01
Changed type of partition to 'MBR partition scheme'
Command (? for help): ?
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options (experts only)
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sdc.
Unable to save backup partition table! Perhaps the 'e' option on the experts'
menu will resolve this problem.
Warning! An error was reported when writing the partition table! This error
MIGHT be harmless, or the disk might be damaged! Checking it is advisable.
Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): Y
Command (? for help): p
Disk /dev/sdc: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 3995C753-D73D-4386-8818-3A9AF06E3B2C
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 2048-sector boundaries
Total free space is 5860533101 sectors (2.7 TiB)
Number Start (sector) End (sector) Size Code Name
Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): Y
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sdc.
Unable to save backup partition table! Perhaps the 'e' option on the experts'
menu will resolve this problem.
Warning! An error was reported when writing the partition table! This error
MIGHT be harmless, or the disk might be damaged! Checking it is advisable.
Command (? for help): p
Disk /dev/sdc: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): F1AE4B7D-9CCE-4211-BE3D-88DFFCCD3696
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Partitions will be aligned on 2048-sector boundaries
Total free space is 5860533101 sectors (2.7 TiB)
Number Start (sector) End (sector) Size Code Name
Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): n
Command (? for help): ?
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options (experts only)
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Command (? for help): d
No partitions
Command (? for help): i
No partitions
Command (? for help): r
Recovery/transformation command (? for help): ?
b use backup GPT header (rebuilding main)
c load backup partition table from disk (rebuilding main)
d use main GPT header (rebuilding backup)
e load main partition table from disk (rebuilding backup)
f load MBR and build fresh GPT from it
g convert GPT into MBR and exit
h make hybrid MBR
i show detailed information on a partition
l load partition data from a backup file
m return to main menu
o print protective MBR data
p print the partition table
q quit without saving changes
t transform BSD disklabel partition
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Recovery/transformation command (? for help): f
Warning! This will destroy the currently defined partitions! Proceed? (Y/N): Y
Problem loading MBR! GPT is untouched; regenerating protective MBR!
Recovery/transformation command (? for help): ?
b use backup GPT header (rebuilding main)
c load backup partition table from disk (rebuilding main)
d use main GPT header (rebuilding backup)
e load main partition table from disk (rebuilding backup)
f load MBR and build fresh GPT from it
g convert GPT into MBR and exit
h make hybrid MBR
i show detailed information on a partition
l load partition data from a backup file
m return to main menu
o print protective MBR data
p print the partition table
q quit without saving changes
t transform BSD disklabel partition
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Recovery/transformation command (? for help): v
No problems found. 5860533101 free sectors (2.7 TiB) available in 1
segments, the largest of which is 5860533101 (2.7 TiB) in size.
Recovery/transformation command (? for help): b
Recovery/transformation command (? for help): c
Warning! This will probably do weird things if you've converted an MBR to
GPT form and haven't yet saved the GPT! Proceed? (Y/N): Y
Warning! Read error 5! Misbehavior now likely!
Caution! After loading partitions, the CRC doesn't check out!
Recovery/transformation command (? for help): w
Warning! Main partition table overlaps the first partition by 34 blocks!
You will need to delete this partition or resize it in another utility.
Aborting write of new partition table.
No matter what I try to do, I seem to get the input/output error, I tried installing Ubuntu on it, and it seems to create the partition table, but when I start the install -- input/output error.
Anyone have any idea on how I can fix this? I’m happy to post more logfiles or whatever, but I’m not experienced with Linux, I just use it for this kind of stuff. The disk is very new, just some months, so I doubt it’s any bad sectors.
|
You have copy & pasted a lot of unnecessary transcripts but your first paragraph pretty much says it all:
When I run sudo gparted on a live ubuntu USB, I get Input/output error during read on /dev/sdc.
So you have a defective disk. The error comes directly on /dev/sdc (not /dev/sdc1 or /dev/sda2, etc...) so it applies to the whole disk. Therefore the partition table has nothing to do with it.
You should look at the output of dmesg or the contents of /var/log/kern.log to get additional information about the I/O error. If it's a defective sector then this will tell you which sector it is.
Doing a bad blocks scan with badblocks -w /dev/sdc might give you interesting output. It might also force the hard drive's onboard firmware to reallocate bad sectors from its spare sector pool so that you can continue using the drive.
| Cannot access disk, partition table broken |
1,404,431,914,000 |
I went through what I found about this subject in the most of the threads, unfortunately without success. I have the following situation. fdisk or parted doesn't recognize this sanDisk USB flash:
fdisk -l
root@debian:~# fdisk -l
Disk /dev/sda: 477 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: Intenso SSD SATA
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000b7798
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 11913215 11911168 5.7G 82 Linux swap / Solaris
/dev/sda2 * 11913216 1000215215 988302000 471.3G 83 Linux
fdisk /dev/sdb
root@debian:~# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sdb: 2 MiB, 2097152 bytes, 4096 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x88dde89e
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 4095 2048 1M 83 Linux
Command (m for help):
parted /dev/sdb
root@debian:~# parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: (file)
Disk /dev/sdb: 2097kB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 2097kB 1049kB primary
(parted)
df -h
root@debian:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 16G 2.0M 16G 1% /dev
tmpfs 3.2G 9.7M 3.1G 1% /run
/dev/sda2 463G 162G 281G 37% /
tmpfs 16G 717M 15G 5% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 16G 0 16G 0% /sys/fs/cgroup
tmpfs 3.2G 4.1M 3.2G 1% /run/user/1000
/dev/sdb1 15G 36M 14G 1% /media/USB/54c3f6a6-033c-434a-a6bc-44d60ba82df8
lsblk
root@debian:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 477G 0 disk
├─sda1 8:1 0 5.7G 0 part [SWAP]
└─sda2 8:2 0 471.3G 0 part /
sdb 8:16 1 14.3G 0 disk
└─sdb1 8:17 1 14.3G 0 part /media/USB/54c3f6a6-033c-434a-a6bc-44d60ba82df8
sr0 11:0 1 1024M 0 rom
lsusb
root@debian:~# lsusb
Bus 003 Device 002: ID 8087:8000 Intel Corp.
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 023: ID 0781:5591 SanDisk Corp. Ultra Flair
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 008: ID 138a:0017 Validity Sensors, Inc. VFS 5011 fingerprint sensor
Bus 002 Device 005: ID 058f:9540 Alcor Micro Corp. AU9540 Smartcard Reader
Bus 002 Device 006: ID 413c:2006 Dell Computer Corp.
Bus 002 Device 004: ID 413c:1004 Dell Computer Corp.
Bus 002 Device 011: ID 0765:5010 X-Rite, Inc. X-Rite Pantone Color Sensor
Bus 002 Device 010: ID 5986:026a Acer, Inc
Bus 002 Device 012: ID 17ef:6019 Lenovo
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
lsmod | grep usb
root@debian:~# lsmod | grep usb
btusb 53248 0
btrtl 16384 1 btusb
btbcm 16384 1 btusb
btintel 24576 1 btusb
bluetooth 647168 11 btrtl,btintel,btbcm,bnep,btusb
usb_storage 73728 2 uas
usbhid 57344 0
hid 135168 2 usbhid,hid_generic
scsi_mod 249856 6 sd_mod,usb_storage,uas,libata,sg,sr_mod
usbcore 294912 9 xhci_hcd,ehci_pci,usbhid,usb_storage,uvcvideo,ehci_hcd,btusb,xhci_pci,uas
usb_common 16384 1 usbcore
hdparm -I /dev/sdb
root@debian:~# hdparm -I /dev/sdb
/dev/sdb:
HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device
smartctl -i /dev/sdb1
root@debian:~# smartctl -i /dev/sdb1
smartctl 6.6 2017-11-05 r4594 [x86_64-linux-4.19.0-9-amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Vendor: SanDisk
Product: Ultra USB 3.0
Revision: 1.00
Compliance: SPC-4
User Capacity: 15,376,318,464 bytes [15.3 GB]
Logical block size: 512 bytes
Serial number: 4C530000080316205084
Device type: disk
Local Time is: Sat Jun 20 17:35:53 2020 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Temperature Warning: Disabled or Not Supported
root@debian:~# dd if=/dev/zero of=/dev/sdb bs=1M
dd: error writing '/dev/sdb': No space left on device
15873+0 records in
15872+0 records out
16643719168 bytes (17 GB, 16 GiB) copied, 4.11023 s, 4.0 GB/s
root@debian:~# fdisk -l
Disk /dev/sda: 477 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: Intenso SSD SATA
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000b7798
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 11913215 11911168 5.7G 82 Linux swap / Solaris
/dev/sda2 * 11913216 1000215215 988302000 471.3G 83 Linux
root@debian:~#
So basically the flash is 16GB, but neither fdisk nor parted nor gparted recognize it. In Nautilus ist is mounted as a 15 GB volume. The device information is in dmesg as well.
I tried to delete the partition, creating fat32, ntfs, and even using a Windows machine for that, but I still have this weird behavior.
I can use the flash as a 15GB volume, but I am very interested to know the explanation.
Thanks in advanced.
responses to comments and answers
root@debian:~# ls -l /dev/sdb
-rw-r--r-- 1 root root 16643719168 Jun 20 18:28 /dev/sdb
root@debian:~# blockdev --getsz /dev/sdb
32507264
root@debian:~# ls -l /dev/sdb
-rw-r--r-- 1 root root 16643719168 Jun 20 18:50 /dev/sdb
root@debian:~# df -h /dev
Filesystem Size Used Avail Use% Mounted on
udev 16G 0 16G 0% /dev
|
The problem seems to be that (for whatever reason) /dev/sdb is not a device file but a regular file. Both the output of ls -l (-rw-r--r--) and parted (Model: (file)) schow that.
This can be fixed by deleting and recreating /dev/sdb (the file):
rm /dev/sdb
mknod /dev/sdb b 8 16
| fdisk dowsn't recognize SanDisk USB 3 Ultra Flair |
1,404,431,914,000 |
I installed Linux Mint 18.2, as LVM with LUKS encryption, onto a 128GB SSDD. I would like to remove the swap drive b/c I have 16GB of RAM on my machine and I want to try to preserve the drive as long as I can. When I started the disk and started Gparted to remove the swap partition I noticed that Gparted lists the drive as only two partitions /dev/sdb1 ~.5GB boot-sector (I think) and /dev/sdb2 the crypt-luks container. When I checked /ect/fstab I noticed that this was the last line;
/dev/mapper/cryptswap1 none swap sw 0 0
Does anyone know a safe way to remove this kind of swap partition?
|
There shouldn't be any problem disabling a swap partition of any sort. Once booted, you can disable the swap partition with:
sudo swapoff -a
And then place a swap partition on some other disk and enable that with:
sudo swapon -U uuid-of-new-swap-partition.
Once you verify that the new swap is working, you can remove the LVM swap partition on your LUKS drive... and reuse the space. LVM is awesome!
To make the changes permanent, replace the swap partition listed in /etc/fstab with the new one using the same options as the prior swap... none swap sw 0 0
LUKS specific instructions
Apparently... There is a specific option with cryptmount for enabling and disabling swap.
cryptmount --swapoff
and
cryptmount --swapon
It seems that cryptmount will perform the close operation in addition to disabling the swap partition.
If you've disabled the swap with the regular system swapoff, you may need to disable the current swap partition (safe to do) to close the LUKS swap partition before you can remove it...
cryptsetup -v luksClose /dev/mapper/cryptswap1
| Removing the swap partition from a LUKS encrypted SSDD |
1,404,431,914,000 |
I thought I could nuke all partitions of a drive by using dd if=/dev/zero of=/dev/sdX. In the past this has always worked for me, but in this case it is not working as expected.
#check the partitions
➜ ~ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 477G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
└─sda2 8:2 0 476.4G 0 part /
sdb 8:16 1 14.6G 0 disk
├─sdb1 8:17 1 292M 0 part /media/james/Gentoo amd64 20190703T214502Z
└─sdb2 8:18 1 6.3M 0 part /media/james/GENTOOLIVE
#unmount and confirm the drive is still seen.
➜ ~ sudo umount "/media/james/Gentoo amd64 20190703T214502Z"
➜ ~ sudo umount "/media/james/GENTOOLIVE"
➜ ~ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 477G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
└─sda2 8:2 0 476.4G 0 part /
sdb 8:16 1 14.6G 0 disk
├─sdb1 8:17 1 292M 0 part
└─sdb2 8:18 1 6.3M 0 part
#Run dd
➜ ~ sudo dd if=/dev/zero of=/dev/sdb bs=3M
dd: error writing '/dev/sdb': No space left on device
2649+0 records in
2648+0 records out
8330620928 bytes (8.3 GB, 7.8 GiB) copied, 5.50879 s, 1.5 GB/s
#the partitions are still there!
➜ ~ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 477G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
└─sda2 8:2 0 476.4G 0 part /
sdb 8:16 1 14.6G 0 disk
├─sdb1 8:17 1 292M 0 part
└─sdb2 8:18 1 6.3M 0 part
➜ ~ lsblk
#after unplugging and replugging the drive, the old partition still mounts and still contains files. I was able to open several and read the contents.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 477G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
└─sda2 8:2 0 476.4G 0 part /
sdb 8:16 1 14.6G 0 disk
├─sdb1 8:17 1 292M 0 part
└─sdb2 8:18 1 6.3M 0 part /media/james/GENTOOLIVE
What is really confusing me is that if I look in Gparted, the device is shown as 8GB unallocated, but this is a 16GB drive.
I ran badblocks -wsv, which passed but did so suspiciously quickly (minutes instead of hours). After unplugging and replugging, the drive shows up as /dev/sdc, and Gparted sees 14.56GB partition called "gentoo"
Testing with pattern 0xaa: set_o_direct: Invalid argument/0/0 errors)
done
Reading and comparing: done
Testing with pattern 0x55: done
Reading and comparing: done
Testing with pattern 0xff: done
Reading and comparing: done
Testing with pattern 0x00: done
Reading and comparing: done
Pass completed, 0 bad blocks found. (0/0/0 errors)
➜ ~ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 477G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
└─sda2 8:2 0 476.4G 0 part /
sdc 8:32 1 14.6G 0 disk
├─sdc1 8:33 1 292M 0 part
└─sdc2 8:34 1 6.3M 0 part
I'm guessing I should just put this flash drive out to pasture, but it seems to me such an odd sequence of events, I'm curious as to what sort of failure might have caused it (not really looking for a fix).
Edit: This was on Xubuntu 18.04
Edit2: After a reboot, zeroing works as expected. I guess it was just a temporary issue with the OS. I'm still curious about what sort of issue though.
Edit3: I spoke too soon, a reboot was not sufficient. I thought dd was working because it was taking a normal amount of time, but it seems not.
➜ ~ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 477G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
└─sda2 8:2 0 476.4G 0 part /
sdb 8:16 1 14.6G 0 disk
├─sdb1 8:17 1 292M 0 part /media/james/Gentoo amd64 20190703T214502Z
└─sdb2 8:18 1 6.3M 0 part
➜ ~ sudo dd if=/dev/zero of=/dev/sdb
[sudo] password for james:
Sorry, try again.
[sudo] password for james:
dd: writing to '/dev/sdb': No space left on device
30629377+0 records in
30629376+0 records out
15682240512 bytes (16 GB, 15 GiB) copied, 4232.1 s, 3.7 MB/s
➜ ~ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 477G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
└─sda2 8:2 0 476.4G 0 part /
sdb 8:16 1 14.6G 0 disk
├─sdb1 8:17 1 292M 0 part /media/james/Gentoo amd64 20190703T214502Z
└─sdb2 8:18 1 6.3M 0 part
Edit 4: Ok, so dd did actually work, but lsblk did not update until I ejected and put back in.
➜ ~ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 477G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
└─sda2 8:2 0 476.4G 0 part /
sdb 8:16 1 14.6G 0 disk
Edit 5: I checked dmesg and there is a warning about the disk not being properly mounted.
➜ ~ journalctl --dmesg --since="3 days ago" | grep sdb
Jul 09 19:59:27 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] 30595072 512-byte logical blocks: (15.7 GB/14.6 GiB)
Jul 09 19:59:27 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] Write Protect is off
Jul 09 19:59:27 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] Mode Sense: 43 00 00 00
Jul 09 19:59:27 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Jul 09 19:59:27 james-Latitude-E7470 kernel: sdb: sdb1
Jul 09 19:59:27 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] Attached SCSI removable disk
Jul 09 19:59:33 james-Latitude-E7470 kernel: FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
Jul 10 02:38:38 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] 30629376 512-byte logical blocks: (15.7 GB/14.6 GiB)
Jul 10 02:38:38 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] Write Protect is off
Jul 10 02:38:38 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] Mode Sense: 43 00 00 00
Jul 10 02:38:38 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Jul 10 02:38:38 james-Latitude-E7470 kernel: sdb: sdb1 sdb2
Jul 10 02:38:38 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] Attached SCSI removable disk
Jul 10 04:12:42 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] 30629376 512-byte logical blocks: (15.7 GB/14.6 GiB)
Jul 10 04:12:42 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] Write Protect is off
Jul 10 04:12:42 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] Mode Sense: 43 00 00 00
Jul 10 04:12:42 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Jul 10 04:12:42 james-Latitude-E7470 kernel: sd 3:0:0:0: [sdb] Attached SCSI removable disk
|
#the partitions are still there!
This part, at least, is still normal. You have to re-read partition table to update the partition information. You can trigger a re-read with
blockdev --rereadpt /dev/sdx
(alternatively sfdisk --re-read but that option has been removed from recent versions of sfdisk).
For everything else, yes it's possible for flash based storage to fail into a readonly mode. Strange things might also happen for other reasons, for example if the USB connection is not stable, the /dev/sdx device might be dropped, and redetected as /dev/sdy and all writes to /dev/sdx go to limbo, but I guess that would have showed in your lsblk.
Sometimes there are interesting error messages in dmesg, but all in all... if your USB stick failed you just have to get a new one, no way around it.
For sake of completeness, there is also this special case here (user error):
# dd bs=1M if=/dev/zero of=/dev/sdx
dd: error writing '/dev/sdx': No space left on device
7956+0 records in
7955+0 records out
8341966848 bytes (8.3 GB, 7.8 GiB) copied, 2.08568 s, 4.0 GB/s
So. Did this command write to a device?
Not at all. I don't even have a /dev/sdx. Instead it filled my /devtmpfs with 50% RAM sized regular file of zeroes. (I really should adjust my tmpfs size limits. If you do this on two instances of tmpfs, the system crashes because RAM is full.)
That happens when the device is missing entirely, or devicename mistyped, since dd does not check at all for existence beforehand, and if your machine has lots of RAM, and /dev not limited to a sane size like 10M, then you get this confusing result.
| dd if=/dev/zero leaves drive contents in-tact? Bad USB stick? |
1,404,431,914,000 |
I am using GParted (0.28.1, Fedora 25) to format a external drive and noticed that the command displayed is:
mkfs.ext4 -F -O ^64bit -L "INSTALL" /dev/sdd1
When making disks in the past from command line I have just used mkfs.ext4 DEVICE which seemed to work well for various architectures. However the above includes the option -O ^64bit, which I guess removes some default 64bit feature of the filesystem so it works with 32bit. Does it do this and is normally necessary to pass it on modern Linux OSs (to enable compatibility with 32bit etc systems), and what cost could it have other than probably reducing the volume size limit?
|
The default options for mke2fs including those for ext4 can be found in /etc/mke2fs.conf. They could be different depending on the distro you're using. I'd take a look at that file on any distro you're curious about to see if the -O ^64bit param would be necessary. According to the man page the '^' is indeed the prefix used to disable a feature. The effect of not using 64bit ext4 is that you'll be limited to ~ 15T volumes. Where as you can have 1EiB volumes if you use the 64Bit flag. HOWEVER, 16T is the recommended max volume size for ext4 anyway.
| What does this mkfs.ext4 operand mean? |
1,404,431,914,000 |
I shrunk my root partition and it seems nice. But I am thinking about overwriting now at least the most important files from the backup copy (external drive, rsync, weekly backup) in order to be sure that none of my files got corrupted during the shrinking. That is probably a waste of time (and perhaps it may result in more fragmentation).
I can check that the files are OK after moving them during the shrinking by means of a CRC comparison with those in the backup (e.g. with md5sum) as one unser kindly says in his answer.
But specifically I would like a short explanation on the algorithm that GNU Parted uses in order to ensure that no data corruption happens while moving information from one sector of the disk to another, prior to the shrinking of the partition. Is there such algorithm, or the program copies bytes blindly? I would like to read a simple explanation.
|
Why can I rest assured that GNU Parted has not corrupted a single bit
after shrinking my partition?
You can't, in fact, gparted man page clearly says (under NOTES):
Editing partitions has the potential to cause LOSS of DATA.
......
You are advised to BACKUP your DATA before using the gparted application.
Reboot your system after resizing the partition and run fsck. If it doesn't find any errors then the operation was successful and the data is intact.
There have been issues in the past with gparted corrupting data when resizing partitions even though it wasn't reporting any error (e.g. see this thread on their forum and the warning linked there).
When resizing, (g)parted only moves the END position of partition NUMBER. It does not modify any filesystem present in the partition. Underneath, gparted uses fs specific tools to grow/shrink the filesystem.
You can get detailed information for each operation, as per the online manual:
To view more information, click Details. The application displays more details about operations.
To view more information about the steps in each operation, click the arrow button beside each step.
Let's see what it actually does when shrinking an ext4 partition (skipping the calibrate&fsck steps):
shrink file system 00:00:02 ( SUCCESS )
resize2fs -p /dev/sdd1 409600K
Resizing the filesystem on /dev/sdd1 to 409600 (1k) blocks.
Begin pass 3 (max = 63)
Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/sdd1 is now 409600 (1k) blocks long.
resize2fs 1.42.12 (29-Aug-2014)
As you can see, gparted does nothing, it just calls resize2fs -p with the specified device and new size as arguments.
If you're interested in the algorithm you could look at resize2fs.c. In short:
Resizing a filesystem consists of the following phases:
1. Adjust superblock and write out new parts of the inode table
2. Determine blocks which need to be relocated, and copy the
contents of blocks from their old locations to the new ones.
3. Scan the inode table, doing the following:
a. If blocks have been moved, update the block
pointers in the inodes and indirect blocks to
point at the new block locations.
b. If parts of the inode table need to be evacuated,
copy inodes from their old locations to their
new ones.
c. If (b) needs to be done, note which blocks contain
directory information, since we will need to
update the directory information.
4. Update the directory blocks with the new inode locations.
5. Move the inode tables, if necessary.
Filesystem resizing should be a safe operation, as per one of the authors, Ted Tso:
resize2fs is designed not to corrupt data even if someone hits the Big
Red switch while it is operating. That was an explicit design goal.
but like all code, it isn't bug-free.
Once fs resize is done, gparted shrinks the partition:
shrink partition from 500.00 MiB to 400.00 MiB 00:00:00 ( SUCCESS )
old start: 2048
old end: 1026047
old size: 1024000 (500.00 MiB)
new start: 2048
new end: 821247
new size: 819200 (400.00 MiB)
Bottom line: always backup your data before altering partitions/filesystems and run fsck after making the changes.
| Why can I rest assured that GNU Parted has not corrupted a single bit after shrinking my partition? |
1,404,431,914,000 |
In CentOS 8.0 Server with desktop, I am trying to install gparted. It's not in the native software app, so I tried:
sudo yum install epel-release
sudo yum install gparted
and when I ran the latter, I see
Error: Problem: conflicting requests
- nothing provides PolicyKit-authentication-agent needed by gparted-1.0.0.4.el8.x86_64
(try to add '--skip-broken' to skip uninstallables packages)
When I did, I saw:
Last metadata expiration check: 1 day, 2:43:25 ago,.....
Dependencies resolved.
Nothing to do.
Complete!
but sudo yum install gparted still fails in the same way.
|
The encountered error which is missing policykit-authentication-agent dependency package does not look essential to run gparted.
You can try
dnf download gparted
sudo rpm -i gparted-downloaded-package-name.rpm --nodeps
sudo gparted
| CentOS 8 install gparted fails |
1,404,431,914,000 |
I am currently dualbooted between Windows 8 and Linux Mint 18
Using GParted, I see this following:
The selection partition is unallocated for a size of 25 GB, I would like to merge this with my dev/sda6 (linux partition), so that I can make my linux partition about 50GB. I'm not really sure about the process though on how to do this? I try to resize dev/sda6, but I see that the maximum size and minimum size are the same. How do I merge the unaccolated space?
|
The free space and your existing Linux partition are not contiguous, so you can't simply merge them. Linux's own partition scheme, LVM, allows a filesystem to be split between separate location on the disk or even between disks. But native MBR or GPT partitions have to be a single contiguous area.
Moving the partition in the middle would be complicated because there isn't enough space for a non-overlapping move. Unless you move it to another disk and then back, I recommend switching Linux to use LVM, which has other benefits as well.
The tool blocks (formerly lvmify) by Gabriel can convert an existing partition in place. Run it from a live CD/USB.
blocks to-lvm --vg-name=mint /dev/sda6
lvrename mint sda6 root
This will make your system unbootable, so you need to do one more thing before you reboot. Mount the volume and get ready to run commands in Mint via chroot:
mkdir /media/root
mount /dev/mapper/mint-root /media/root
mount --rbind /proc /media/root/proc
mount --rbind /dev /media/root/dev
mount --rbind /sys /media/root/sys
chroot /media/root
Run update-grub and update-initramfs. Now your system will have the necessary drivers at boot time to boot from LVM.
You can now reboot to your Linux installation and add more space to the LVM volume. Create a partition /dev/sda8 encompassing the space you want to use. If asked for a partition type, select LVM physical volume. Then run the following commands to add the space to your root partition.
pvcreate /dev/sda8
vgextend mint /dev/sda8
lvextend mint/root /dev/sda8
resize2fs /dev/mapper/mint-root
| How can I merge unallocated hard disk space to my linux partition? |
1,404,431,914,000 |
Current Environment Information:
Dual Boot with Windows 7x64 and Linux Mint 16
I am currently trying to install Elementary OS instead of Linux Mint.
Windows works fine but Mint boots fine but has some problems (Cinnamon Crashes and unable to browse other drives) so cannot use for regular use. So I decided of trying the newly released Elementary OS.
I started the Install reached the step for "Installation Type" and selected "Something Else" as I already has the partitions where I would be installing it. But then it didn't show /dev/sda partition structure.
LiveCD runs from sdb1, so I canceled and ran parted, fdisk, fixparts(readonly).
Image from Easues Partition Magic https://i.sstatic.net/hJcbq.jpg taken on Windows 7
Here Is the Output:
elementary@elementary:~$ sudo parted /dev/sda print
Error: Unable to satisfy all constraints on the partition.
elementary@elementary:~$ sudo fdisk -l /dev/sda
Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x880afec3
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 206847 102400 7 HPFS/NTFS/exFAT
/dev/sda2 206848 164812799 82302976 7 HPFS/NTFS/exFAT
/dev/sda3 290840760 488392064 98775652+ 7 HPFS/NTFS/exFAT
/dev/sda4 164814847 290840759 63012956+ f W95 Ext'd (LBA)
/dev/sda5 164814848 196298297 15741725 83 Linux
/dev/sda6 196298298 290840759 47271231 7 HPFS/NTFS/exFAT
Partition table entries are not in disk order
elementary@elementary:~$ sudo fixparts /dev/sda
FixParts 0.8.8
Loading MBR data from /dev/sda
Warning: 0xEE partition doesn't start on sector 1. This can cause problems
in some OSes.
MBR command (? for help): p
** NOTE: Partition numbers do NOT indicate final primary/logical status,
** unlike in most MBR partitioning tools!
** Extended partitions are not displayed, but will be generated as required.
Disk size is 488397168 sectors (232.9 GiB)
MBR disk identifier: 0x880AFEC3
MBR partitions:
Can Be Can Be
Number Boot Start Sector End Sector Status Logical Primary Code
1 * 2048 206847 primary Y 0x07
2 206848 164812799 primary Y 0x07
3 290840760 488392064 logical Y Y 0x07
5 164814848 196298297 logical Y Y 0x83
6 196298298 290840759 omitted 0x07
MBR command (? for help): s
MBR command (? for help): p
Disk size is 488397168 sectors (232.9 GiB)
MBR disk identifier: 0x880AFEC3
MBR partitions:
Can Be Can Be
Number Boot Start Sector End Sector Status Logical Primary Code
1 * 2048 206847 primary Y 0x07
2 206848 164812799 primary Y 0x07
3 164814848 196298297 logical Y Y 0x83
4 196298298 290840759 omitted 0x07
5 290840760 488392064 logical Y Y 0x07
MBR command (? for help): q
This will abandon your changes. Are you sure? (Y/N): y
elementary@elementary:~$
I am not getting what the problem is! As I had previously successfully installed different versions of Ubuntu's, Linux Mint's.
If anymore information is required please comment. Any help is appreciated.
|
Your partition table looks OK, but it's a bit odd. In particular, most partitioning tools put a data structure known as an Extended Boot Record (EBR) in the sector immediately preceding the logical partition it describes. In your case, though, there's no gap between your logical partitions 5 and 6, so your partition 6's EBR must be located somewhere else. This is legal, but it's unusual. My suspicion is that libparted (used by parted, GParted, and most GUI Linux installers) is confused by this placement, resulting in the empty partition table you're seeing.
You might get a little more information on this by running parted on the disk, as in:
sudo parted /dev/sda print
If I'm right, there may be an error message that describes the problem (most likely using confusing terms). It's conceivable that the message will suggest a fix. If so, you could try that (but see my caveat below).
The easiest way to fix this is likely to be to shrink partition 5 or 6 so open up a short gap between them. (Just one sector should be plenty, but most partitioning tools align on 1MiB boundaries, so you may need a 1MiB gap.) The trouble is that GParted doesn't see partitions, so you can't use it; and the built-in Windows tools will most likely try to convert the disk to a Logical Disk Manager (LDM) format, which will render Linux unbootable. The EaseUS program you used for your screen shot may well do the job safely, but I can't promise that.
If you resize the partitions as I suggest and GParted still shows the disk as empty, run FixParts on it, as you've already done. This time, though, FixParts should not show any partitions as "omitted." You should then be able to type w to save your changes (which would be nothing but re-writing EBRs in a way that parted would like).
The big caveat: Because your partition table is a bit unusual, any changes you make are risky. I'm the author of FixParts, so I know its capabilities; but even with FixParts, I can't promise how it will react to your disk after you make the change I suggest. Worse, a resizing operation is risky at the best of times, and because of your partition table oddities, it's even riskier. I strongly recommend you back up important data before doing anything more with your disk.
| Gparted showing complete drive unallocated |
1,404,431,914,000 |
I know this isn't a question that's specific to Unix/Linux, but I think there are people who can answer this question here.
I want to hide my Windows partition from the partition table completely, then later I want it to come back. I'm sure it's something simple to do, but it's safer to ask people who know instead of fiddling with the partition table myself and mistakenly lose my data.
By "hide" I mean I want that area of the disk to appear unallocated. Basically remove the "partition entry" if that makes sense without removing the data itself, so later I can just change the partition table again to make it have a partition entry at the exact location, so I can access it again.
|
Make a backup of the partition table (sfdisk -d /dev/sda >sda.txt (DOS MBR)
or sgdisk --backup=<file> <device> (GPT)).
Delete the partition.
Restore the partition table from the backup.
Warning: Under certain conditions deleting even an unused partition may prevent your Linux from booting. This can happen if the system has references to a partition with a higher number. GRUB e.g. (I am not familiar enough with GRUB2 to assess that). My distro has been advising against using references like /dev/sda7 in fstab for years. Mounting LVM / MD volumes or partitions by label or UUID is not a problem.
| Hide a partition in the partition table and make it reappear later |
1,404,431,914,000 |
why does df command and gparted show different free space?
In my case, I have:
$ df -hT
Filesystem Type Size Used Avail Use% Mounted on
[...]
/dev/sda4 ext4 184G 173G 1.6G 100% /home
and the same results from Nautilus
while gparted shows:
Size Used Unused
186.47GiB 175.58 GiB (94%) 10.90 GiB (6%)
|
Previously answered here
Gparted will be looking at actual inodes and disk-level info to determine how much is free, whereas df will be looking using the filesystem tools themselves[...]
| free space inconsistency |
1,404,431,914,000 |
I will be installing Windows 10 and Linux (dual-boot) on a new computer in a couple of days. I would like to use GPT instead of MBR for the partition table.
As I understand it (and have done in the past), it is much easier to install Windows first (and let it try to dominate the machine 😊) followed by the Linux install with grub allowing the dual boot.
Can I use the live USB stick with Linux to run gparted and create the GPT partition table, then boot Windows from its USB installer? Will Windows "respect" the partition table that I have created?
|
Latest Windows can install automatically on GPT, and then proceed with Linux install as usual, modifying partitioning setup as required. Why would you partition first?
| Using gparted before installing Windows 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.