date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,487,538,464,000 |
Source code is text; text is architecture-independent data (i.e., /usr/shareable).
Would it be, for some reason, a bad idea to have /usr/src/ link into /usr/share/src in a Linux distro?
|
In Unix and clones like Linux, /usr/src is not just for any source code. It is traditionally where you put the source code for the running operating system. The basic build tools for each OS and their configuration files are set to use /usr/src and if all you did was ln -fs /usr/share/src /usr/src then those tools are... | /usr/share/src? |
1,487,538,464,000 |
I'm trying to make a program (Thunderbird) run at startup, but when I go to usr/bin it seems empty. However, if I run $ which Thunderbird in terminal, it tells me /usr/bin/thunderbird.
The usr/bin folder has the option to display hidden files checked. What could be the reason I can't find any files in that folder?
|
Make sure you are typing in /usr/bin, not usr/bin.
The latter means "look for usr/bin starting in the current directory." For example, if your current directory is your home directory (~), then it will look for ~/usr/bin.
The former means "look for /usr/bin starting from the root directory." This makes sure that the s... | usr/bin appears empty |
1,487,538,464,000 |
I have a couple command line php scripts and also php pages that call the same class file. Instead of having mutiple copies of it floating around, I want to put class.myApi.php in one central location on the filesystem. All files will then reference that one single file. Where does it belong? Does it belong in /usr/b... |
I would suggest either /usr/local/share/php/your-app-name or /opt/local/share/php/your-app-name.
| where on the filesystem do user-generated system scripts go? |
1,487,538,464,000 |
I'm building a control device that runs Debian Jessie on a ARM based Linux SBC. I'm curious what the recommended location is for application files? To date, I've been placing things in a root level directory, e.g.
/MyApplication
But I was toying with moving it to /root/ since it's a single user deployment, e.g.
/root... |
Certainly you have tighter control of the environment on an embedded system than you do on a desktop or server, and you can probably get away with putting your files anywhere you like (subject to constraints like avoiding read-only filesystems, which embedded systems often have).
That being said, I would definitely av... | Where to place application files in embedded linux deployment? |
1,487,538,464,000 |
I need to increase the logical volume of the var directory, the maximum size of var right now is 10GB, I need to make it 50GB. I have a Centos 6 server.
The output of df -h is:
Filesystem Size Used Avail Use% Mounted on
rootfs 10G 10G 0 100% /
/dev/root 10G 10G 0 10... |
As I expected from the name /dev/root, you're not using LVM. You have a few options:
Reinstall
Hope that your partitioning scheme allows you to grow the root partition with (g)parted.
Create a new partition as LVM volume, create a vg and and an lv for /var and move /var over
Clean up the current system so you don't ... | increasing a logical volume |
1,487,538,464,000 |
I am looking for a command that will write the names of all directories, subdirectories and file names to a text file.
Example format:
directory1
|_subdirectory1
| |_filename1.mp4
|_subdirectory2
| |_filename2.txt
| |_filename3.jpg
|
directory2
|
...
So the text file will only just show what the directory, subdirecto... |
tree command with -o option.
For example to output contents of /home to file.txt
tree /home -o file.txt
You will probably need to install tree package, since it is usually not installed by default.
There are other options available which you can see with:
tree --help
| Write directories, subdirectories and file names to .txt file |
1,487,538,464,000 |
I have a shell function which operates in-folder (in my case, it looks for *.eps` files and convert them to pdf without blank borders). Let us abstract this by the below function:
function do_here() {
echo $(pwd)
}
I look for an intelligent way to traverse directories and paths given root path ROOT_PATH and opera... |
Bash also supports ** for recursive globbing, provided shopt -s globstar is set. And you can get only directories if you suffix the glob with a /. Add dotglob so you don't miss directories with names starting with a dot.
So, e.g.
#!/bin/bash
shopt -s globstar
shopt -s dotglob
do_here() {
echo "working in $(pwd)...... | Operate and output inplace results |
1,487,538,464,000 |
I have 2 independent folders A and B. B has many files with the extension .build. Across A there are a fe subdirectories that have the same structure as subdirectories of B.
For example A has some_path/Tools/Camera/ and B has different_path/Tools/Camera. Say I manually identified 2 subdirectories one in A one in B tha... |
Enable the globstar Bash shell option: shopt -s globstar
Now change directory into B and run:
for path in **/; do
[ -d "<A-dir>/$path" ] && cp -n "$path/"*.build "<A-dir>/$path"
done
This will recursively check each subdirectory in B and see if there is an equivalent subdirectory in A. If there is then it will co... | How to copy all files with same extension between identical directory structures? |
1,487,538,464,000 |
I'm trying to write a find command that searches for all files or directories with the name andreas in them (forward slashes added for clarity).
~$ find . -iname '*andreas*'
./Documents/Resume - Andreas/
./Documents/Resume - Andreas/Resume-Andreas-Renberg.odf
./Documents/Resume - Andreas/Resume-Andreas-Renberg.pdf
./D... |
You could prune matches of type directory:
find . -iname '*andreas*' -print -type d -prune
From man find:
-prune True; if the file is a directory, do not descend into it.
| Find all files OR directories (without contents) that match a name |
1,487,538,464,000 |
On PCs, the XDG Desktop specifications allow the individual desktops to set different folders for various data. When writing an application that will only ever be run on servers, should one simply hardcode /etc/myapp, /var/cache/myapp etc, or are there potential environment variables or similar that should be checked?... |
Most Linux applications that I know of indeed hardcode paths but sometimes allow to redefine them using environment variables and command line arguments.
I see nothing wrong with hardcoding these paths but maybe you'll make the lives of your potential app users easier if you allow to specify the configuration file loc... | What directory specifications need to be followed on servers? |
1,487,538,464,000 |
I need to draw the tree structure of the following code.
cd /; mkdir a b c a/a b/a; cd a; mkdir ../e ../a/f ../b/a/g; cd../b/./; mkdir /a/k a/b ../a/./b /c
I know that: cd /; (goes to root) , mkdir creates directories a b c but I can't understand the rest of the line.
Any thoughts would be really helpful.
|
This is written in a confusing manner and I'm assuming comes from a basic linux/unix test. I can explain. It will seem clearer if it is on multiple lines. The ; char means end of a command. The mkdir command can do multiple things with one execution.
cd /
You will be in / as your current working directory.
mkdir a b ... | Tree structures and directories [closed] |
1,487,538,464,000 |
I have a directory-tree which contains files with the same name, e.g.:
a/file
a/...
a/b/file
x/a/file
x/a/...
x/b/file
I'm trying to use find (with -exec and -prune) to get all paths where file occurs first when recursively searching the tree. My example would return:
a/file
x/a/file
x/b/file
It does not return a/b/... |
find . -type d -exec sh -c '
f="$1"/file
[ -e "$f" ] && { printf "%s\n" "$f"; true; }
' find-sh {} \; -prune
Instead of finding files I find directories and test the existence of file in each directory. If file exists, the path to it is printed and -prune activated for the directory.
Notes:
true is there to ma... | Recursively search directories for a filename, stop descending if found |
1,487,538,464,000 |
I have a directory containing about 7k folders. These folders were extracted from zips and some of the extraction was done using Python scripts. Some of these folders are extracted in such a way that
Main Dir
|
---------------
| |
fold1 fold2... |
The following script will search the current working directory for paths of the form a/B/B/c and compress them to a/B/c. This also compresses a/B/B/B/B/c to a/B/c and a/B/B/c/D/D/e to a/B/c/D/e.
You need GNU find to use the -regextype option and an implementation of mv supporting -n. If you don't have these please hav... | How to move some specific folder keeping a predefined directory structure? |
1,487,538,464,000 |
I am wondering if there is a convention on where to store the data folder containing all the files for the tables and rows of a relational database system such as Postgres.
|
On OpenBSD, the (OpenBSD) postgresql-server package will be preconfigured to use /var/postgresql/data for its databases. It also adds a _postgresql service user with /var/postgresql as its home directory.
Storing databases under /var makes sense as they generally contain variable data. If your /var partition is not ... | On FreeBSD, or other BSDs, what directory is commonly used for data folder storing the content of a database such as Postgres |
1,487,538,464,000 |
I have a stand-alone web app, it's an executable file. At this point it doesn't require nginx or apache in front of it because it has a built-in webserver. Where should I put it on a server? In the directory of my user? Or in /opt/something or somewhere else?
Also, it's controlled by systemd.
|
Traditionally, the location for this would be /usr/local (resp. /usr/local/bin if this is just one executable). See What is /usr/local/bin? and What is the difference between /opt and /usr/local? .
| Where should I put a standalone web app which doesn't require an external web server? |
1,487,538,464,000 |
I need to know how to get the 4th directory name into the tree. this directory var changes while working through it using a loop, so while the loop is running always updating this directory structor I need to update this and keep it current
/dir 1/dir 2/dir 3/dir 4/dir 5/
I only need to get that name that is in that ... |
If your file is saved as $FILENAME, these will all give you the 4th directory. In these examples, I am manually setting
FILENAME="/media/data/temp1/Joe Jackson - The Ultimate Collection/CD2/Jumpin' Jive Live - Joe Jackson.mp3"
Use the shell:
$ dir=${FILENAME#*/*/*/*/}; echo ${dir//\/*}
Joe Jackson - The Ultimate Co... | how do I extract the SubDir name 4 deep & put into a Var 4 later use? |
1,487,538,464,000 |
I'm building several (> 10) packages as a non-root user from source, and want to install them (for the sake of this question, choose the --prefix= value). Two obvious options are:
Use my home directory, which means I'll have etc/, usr/, var/ and similar subdirs, and within each of them will be the files for different... |
Eventually I decided on $HOME/opt/myfooapp. The reasons are:
Options 2 and 3 allow me to separate the file hierarchies of the different packages; that's less of a consideration when you're working on / as the root user - since you have a package manager to help you. I don't...
Only option 3 avoids cluttering my home ... | Where should I install packages built from source as a non-root user? |
1,487,538,464,000 |
I have a directory(INPUTDIR) with sample names as subdirectories(508_C,540_C,570_D etc).Within those each subdirectories there is another directory called FASTQ which contains two kinds of files.
e.g.
540_Ct_1.fastq.gz
540_Ct_2.fastq.gz
I want to create two lists,the first having all _1.fastq.gz filenames with path... |
cd INPUTDIR
find . -name \*1.fastq.gz > list1
find . -name \*2.fastq.gz > list2
The paths in the "list" files will be relative to the current directory. If you want absolute paths, use
find "$PWD" -name \*1.fastq.gz > list1
| Creating a list containing filenames with paths |
1,487,538,464,000 |
When I first log in to Unix on my Mac, I usually see a ~ after my username in the command line.
However, if I look at the apps contained in that directory ~/Applications they are not all of my applications, but rather just some of my chrome apps.
If I cd to my / directory, and then go to /Applications there I see all... |
~ is your home directory, / is the root directory.
~ is where you keep your personal files and directories. Other users can't see or access them. Files and directories in / are system-wide and accessible to all users who have the right permissions.
Startec is a link, which allows you to have two pointers to the same d... | What is the difference between ~ and / in paths [duplicate] |
1,346,614,573,000 |
Long story short, i just accidentally deleted my entire home folder. Thankfully it seems like the hidden files are still there.
I'm not sure, but aren't all of the folders within the home folder (Desktop, Downloads and whatever else is in there) empty by default? If that is the case, could some super nice person just ... |
How about making a new user, and then copying all the hidden files to this new user. You could then rename the new user to your old one. I don't know the specifics of your situation, but I think this is better than manually recreating the default folders.
| Home folder structure in Ubuntu 12.04.1? |
1,346,614,573,000 |
using terminal on MAC OS I need to return path along with the file name in the a directory and all sub-directories, but only if a fie has a specific file extension (e.g. .txt).
I tried this, but it does not filter by file extension:
find $PWD/* -maxdepth 20
I also tried this, but it does not return me a directory pat... |
If you're on macos, then your shell is likely zsh, then:
print -rC1 -- $PWD/**/*.txt(N)
Would print raw on 1 Column the full paths of the non-hidden files (of any type including regular, symlink, fifo...) whose name ends in .txt in the current working directory or below, sorted lexically
Add the D qualifier (inside t... | Return all files of a specific extension with directory and subdirectories paths |
1,346,614,573,000 |
Here is my file structure. I am currently residing in test2/ directory, and all commands must run from there.
test/
|_test2/
publish/
|_subfolder1/
|_f1
|_f2
|_f3
|_subfolder2/
|_f4
|_f5
|_f6
|_f7
I need to do the following
Create a tar.gz of subfol... |
To archive the contents of foo, change to foo and tar the current directory: -C /some/dir/foo .. To archive the foo directory itself, change to foo's parent directory and tar foo: -C /some/dir foo.
So the commands would look like:
tar -zcf ../../publish/subfolder1/subfolder2.tar.gz -C ../../publish/subfolder1 subfolde... | Create a tar.gz file from a different directory, tar must keep files in specific directory structure |
1,346,614,573,000 |
About share data (files and directories) among users within the same machine, has sense use the /srv directory it according with:
What's the most appropriate directory where to place files shared between users?
I am assuming it is still valid or recommendable - correct me if that changed
But - What should be the dir... |
There are 2 kinds of programs:
Linux like. Their files are spread over all filesystem in accordance to files type/usage.
No issues with that kind of programs. They are managed well by package managers.
Windows like. Every program file in one program-specific folder. Like C:/Program files/XXX
Not good way. But if you... | What's the most appropriate directory where to place development software shared between users? |
1,346,614,573,000 |
What is the prevailing (or correct) convention on where to install cross-platform libraries?
E.g. libfoo.so.1.0.0 compiled for the host might typically be located at /usr/local/lib/. If I also had to install libfoo for a non-host architecture, e.g. ARM, where should it go?
Some reading leads me to /usr/local/lib/aarch... |
It's really up to you as long as it's a separate directory not used by your system.
You can even use something like /opt/arm64 or even /arm64.
| What is convention on where to install cross-platform libraries? |
1,346,614,573,000 |
This is easier to explain with an example. Imagine I have a directory structure as follows:
pics/cats/png/01.png
pics/cats/png/02.png
pics/cats/jpg/01.jpg
pics/cats/jpg/02.jpg
pics/dogs/png/01.png
pics/dogs/png/02.png
pics/dogs/jpg/01.jpg
pics/dogs/jpg/02.jpg
I would like to rsync the "pics" directory to a destinatio... |
You can get all the leaf nodes, filter them with grep and save the result to a file.
Then you run rsync with the --files-from option.
That is just the basics. You could filter directly in awk and/or pipe directly to to xargs for example. I'm not trying to be concise or performant, but to show the steps involved.
If yo... | How to rsync a large directory tree, but only leaf directories that match a regex? |
1,346,614,573,000 |
I've got 2 very old Backups of a friends computer. They were simply copied into a folder each on an external Harddrive. Both are about 300GB in Size and the contents are very much alike but not identical and the folder-structure is different. I want to free that space and make one single Backup of those two. I think a... |
If the aim is to preserve file content (avoid losing data), I would concentrate on file equality, not the naming of directories of files.
Start with running this on each of the top-level folders, and save the output (it will run for a while!).
find FolderA -type f -print0 | xargs -0 cksum > FoldA.cksum
find FolderB -t... | Compare large directories recursively - but ignoring sub-directories - compare two backups - with gui |
1,346,614,573,000 |
If I have a program that copies and modifies scripts or code-files as part of its operation, where should these other "default" or "template" scripts be installed?
|
/usr/local/share, /opt, or users directory.
/usr/local follows the same structure as /usr however it is for you to put your own stuff into. /usr is for the system installer to manage. Don't get in its way. /usr/local will not be touched by built in tools, so can be backed up and managed more easily.
/opt is also (lik... | Where should I install template scripts? [closed] |
1,346,614,573,000 |
Is there a Linux utility for creating templates for directory structures, outside of the scripts packaged with a DE like Gnome or LXDE? (I run openbox and would like to avoid a DE at all costs)
There is this post talking about template files, which I will absolutely use, and there is the template toolkit but that's mo... |
The mtree(1) utility is standard on BSD systems, and I'm pretty sure it ought to be available for Linux as well somewhere. It reads a directory hierarchy specification and compares it with what's found on disk, optionally deleting files (or updating their permissions or ownership) and creating missing directories as ... | Tool for creating and calling folder structure templates? |
1,346,614,573,000 |
When browsing to trash:/// in Nautilus, I see a long list of files and directories that I recognize and remember placing in the trash. However, attempting to delete them from Nautilus either results in a Preparing message indefinitely, or an error message Error while deleting. You do not have sufficient permissions to... |
This problem was actually being caused by having a .Trash-1000 folder on the external drive itself, with all the contents I was seeing in Nautilus within it.
In order to delete these files, I had to remount that drive as writable:
sudo mount -o remount,rw /partition/identifier /mount/point
After this point, I was ab... | Nautilus shows files in Trash, can't be located on cli |
1,346,614,573,000 |
My main directory is
/home/hts/.hts/tvheadend/input/dvb/networks/1d38df81855dee2d39e692ecc4caf05c/muxes
In there are many more directories with radomly generated names
Example:
/027941cc4936a3a3515c78487abc5445/
/4ab4097f4089f9e6d3c062a96f027707/
/8224af212d24d291570864021d9107a3/
/bffd49d7d6af0f6405b1dba81df7... |
as has been posted in the comments so many options;
#!/bin/bash
find /home/hts/.hts/tvheadend/input/dvb/networks/1d38df81855dee2d39e692ecc4caf05c/muxes -maxdepth 1 -type d | while read ad; do
find "$ad/config/services/" -type f -exec sed -i 's/"enabled": true,/"enabled": true,/' '{}' \;
done
or
#!/bin/bash
dirarr... | Execute command in dynamic directories via shell script |
1,346,614,573,000 |
I have certain directory path like this /backup/data/cm/au and /backup/data/cm/ds. I have to create paths from /cm/au and cm/ds in tmp with same owner and group of their originals.
|
Your question is a little vague, but it looks like you want something like
# cd /backup/data
# cp -a cm /tmp
If you don't want to copy all of the cm directory, do
# cd /backup/data
# cp -a cm/au cm/ds /tmp
The -a option tells cp to preserve as much meta-data as possible.
For it to preserve ownership (rather than ma... | Clone directories [closed] |
1,346,614,573,000 |
When installing a library with configure, make and make install,
does make install copy <libraryname>.pc to some place?
If yes: Where is it?
If no: Should we copy it somewhere rather than leave them where they are?
I am asking that, because on an old notebook of mine, I saw:
add the directory containing libraryna... |
In general, ./configure && make && make install without any parameters sticks everything under /usr/local, which would place foo.pc in /usr/local/lib/pkgconfig/foo.pc
To make use of this, you'd need to do basically PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH} pkg-config --cflags foo, or, compile in this... | Where is <libraryname>.pc? |
1,346,614,573,000 |
I'm trying to write a command that uses mv to move files two directory levels up.
So if the folder order goes like this: ~/Test/2020-08-01/001/002/file.txt, I want to move file.txt from directory 002 to directory 2020-08-01.
When I type out this command from my home directory mv ~/Test/2020-08-01/001/002/* ../.. I get... |
The issue is that ../.. in your command is relative to your current directory. If your current directory is /home/user, then ../.. refers to the root of the directory hierarchy (where your non-privileged user can't write).
To move file.txt from ~/Test/2020-08-01/001/002 to ~/Test/2020-08-01, use
mv ~/Test/2020-08-01/... | Moving folder contents up 2 directory levels |
1,346,614,573,000 |
I am trying to make a photo organizer with a zsh shell script. But i am having trouble creating sub directories within each main directory(based on date). Currently the script starts from a folder i created and gets one argument(the file it needs to edit, hence the first cd $1). Secondly, i do some name changing whic... |
for d in *;
do
cd $d
As far as I can tell this is the error. You've created a loop over your directories d. You cd into $d. But your loop never cd's back out
done
cd ..
done
So on the second iteration with the second $d, you're still in the first subdir, which of course does not contain th... | How can i create sub directories within a directory? [closed] |
1,346,614,573,000 |
I am using Debian 11
I would like to move /var and /home directories to a NVME partition nvme1n1p1 I have attached to the server.
EDIT: I am able to move the home folder and bind to the partition. But seems I have not done correctly somewhere. Because I see the read/write speed is not high.
How to do this correctly pl... |
I was able to fix it. I was not mounting the NVME at startup
here's the revised script that I used to solve. Posting in case if anyone needs it.
lsblk
sudo -s
cd /
sudo fdisk /dev/nvme1n1
sudo mkfs.ext4 /dev/nvme1n1p1
sudo mount /dev/nvme1n1p1 /mnt/
sudo mkdir /mnt/var/
sudo mkdir /mnt/home/
sudo rm -rf /mnt/lost+fou... | Move /var and /home directory on a separate NVME partition |
1,346,614,573,000 |
How can I inspect two directory trees to determine if they are identical. Are there some good tools that allow tree merging that is free?
I am using Ubuntu Linux 20.04 LTS on an x86_64 architecture.
I am interested in the contents of the files or directories, whether they are identical (in regards to source code or te... |
A simple diff Linux command will be sufficient.
Shown below is a structure of folder and sub folders we've created:
It contains two sub-folders, each with two text files (file1.txt and file2.txt) to be compared.
file1.txt is identical at folder1 and folder2
Using the following, will compare both folders and with all ... | Inspecting two directory trees |
1,346,614,573,000 |
I would like to use dmenu to open files. I figured out how to get this to work if the file is in my home directory:
#!/bin/sh
FILE="workbook.pdf"
zathura "$FILE"
However, I cannot get it to work with files from my sd card. I tried:
#!/bin/sh
FILE="mnt/School/Latin/Lingua\ Latina/Workbook/workbook.pdf"
zathura "$F... |
You are missing one slash at the beginning, the path should start with:
/mnt/...
instead of
mnt/...
It is formally called the root directory and with it (/) every full path begins. More info here for example.
| Opening file from sd card using dmenu |
1,346,614,573,000 |
I have a scenario where I want to create a main folder sub folder child folder and file in that child folder
my text file contain below format
ABC|A1|B1|A.txt
ABC|BB|CD|AF|JIDS.txt
ABC|BB|CDE|AFD|KL|JI.pdf
This above file need to be passed in form of for loop
Lets take an example of first record
ABC|A1|B1|A.txt
A... |
For each line, change all |-characters to / to form a pathname, create the directory, create the file at the end of the pathname.
tr '|' '/' <file |
while IFS= read -r pathname; do
mkdir -p "$(dirname "$pathname")" &&
touch "$pathname"
done
Result:
$ tree ABC
ABC
|-- A1
| `-- B1
| `-- A.txt
`-- BB
... | How do i create main folder subfolder and file name |
1,346,614,573,000 |
I would like to standardize on a directory where normal users would put programs/installs which would be used by other users. What would be the best practices? For instance, I could create a /users/shared_binaries/ directory with fairly open permissions. Is there a convention/best practice for doing something like... |
There's no standard location for this. The standard way to do things is that you have to be privileged to install a program in a place where other users would run it.
It's your choice between a subtree of /usr/local like /usr/local/users/bin, a subdirectory of /home like /home/shared/bin, a subdirectory of /opt like /... | Linux path for users' shared binaries [duplicate] |
1,346,614,573,000 |
I have a directory structure produced during archiving. The archiving system can't be changed. Whenever a duplicate directory occurs the archiver appends an integer suffix to the directory name. My goal is to collapse these so that there is only one directory per name (no suffixes) and sub-directories are merged.
# Cu... |
I'm pretty sure a simple
cp -R Folder_Name_*/* Folder_Name
will do all the merge for you. After you checked the result, you can remove the source directories.
If you have multiple folders to merge, build a for loop around it:
for folder in *_1; do
folder="${folder%_*}"
cp -R "$folder"_* "$folder"
# rm -rf "$fol... | Merging Directories Based on their Suffix |
1,352,400,120,000 |
I'd like to do some general disk io monitoring on a debian linux server. What are the tools I should know about that monitor disk io so I can see if a disk's performance is maxed out or spikes at certain time throughout the day?
|
For disk I/O trending there are a few options. My personal favorite is the sar command from sysstat. By default, it gives output like this:
09:25:01 AM CPU %user %nice %system %iowait %steal %idle
09:35:01 AM all 0.11 0.00 0.01 0.00 0.00 99.88
09:45:01 AM all... | How can I monitor disk io? |
1,352,400,120,000 |
Is there a command that will list all partitions along with their labels? sudo fdisk -l and sudo parted -l don't show labels by default.
EDIT: (as per comment below) I'm talking about ext2 labels - those that you can set in gparted upon partitioning.
EDIT2: The intent is to list unmounted partitions (so I know which o... |
With udev, You can use
ls -l /dev/disk/by-label
to show the symlinks by label to at least some partition device nodes.
Not sure what the logic of inclusion is, possibly the existence of a label.
| List partition labels from the command line |
1,352,400,120,000 |
I sometimes need to plug a disk into a disk bay. At other times, I have the very weird setup of connecting a SSD using a SATA-eSATA cable on my laptop while pulling power from a desktop.
How can I safely remove the SATA disk from the system? This Phoronix forum thread has some suggestions:
justsumdood wrote:
An(noym... |
Unmount any filesystems on the disk. (umount ...)
Deactivate any LVM groups. (vgchange -an)
Make sure nothing is using the disk for anything.
You Could unplug the HDD here, but it is recommended to also do the last two steps
Spin the HDD down. (irrelevant for SSD's) (sudo hdparm -Y /dev/(whatever))
Tell the system... | How can I safely remove a SATA disk from a running system? |
1,352,400,120,000 |
I used to think that file changes are saved directly into the disk, that is, as soon as I close the file and decide to click/select save. However, in a recent conversation, a friend of mine told me that is not usually true; the OS (specifically we were talking about Linux systems) keeps the changes in memory and it ha... |
if I turn off the computer immediately after I edit and save a file, my changes will be most likely lost?
They might be. I wouldn't say "most likely", but the likelihood depends on a lot of things.
An easy way to increase performance of file writes, is for the OS to just cache the data, tell (lie to) the applicatio... | Are file edits in Linux directly saved into disk? |
1,352,400,120,000 |
I'm using Ubuntu 12.04, and when I rigth click on a my flash drive icon (in the Unity left bar) I get two options that have me confused: eject and safely remove.
The closer I came to an answer was this forum thread, which concludes that (for a flash drive) they are both equal and also equivalent to use the umount com... |
If you are using systemd then use udisksctl utility with power-off option:
power-off
Arranges for the drive to be safely removed and powered off. On the OS side this includes ensuring that no process is using the drive, then requesting that in-flight buffers and caches are committed to stable storage.
I would recomm... | Eject / safely remove vs umount |
1,352,400,120,000 |
Can someone please explain to me, what the difference is between creating mdadm array using partitions or the whole disks directly? Supposing I intend to use the whole drives.
Imagine a RAID6 created in two ways, either:
mdadm --create /dev/md0 --level=6 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
or:
md... |
The most important difference is that it allows you to increase the flexibility for disk replacement. It is better detailed below along with a number of other recommendations.
One should consider to use a partition instead of the entire disk. This should be under the general recommendations for setting up an array a... | What's the difference between creating mdadm array using partitions or the whole disks directly |
1,352,400,120,000 |
When monitoring disk IO, most of the IO is attributed to jbd2, while the original process that caused the high IO is attributed a much lower IO percentage. Why?
Here's iotop's example output (other processes with IO<1% omitted):
|
jbd2 is a kernel thread that updates the filesystem journal.
Tracing filesystem or disk activity with the process that caused it is difficult because the activities of many processes are combined together. For example, if two processes are reading from the same file at the same time, which process would the read be ac... | Why is most the of disk IO attributed to jbd2 and not to the process that is actually using the IO? |
1,352,400,120,000 |
I need to securely erase harddisks from time to time and have used a variety of tools to do this:
cat /dev/zero > /dev/disk
cat /dev/urandom > /dev/disk
shred
badblocks -w
DBAN
All of these have in common that they take ages to run.
In one case cat /dev/urandom > /dev/disk killed the disk, apparently overheating it... |
Overwriting the superblock or partition table just makes it inconvenient to reconstruct the data, which is obviously still there if you just do a hex dump.
Hard disks have a built-in erasing feature: ATA Secure Erase, which you can activate using hdparm:
Pick a password (any password):
hdparm --user-master u --securi... | How can I speed up secure erasing of a disk? |
1,352,400,120,000 |
How do I get read and write IOPS separately in Linux, using command line or in a programmatic way? I have installed sysstat package.
Please tell me how do I calculate these separately using sysstat package commands.
Or, is it possible to calculate them using file system?
ex: /proc or /sys or /dev
|
iostat is part of the sysstat package, which is able to show overall iops if desired, or show them separated by reads/writes.
Run iostat with the -d flag to only show the device information page, and -x for detailed information (separate read/write stats). You can specify the device you want information for by simply... | How to get total read and total write IOPS in Linux? |
1,352,400,120,000 |
I have a single disk that I want to create a mirror of; let's call this disk sda. I have just bought another identically-sized disk, which we can call sdb. sda and sdb have one partition called sda1 and sdb1 respectively.
When creating a raid, I don't want to wipe my sda clean and start again, I just want it to start ... |
The simple answer to the question in the title is "Yes". But what you really want to do is the next step, which is getting the existing data mirrored.
It's possible to convert the existing disk, but it's risky, as mentioned, due the the metadata location. Much better to create an empty (broken) mirror with the new dis... | Can I create a software RAID 1 with one device |
1,352,400,120,000 |
Edited: do not run this to test it unless you want to destroy data.
Could someone help me understand what I got?
dd if=/dev/zero of=/dev/sda bs=4096 count=4096
Q: Why specifically 4096 for count?
dd if=/dev/zero of=/dev/sda bs=512 count=4096 seek=$(expr blockdev --getsz /dev/sda - 4096)
Q: What exactly does this do?... |
dd if=/dev/zero of=/dev/sda bs=4096 count=4096
Q: why 4096 is particularly used for counter?
This will zero out the first 16 MiB of the drive. 16 MiB is probably more than enough to nuke any "start of disk" structures while being small enough that it won't take very long.
dd if=/dev/zero of=/dev/sda bs=512 count=... | What does `dd if=/dev/zero of=/dev/sda` do |
1,352,400,120,000 |
I'm having a little issue. I've a live system which run on RHEL 6.7 (VM) and have VMware 6.5 (which is not managed by our group) . The issue is, the other group tried to extend the capacity of an existing disk on a VM. After that, I ran a scan command to detect new disk as usual with echo "- - -" > /sys/class/scsi_hos... |
Below is the command that you need to run to scan the host devices so it will show the new hard disk connected.
echo "- - -" >> /sys/class/scsi_host/host_$i/scan
$i is the host number
| How to detect new hard disk attached without rebooting? |
1,352,400,120,000 |
Possible Duplicate:
How to know if /dev/sdX is a connected USB or HDD?
The output of ls /dev/sd* on my system is -
sda sda1 sda2 sda3 sda4 sda5 sda6 sda7 sdb sdc sdc1 sdc2
How should I determine which drive is which?
|
Assuming you're on Linux.
Try:
sudo /lib/udev/scsi_id --page=0x80 --whitelisted --device=/dev/sdc
or:
cat /sys/block/sdc/device/{vendor,model}
You can also get information (including labels) from the filesystems on the different partitions with
sudo blkid /dev/sdc1
The pathid will help to determine the type of devi... | How to determine which sd* is usb? [duplicate] |
1,352,400,120,000 |
I have a minimalist busybox system that I was recently trying to use, and I found a small problem: it has no lsblk command. Is there another command to list disks, partitions, and sizes like lsblk?
Some that also don't work:
lsblk
lsusb
fdisk -l
cfdisk
|
Seeing through the wiki page of busybox, I see it supports df command to find disk usage.
You can try the below command.
df -h - Show free space on mounted file systems.
From the man page of busybox, they have provided examples of how to use the df command.
However, as @nwildner pointed out, the df will show stora... | Stat disk drives wihout lsblk? |
1,352,400,120,000 |
I have no free space left in the /tmp folder in Fedora 26. That causes several problems.
Folder /tmp takes up all the free RAM:
$ df -h /tmp
Filesystem Size Used Avail Use% Mounted on
tmpfs 3.9G 3.9G 12k 100% /tmp
How can I increase the size of this folder manually to get more free space without ad... |
mount -o remount,size=5G /tmp/
| How to increase /tmp folder size manually |
1,352,400,120,000 |
I woke up this morning to a notification email with some rather disturbing system log entries.
Dec 2 04:27:01 yeono kernel: [459438.816058] ata2.00: exception Emask 0x0 SAct 0xf SErr 0x0 action 0x6 frozen
Dec 2 04:27:01 yeono kernel: [459438.816071] ata2.00: failed command: WRITE FPDMA QUEUED
Dec 2 04:27:01 yeono ... |
I wrote one-liner based on Tobi Hahn answer.
For example, you want to know what device stands for ata3:
ata=3; ls -l /sys/block/sd* | grep $(grep $ata /sys/class/scsi_host/host*/unique_id | awk -F'/' '{print $5}')
It will produce something like this
lrwxrwxrwx 1 root root 0 Jan 15 15:30 /sys/block/sde -> ../devices/p... | Given a kernel ATA exception, how to determine which physical disk is affected? [duplicate] |
1,352,400,120,000 |
I am running some heavy I/O processes on my workstation and recently installed iotop to monitor them. Here's a recent screenshot:
I'm a bit confused about the readings in the IO> column. It indicates my disk is running at around ~1500% I/O activity. Is that even possible?
How to figure out the maximum possible I/O of... |
iotop shows statistics from several different origins; take care when adding up stuff.
This previous discussion covers the difference between per-process read/write amounts and the system total read/write amounts: they cover different stuff since the per-process amounts include all I/O (whether to disk, to cache, to n... | How does iotop calculate the relative I/O activity? |
1,352,400,120,000 |
UPDATE: No, it is not safe to delete these snaps. I deleted them and can no longer open three of my applications. Attempt at opening Visual Studio Code:
~$ code
internal error, please report: running "code" failed: cannot find installed snap "code" at revision 33: missing file /snap/code/33/meta/snap.yaml
The snaps ... |
So, there's a couple questions here and I'll try to address them in an order that makes sense:
What are snaps?
Snaps are a way to package software, like deb packages or flatpaks. They work across linux distros and have become popular because of how easy they are to maintain and use. You can find more here: https://s... | Is it safe to delete these snaps? [closed] |
1,352,400,120,000 |
If I know that a partition is for example /dev/sda1 how can I get the disk name (/dev/sda in this case) that contains the partition ?
The output should be only a path to disk (like /dev/sda).
It shouldn't require string manipulation, because I need it to work for different disk types.
|
You can observe in /sys the block device for a given partition name. For example, /dev/sda1:
$ ls -l /sys/class/block/sda1
lrwxrwxrwx 1 root root /sys/class/block/sda1 -> \
../../devices/pci0000:00/.../ata1/host0/target0:0:0/0:0:0:0/block/sda/sda1
A script to take arg /dev/sda1 and print /dev/sda is:
part=$1
part=${... | How to get disk name that contains a specific partition |
1,352,400,120,000 |
I mount /tmp on tmpfs using:
sudo systemctl enable tmp.mount
sudo systemctl start tmp.mount
But this way /tmp takes up all the free RAM:
$ df -h /tmp
Filesystem Size Used Avail Use% Mounted on
tmpfs 3.9G 12K 3.9G 1% /tmp
$
How do I tell systemd tmp.mount to use only 1G? I know I can alternativel... |
The systemd way of overriding tmp.mount, or extending it, is to add a local override in /etc/systemd/system. You can either copy the existing tmp.mount (from /lib/systemd/system or /usr/share/systemd probably) and edit the copy, or better yet, add configuration snippets to only change the mount options, by running
sud... | Systemd backed tmpfs | How to specify /tmp size manually |
1,352,400,120,000 |
I am in a frustrating situation - no matter how I try, gparted won't let me assign the empty space to the first partition:
The middle partition is blocking me from expanding /dev/sda1. I need to move partition /dev/sda2 to the end of the drive, like so (fabricated image):
Then I will be able to expand first partitio... |
It is recommended that, before making any changes, you make backups of any data you do not want to lose in case anything goes wrong.
Before you start, both partitions will need to be unmounted– if you cannot unmount one of them (e.g. because it is your root partition), use a live CD with GParted (e.g. the GParted live... | Move free space from end of the drive to first partition with gparted |
1,352,400,120,000 |
I can use a variety of tools to measure the volume of disk I/O currently flowing through the system (such as iotop and iostat) but I'm curious if it's possible to easily detect if a disk is seeking a lot with only a small amount of I/O.
I know it;s possible to extract this information using blktrace and then decode it... |
The ratio (rkB/s + wkB/s)/%util of the iostat -x output should give you
some insight:
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await r_await w_await svctm %util
sda 0.04 3.65 7.16 6.37 150.82 212.38 53.71 0.03 1.99 0.82 3.31 0.76 1.03
I'm not sure how exactly t... | How to detect if a disk is seeking? |
1,352,400,120,000 |
Many times, especially when messing around with boot-loaders, I'll see numerical drive and partition numbers used. For instance, in my /boot/grub/grub.cfg I see set root='hd0,gpt2', my UEFI boot entries often reference drive/partition numbers, and it seems to crop up in almost any context where bootloaders are concern... |
The plain numbering scheme is not actually used in recent systems (with "recent" being Ubuntu 9 and later, other distributions may have adapted in that era, too).
You are correct in observing the root partition is set with the plain numbering scheme. But this only is a default or fall-back setting which is usually ove... | Why is drive/partition number still used? |
1,352,400,120,000 |
How to get a list of all disks, like this?
/dev/sda
/dev/sdb
|
ls (shows individual partitions though)
# ls /dev/sd*
/dev/sda /dev/sda1
ls (just disks, ignore partitions)
# ls /dev/sd*[a-z]
/dev/sda
fdisk
# fdisk -l 2>/dev/null |awk '/^Disk \//{print substr($2,0,length($2)-1)}'
/dev/xvda
| Get simple list of all disks [duplicate] |
1,352,400,120,000 |
Specifically, in smartctl output, how is LifeTime(hours) calculated? I'm assuming it's one of the following:
The difference (in hours) between the time of the test and the manufacture date of the drive.
The difference (in hours) between the time of the test and the first powered-on date of the drive.
The difference ... |
If I remember correctly this can vary from drive to drive.
Most brands:
Once testing is done at the manufacturer the firmware is loaded which will begin monitoring the first time the drive is started by the user.
The firmware does not monitor actual times. It works exactly like the hour meter on a plane. The only dif... | In smartctl output, what does LifeTime(hours) mean? |
1,352,400,120,000 |
I have two VMs in VirtualBox. For exmaple, VM 1 runs Red Hat, and VM 2 runs Ubuntu. For the Red Hat VM I have redhat.vdi and redhat2.vdi, and for the Ubuntu VM I have ubuntu.vdi and unbuntu2.vdi.
Each VM can access its own virtual disks without problem.
How can I access ubuntu.vdi from the Red Hat virtual machine, usi... |
This is how you add another virtual hard disk to a VM in VirtualBox.
Go into the VirtualBox Manager and make sure both VMs are shut down
Right-click on the VM in question and pick Settings
Go into the Storage category
Select the controller on which you want to connect the virtual hard disk
Click the "Add attachment" ... | Mounting another VM's .vdi in VirtualBox |
1,352,400,120,000 |
We have RedHat 7.2 OS.
/dev/sdc is mounted to /bla/appLO
Is it possible to run fsck on mounted disks (without umount /bla/appLO)
and to see only the errors if they exist?
Example:
e2fsck -n /dev/sdc
e2fsck 1.42.9 (28-Dec-2013)
Warning! /dev/sdc is mounted.
Warning: skipping journal recovery because doing a read-only... |
No.
You should never run fsck on a mounted filesystem. Correcting errors on a live filesystem will mess up your disk. Even if you run the tool in read-only mode (without error correction) the results can't be trusted. This is true even if the filesystem is mounted read-only.
From man e2fsck:
Note that in general i... | Is it possible to run fsck to only see errors on mounted disk |
1,352,400,120,000 |
My goal is to get the disks greater than 100G from lsblk.
I have it working, but it's awkward. I'm pretty sure it can be shortened. Either by using something totally different than lsblk, or maybe I can filter human readable numbers directly with awk.
Here's what I put together:
lsblk | grep disk | awk '{print$1,$4}' ... |
You can specify the form of output you want from lsblk:
% lsblk -nblo NAME,SIZE
mmcblk0 15931539456
mmcblk0p1 268435456
mmcblk0p2 15662038528
Options used:
-b, --bytes
Print the SIZE column in bytes rather than in human-readable format.
-l, --list
Use the list output format.
-n, --noheadings
D... | Can I shorten this filter, that finds disk sizes over 100G? |
1,352,400,120,000 |
I want to create a new encrypted LUKS-partition in GParted.
I've searched the UI and the help, but the only thing I can find is how to open and close an existing LUKS partition and how to to copy and paste an existing one.
However, I can find no way to create a new one. I can create a new partition e.g. for btrfs, but... |
GParted doesn't support creating of encrypted partitions, you'll need to use either GNOME Disks or blivet-gui (shameless plug for my project) or you can just use cryptsetup directly if you are ok with using command line tools.
See GParted Features page for details about supported features, LUKS is listed as not suppor... | How to create a new encrypted LUKS-partition in GParted? |
1,352,400,120,000 |
I'm not sure what is wrong here but when running fdisk -l I don't get an output, and when running
fdisk /dev/sdb # I get this
fdisk: unable to open /dev/sdb: No such file or directory
I'm running Ubuntu 12.10 Server
Can someone please tell me what I'm doing wrong? I want to delete /dev/sdb2-3 and just have one p... |
On most non-embedded Linux installations, and many embedded installations, /dev is on a RAM-backed filesystem, not on the root partition. Most current installations have /dev as a tmpfs filesystem, with the udev daemon creating entries when notified by the kernel that some hardware is available. Recent kernel offer th... | /dev/sdb: No such file or directory (but /dev/sdb1 etc. exists) |
1,352,400,120,000 |
fdisk -l output:
.
.
Disk label type: dos
Disk identifier: 0x0006a8bd
.
.
What are Disk label type and Disk identifier?
Also, apart from the manuals, where else can I find more information about disk management / partitioning etc..?
|
The disk label type is the type of Master Boot Record. See http://en.wikipedia.org/wiki/Master_boot_record. The disk identifier is a randomly generated number stuck onto the MBR.
In terms of tools for looking at disks, fdisk is on its way to being deprecated if it isn't already so. parted is the replacement for fdisk ... | "fdisk -l" output: what are Disk label type" and "Disk identifier" |
1,352,400,120,000 |
OS: Debian Bullseye, uname -a:
Linux backup-server 5.10.0-5-amd64 #1 SMP Debian 5.10.24-1 (2021-03-19) x86_64 GNU/Linux
I am looking for a way of undoing this wipefs command:
wipefs --all --force /dev/sda? /dev/sda
while the former structure was:
fdisk -l /dev/sda
Disk /dev/sda: 223.57 GiB, 240057409536 bytes, 468... |
You're lucky that wipefs actually prints out the parts it wipes.
These,
wipefs -a /dev/sda
/dev/sda: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54
/dev/sda: 8 bytes were erased at offset 0x3b9e655e00 (gpt): 45 46 49 20 50 41 52 54
/dev/sda: 2 bytes were erased at offset 0x000001fe (PMBR): 55 ... | Undoing wipefs --all --force /dev/sda? /dev/sda |
1,352,400,120,000 |
I've got an USB pen drive and I'd like to turn it into a bootable MBR device. However, at some point in its history, that device had a GPT on it, and I can't seem to get rid of that. Even after I ran mklabel dos in parted, grub-install still complains about
Attempting to install GRUB to a disk with multiple partition ... |
If you want a single command, instead of navigating interactive menus in gdisk, try:
$ sudo sgdisk -Z /dev/sdx
substituting sdx with the name of your disk in question.
(obviously - don't wipe out the partition information on your system disk ;)
| Remove all traces of GPT disk label |
1,352,400,120,000 |
I have a disk image, it's a "whole" disk image, e.g., contains multiple partitions, and I want to clone just one of them (not the first one..) onto a partition on an external drive with multiple partitions on it (I'm also not cloning it onto the first partition of the disk...)
FDisk'ing the image gives this:
# fdisk -... |
# losetup --find --show --partscan --read-only 2013-02-09-wheezy-raspbian.img
/dev/loop7
# dd if=/dev/loop7p2 of=/dev/narnia bs=1M
If --partscan doesn't work, you can also use one of:
# partx -a /dev/loop7
# kpartx /dev/loop7
or similar partition mapping solutions.
You should probably mount it first just to see if i... | How to use DD to clone a partition off a disk image? |
1,352,400,120,000 |
Currently working on a project where I'm dealing with an arbitrary group of disks in multiple systems. I've written a suite of software to burn-in these disks. Part of that process was to format the disks. While testing my software, I realized that if at some point during formatting the disks, the process stops/dies, ... |
Depending on how you access the drives, you could use blkid -o list (deprecated) on them and then parse the output.
The command outputs, among other things, a fs_type label column, that shows the filesystem.
blkid -o list has been superseded be lsblk -f.
| Method to test if disks in system are formatted |
1,352,400,120,000 |
I have a btrfs RAID1 system with the following state:
# btrfs filesystem show
Label: none uuid: 975bdbb3-9a9c-4a72-ad67-6cda545fda5e
Total devices 2 FS bytes used 1.65TiB
devid 1 size 1.82TiB used 1.77TiB path /dev/sde1
*** Some devices missing
The missing device is a disk drive that faile... |
Update: According to @mkudlacek, this problem has been fixed.
For prosperity, here is my answer to why in 2017, I could not rebuild a RAID with a missing drive.
Turns out that this is a limitation of btrfs as of beginning of 2017. To get the filesystem mounted rw again, one needs to patch the kernel. I have not tri... | Btrfs RAID1: How to replace a disk drive that is physically no more there? |
1,352,400,120,000 |
Is there any way to find some process which is periodically writing to disk (according to hdd led) on FreeBSD 10 with ZFS (maybe turn ZFS into verbose logging mode)?
lsof and other instantly aggregating statistics utilities seems not able to catch anything due to a short time of a moment of a disk access.
|
DTrace is able to report on vfs information in FreeBSD (as well as a raft of other probes). DTrace is enabled by default in the 10 kernel so all you need to do is load the module then run the dtrace script.
Load the DTrace module
kldload dtraceall
Get the vfssnoop.d script from the FreeBSD forums. The whole thread ... | FreeBSD 10 trace disk activity |
1,352,400,120,000 |
My program creates many small short-lived files. They are typically deleted within a second after creation. The files are in an ext4 file system backed by a real hard disk. I know that Linux periodically flushes (pdflush) dirty pages to disk. Since my files are short-lived, most likely they are not cached by pdflush. ... |
A simple experiment using ext4:
Create a 100MB image...
# dd if=/dev/zero of=image bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 0.0533049 s, 2.0 GB/s
Make it a loop device...
# losetup -f --show image
/dev/loop0
Make filesystem and mount...
# mkfs.ext4 /dev/loop0
# mount /dev/l... | Are short-lived files flushed to disk? |
1,352,400,120,000 |
On my system (Debian), I can see the UUID identifier for all of my disks partitions (i.e. /dev/sda1, dev/sda2, ..)
ls /dev/disk/by-uuid/
However, I don't see the UUID identifier for /dev/sda itself. Is it possible to reference whole disk with UUID?
I need this because I want to reference a particular disk, and I cann... |
The symlinks under /dev/disk/by-uuid/ are created by udev rules based on filesystems UUIDs. If you look at /usr/lib/udev/rules.d/60-persistent-storage.rules you will find entries like:
...... ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
To reference a disk you could use the disk serial numb... | reference whole disk (/dev/sda) using UUID |
1,352,400,120,000 |
I have an 8G usb stick (I'm on linux Mint), and I'm trying to copy a 5.4G file into it, but getting
No space left on device
The filesize of the copied file before failing is always 3.6G
An output of the mounted stick shows..
df -T
/dev/sdc1 ext2 7708584 622604 6694404 9% /media/moo/ba20d7ab-2c46-4... |
Your 8GB stick has approximately 7.5 GiB and even with some file system overhead should be able to store the 5.4GiB file.
You use tune2fs to check the file sytem status and properties:
tune2fs -l /dev/<device>
By default 5% of the space is reserved for the root user. Your output lists 97894 blocks, which corresponds ... | Unable to copy large file onto ext2 usb stick [closed] |
1,352,400,120,000 |
I want to create a fixed size Linux ramdisk which never swaps to disk. Note that my question is not "why" I want to do this (let say, for example, that it's for an educative purpose or for research): the question is how to do it.
As I understand ramfs cannot be limited in size, so it doesn't fit my requirement of havi... |
This is just a thought and has more than one downside, but it might be usable enough anyway.
How about creating an image file and a filesystem inside it on top of ramfs, then mount the image as a loop device? That way you could limit the size of ramdisk by simply limiting the image file size. For example:
$ mkdir -p /... | How to create a fixed size Linux ramdisk which does never swap to disk? |
1,507,025,938,000 |
I have a VPS. I might be able to encrypt my partition but I havent tried. My VPS company I believe can reset my root password although the only SSH key I see is my own. With all my data I have it encrypted with encfs. Just in case a hacker gets some kind of access, encfs can only mount the drive if my password is corr... |
As a general rule, physical access to the machine is all that's ever needed to compromise it. You are, after all, trusting that what the machine tells you is true; a person with physical access can void that trust. Consider that an attacker with physical access can theoretically do anything (including installation of ... | Physically break into box? (Memory & disk) |
1,507,025,938,000 |
I have a 128GB Somnambulist SSD. I know this brand is one of the worst. I measured the speed using GNOME Disk Utility, and it showed a read/write speed of 420/340.
After encrypting the SSD with Debian 12, the read speed, as measured by the GNOME Disk Utility, dropped to 13.5 MB/s!
Is this drop in speed normal, or is t... |
If your CPU is old enough it may not support AES-NI instructions, so encryption/decryption will be slow.
grep -qw aes /proc/cpuinfo && echo Supported || echo Unsupported
Will tell you everything.
| Low performance of encrypted SSD |
1,507,025,938,000 |
I have a 3TB drive which I have partitioned using GPT:
$ sudo sgdisk -p /dev/sdg
Disk /dev/sdg: 5860533168 sectors, 2.7 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 2BC92531-AFE3-407F-AC81-ACB0CDF41295
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 5860533134
Par... |
I found a solution: A program called kpartx, which is a userspace program that uses devmapper to create partitions from loopback devices, which works great:
$ loop_device=`losetup --show -f /dev/sdg`
$ kpartx -a $loop_device
$ ls /dev/mapper
total 0
crw------- 1 root root 10, 236 Mar 2 17:59 control
brw-rw---- 1 roo... | Recognizing GPT partition table created with different logical sector size |
1,507,025,938,000 |
I've seen some disk formatting/partitioning discussions that mention destroying existing GPT/MBR data structures as a first step:
sgdisk --zap-all /dev/nvme0n1
I wasn't previously aware of this, and when I've set up a disk, I've generally used:
parted --script --align optimal \
/dev/nvme0n1 -- \
... |
This advice is from the time when other tools didn't properly support GPT and were not removing all the pieces of the GPT metadata. From sgdisk man page for the --zap/--zap-all option:
Use this option if you want to repartition a GPT disk using fdisk or some other GPT-unaware program.
That's no longer true. Both fdi... | Is it important to delete GPT/MBR labels before reformatting/repartitioning? |
1,507,025,938,000 |
All of the tools I've tried until now were only capable to create a dual (GPT & MBR) partition table, where the first 4 of the GPT partitions were mirrored to a compatible MBR partition.
This is not what I want. I want a pure GPT partition table, i.e. where there isn't MBR table on the disk, and thus there isn't also ... |
TO ADDRESS YOUR EDIT:
I didn't notice the edit to your question until just now. As written now, the question is altogether different than when I first answered it. The mirror you describe is not in the spec, actually, as it is instead a rather dangerous and ugly hack known as a hybrid-MBR partition format. This questi... | How to construct a GPT-only partition table on Linux? |
1,507,025,938,000 |
I noticed today while setting up a new system that the disk as represented by /dev/disk/by-id also had a WWN link that I was not familiar with:
My research suggests that this is a "World Wide Number" or some kind of unique ID to the drive. What is the use case for this and when would it be appropriate to use it versu... |
The WWN identifies the actual physical hardware disk; in simple cases it is derived from the hardware serial number. (Except when it doesn't; a WWN can also identify storage which is not an actual hardware disk, it just pretends that it is for the sake of the operating system, for example, a volume presented by a sto... | What are the use cases for a hard disk's WWN? |
1,507,025,938,000 |
I have a couple of large disks with backup/archive material on them. They're ext4. Regarding the ones of those that will be stored for a couple of years without reading the whole disc again I've been thinking of a way to refresh the disks magnetic state. Shelf life of drives seems to be a matter of debate everywhere I... |
Generally you can't really refresh the whole disk without reading/writing all of it. fsck is unlikely to provide what you need - it works with the file system not the underlying device hence it mostly just scans file system meta data (inodes and other file system structures).
badblocks -n might be an option to dd if=X... | How do I refresh the magnetic state on a disks with backups? |
1,507,025,938,000 |
Consider you've been informed about a bad sector like this:
[48792.329933] Add. Sense: Unrecovered read error - auto reallocate failed
[48792.329936] sd 0:0:0:0: [sda] CDB:
[48792.329938] Read(10): ...
[48792.329949] end_request: I/O error, dev sda, sector 1545882485
[48792.329968] md/raid1:md126: sda: unrecoverable I... |
The traditional way is to copy all files elsewhere and see which one triggers a read error. Of course, this does not answer the question at all if the error is hidden by the redundancy of the RAID layer.
Apart from that I only know the manual approach. Which is way too bothersome to actually go through with, and if th... | How to find out which file is affected by a bad sector? |
1,507,025,938,000 |
Is there a way to make sar (from sysstat) collect free disk space data?
|
Maybe this post is old, however, you can get the disk space with the current version (sysstat-11.1.1)
Example:
[root@ipboss-linux ~]# sar -F 1 1
Linux 2.6.32-358.el6.x86_64 (ipboss-linux.qualif.fr) 09/23/2014 _x86_64_ (8 CPU)
11:21:16 AM MBfsfree MBfsused %fsused %ufsused Ifree Iused %I... | Using SAR to monitor free disk space data |
1,507,025,938,000 |
How to find the MAX I/O a physical disk can support?
My application is doing I/O, and I can find the actual throughput (Blk_wrtn/s) by using linux commands. But how can I find what is max limit I can reach? I want to know if it can be further loaded.
|
Obiously using Unix tools is the easiest way to do it. You can measure the max operation by creating a test case and use appropriate tools to measure its perfomance. A good resource can be found here: LINUX - Test READ and WRITE speed of Storage
sudo hdparm -tT /dev/sdX
for example as read test.
And to measure write:... | How to find the MAX IO a physical disk can support |
1,507,025,938,000 |
I need to list the partition type GUID's from the command line.
Note: This is not the same as the partition UUID.
Basically I'm needing to search for all disks that have the Ceph OSD type GUID:
4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D
The intention is to emulate some things done with ceph-disk (python) in bash script o... |
This was my ultimate solution using blkid -p
function find_osds()
{
local osds
declare -a dev_list
mapfile dev_list < <(lsblk -l -n -o NAME --exclude 1,7,11) # note -I not available in all versions of lsblk, use exclude instead
for dev in "${dev_list[@]}"; do
dev=/dev/$(trim "$dev")
if ... | List partition type GUID's for all disks from command line? |
1,507,025,938,000 |
I have two hard drives of different physical sector size. I would like to create an LVM volume group with them, however, when I do so with vgcreate, I get a warning telling me that the two disks have different physical sector size. Is there something to be concerned about?
|
You don't want to mix different sector sizes in a single VG. Newer versions of LVM don't even allow creating VG on PVs with mixed sector sizes by default (older versions show only the warning message you saw). The problem is not with the VG, but with the LVs and filesystems -- if you resize or move LV to the larger se... | Is there any risk to create an LVM group with two disks of different physical sector size? |
1,507,025,938,000 |
When we perform this (on linux redhat 7.x)
umount /grop/sdc
umount: /grop/sdc: target is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
We can see that mount failed on busy.
But when we do remount then ...
remount is success as the following:
mount -o rw... |
man mount :
remount
Attempt to remount an already-mounted filesystem. This is commonly used to change the mount flags for a filesystem, especially to make a readonly filesystem writeable. It does not change device or mount point.
The remount functionality follows the standard way how the mount command works with op... | what the difference between remount to umount/mount? |
1,507,025,938,000 |
os: centos7
test file: a.txt 1.2G
monitor command: iostat -xdm 1
The first scene:
cp a.txt b.txt #b.txt is not exist
The second scene:
cp a.txt b.txt #b.txt is exist
Why the first scene don't consume IO, but the second scene consume IO?
|
It could well be that the data had not been flushed to disk during the first cp operation, but was during the second.
Try setting vm.dirty_background_bytes to something small, like 1048576 (1 MiB) to see if this is the case; run sysctl -w vm.dirty_background_bytes=1048576, and then your first cp scenario should show I... | why linux cp command don't consume disk IO? |
1,507,025,938,000 |
I'm looking for an easy solution to protect against random bit flips (so-called bit rot) of data stored on various drives. They are not disk arrays, just single disks, that I backup once a week. So I'm not looking for redundancy, but for file integrity -- i.e. I want to know if my files that I haven't accessed in a lo... |
You should have a look at bup
Very efficient backup system based on the git packfile format, providing fast incremental saves and global deduplication (among and within files, including virtual machine images).
bup supports bup-fsck (with par2)
verify or repair a bup repository
| Easy backup solution to protect against bit rot (or verify) |
1,507,025,938,000 |
We have a Redhat 7 machine. And the filesystem for device /dev/sdc is ext4.
When we perform:
mount -o rw,remount /grop/sdc
We get write protected error like:
/dev/sdc read-write, is write-protected
in spite the /etc/fstab allow read and write and all sub folder under /grop/sdc have full write/read permissions:
/dev... |
It appears your filesystem has become corrupt somehow. Most filesystems switch to read-only mode once they encounter an error. Please perform the following commands in a terminal:
umount /dev/sdc
e2fsck /dev/sdc
mount /dev/sdc
If /dev/sdc is the harddisk which has your operating system on it, use a startup DVD or usb... | How an ext4 disk became suddenly write protected in spite configuration is read/write? |
1,507,025,938,000 |
I use dd a lot. I live in a contant fear of making a mistake one day, for example writing on sda (computer disk) instead of sdb (USB disk) and then erasing everything I have on my computer.
I know dd is supposed to be a power user tool but still, it doesn't make sense to me that you can basically screw your whole comp... |
It's reasonable to ask why the dd command doesn't first check whether its target contains a mounted filesystem, and then prompt for confirmation or require a special flag. One simple answer is that it would break any scripts that expect to be able to use dd in this way, and that aren't designed to handle interactive ... | Why is dd not protected against writing on the active disk ? |
1,507,025,938,000 |
I wish to clone a large disk (a 500GB SSD, for what it's worth), and I am leaning toward using cat, as suggested by Gilles here. But what gave me pause is that I do not really know what cat does upon read errors. I know how dd behaves in these cases, i.e. the command
dd if=/dev/sda of=/dev/sdb bs=64K conv=noerror,sync... |
cat stops if it encounters a read or write error.
If you’re concerned there might be unreadable sectors on your source drive, you should look at tools such as ddrescue.
| Errors on cloning disk with cat |
1,507,025,938,000 |
If I put /var as first partition, then /home and /, will the partition for /var have better performance than if I put other partitions close to head of the disk? Will the disk sector position matter?
I heard some people saying that I should put swap closer to the head of a partition to get higher performance.
|
Yes, it is true.
The platters in a disk rotate at a fixed speed (7200 RPM in the common case). As such when the head is over the outer portion of the platter more surface area passes under the head per rotation than on the inside track. Thus more IO per rotation is possible.
(The 'beginning' of the drive is the outsid... | Does the position of partition on disk affect speed? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.