date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,432,265,534,000 |
If for benchmarking purposes one has to use hdparm or dd directly on the device, I wonder what the correct way would be to do this safely.
Let's say the disk in question is /dev/sda:
root@igloo:~# ls -l /dev/sd*
brw-rw---- 1 root disk 8, 0 May 29 08:23 /dev/sda
brw-rw---- 1 root disk 8, 1 May 29 08:23 /dev/sda1
I re... |
chmod o+r /dev/sda* is quite dangerous, as it allows any program to read your whole disk (including e.g. password hashes in /etc/shadow, if your root partition is on sda)!
There are (at least) two ways to do this more safely:
Add all users that need to read the disk to the disk group and run chmod g-w /dev/sda* to pr... | Giving read permissions to device file of disk |
1,432,265,534,000 |
From man mknod on Linux:
c, u create a character (unbuffered) special file
Why are there 2 letters for the same function? Is there any subtle difference, or they are completely alike?
|
They're identical, at least on Linux.
I came to this conclusion by first looking at the source code for mknod(1) in the GNU coreutils, where on line 217 in the current version we find that the 'c' and 'u' cases are treated identically, getting the same device type. The S_IFCHR value is defined in the Linux kernel head... | Is there a difference between u and c in mknod |
1,432,265,534,000 |
Here's the situation. I have a video device /dev/video0 on a VMware Server and I want to access this device from within a virtual machine. However for whatever reason I can't connect the device directly to the VM, it must be connected to the host.
Since under unix philosophy everything really is just a file, can I sha... |
No.
You can export a device file through NFS or some other network filesystems. But the meaning of the device file is dependent on the machine where you open it. If you export /dev/video0 over NFS from a server machine to a client machine, the client machine just sees “character device 81:0”, and interprets it as its ... | Can I share a device from under /dev across hosts? |
1,432,265,534,000 |
My flash is partitioned as /dev/mtd0 /dev/mtd1 etc....And I want to scp one of the partitions over to my pc so I can analyze it with a hex editor, but everytime I try to copy it with scp I get -not a regular file. How can I scp the contents of a flash partition? I think I did it once with WinSCP on a windows machine b... |
A combination of dd and ssh can probably help here:
# dd if=/dev/mtd0 | ssh me@myhost "dd of=mtd0.img"
| Can you scp a device file? |
1,316,460,239,000 |
I'm running tar on a complete remote filesystem using
ssh -n <hostname> 'sudo tar -cpvzf - --one-file-system /' | cat > Bak.tar.gz
This gave me a tarball. I tried importing this tarball into another service I'm using and ran into an issue because it appears it did not include the /dev directories. I'm wondering if I ... |
Just add /dev onto the list of files to archive:
ssh -n <hostname> sudo tar -cpvzf - --one-file-system / /dev > Bak.tar.gz
--one-file-system only prevents recursing into directories on different filesystems. You can still list files/directories on different filesystems directly as arguments to tar.
| how to include or add /dev with tar --one-file-system |
1,316,460,239,000 |
I wanted to see which driver was associated with some of the network interfaces listed by ip link. My first thought was to find the network interfaces in /dev and look at the device major and minor numbers to determine the associated driver. However, network interfaces don't appear under /dev.
I'm have a feeling I'm ... |
I'm never quite sure if spelunking in sysfs is the best way to do things (am I supposed to use udevadm?), but at least it's discoverable
$ DEV=p8p1
$ readlink /sys/class/net/$DEV/device/driver
../../../../bus/pci/drivers/tg3
It won't work for devices like lo which are "virtual" (/sys/devices/virtual/). They don't h... | Determine driver for network interface [duplicate] |
1,316,460,239,000 |
Can someone please explain the concept of a device controller (hard disc controller, NEC PD765 compatible controller etc.).
Here are some definition of key terms which might be needed for the explanation. Just to maintain the term sync :)
Kernel - The software which provides abstraction for accessing hardware device... |
Was the idea behind the controller to be able to control devices from a different manufacturers with the same driver?
No. The primary purpose is to provide part of the interface between devices and the processor. A controller has its own driver; this is in addition to any drivers necessary for the devices connecte... | What is a device controller, and where does it fit in between the kernel and the device? |
1,316,460,239,000 |
I am planning to set up a few chroot jails for some users to run/test Java applications (lets just assume each application is untrusted). Is there any risk involved with mounting /dev and /proc into each jail? If there is, what steps can be taken to get rid of this risk?
|
Exposing /proc and /dev exposes some more information and grants more rights to the users inside the jail.
Beware that uids and gids may be different inside and outside the jail. For instance, inside the jail, user "x" may be member of group 123, which in the jail is for "users" while on the system is for "disk". By b... | Chroot Risks w/ /dev and /proc |
1,316,460,239,000 |
In that question someone wanted a blacklist for all USB devices, and then only allow specific devices.
In this question, we want to accept all USB devices, but prevent the driver (e.g. cdc_acm) from taking one specific device type – for example, an LEGO® NXT brick in flash mode should not be taken (because fwflash nee... |
I’ve been able to do this with an udev rule, after some trickery (and using lsusb to find out the vendor and product ID of the device in flash mode):
$ cat /etc/udev/rules.d/nxt.rules
# disable NXT in flash mode
ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="6124", RUN="/bin/sh -c '/bin/echo -n $kernel:1.0 |... | How to disable USB devices based on their vendor ID on GNU/Linux? |
1,316,460,239,000 |
We have a RHEL 5.5 box with 8 interfaces. And the eth interface naming is flip flopping. Sometimes eth0 comes up on physical port 7th, and sometimes on another physical port.
We want the naming to be as per the sequence of PCI BUS. I did the research and found that
cat /sys/devices/pci0000\:00/0000\:00\:1e.0/0000\:0... |
Have you tried including the MAC addresses in the different ifcfg-ethX files for the various ethernet devices? Additionally you can control which device get's which ethX handle through udev's 60-net.rules file.
For example
# /etc/sysconfig/network-scripts/ifcfg-eth0
# Intel Corporation 82573E Gigabit Ethernet Control... | RHEL: Creating stable names for network interfaces |
1,316,460,239,000 |
This is an extension to Why rsync attempts to copy file that is already up-to-date?
I'm attempting to use the --copy-devices patch to rsync to copy an entire disk drive and store it as an image on another machine.
The copy appears to have run correctly however, when I run rsync again with the same values, it appears t... |
By default rsync compares files by size and timestamp, but a device does not have a size so it must calculate differences using the delta algorithm which is described in this tech report.
Loosely, the remote file is divided into blocks of a chosen size, and the checksums of these are sent back. The local file is sim... | How to verify that rsync copied the device correctly when copy-devices is enabled? |
1,316,460,239,000 |
Does the suid bit have any special meaning for device files in Linux ?
|
I believe it is not. This bit is only used on executable files. It's defined in Linux kernel headers as S_ISUID. If you grep kernel sources for this constant, you will find that it is only used in:
should_remove_suid function, which is used on FS operations that should remove SUID/SGID bit,
prepare_binprm function in... | Does the suid bit have any meaning for device files? |
1,316,460,239,000 |
I am using a library (librealsense) that only outputs the bus and port number as such (9.1). It uses libusb internally. The issue is from this identifier in libusb I want to know what physical device it belongs to in /dev/video0. For instance, 9.1 -> /dev/video0 and 7.2 -> /dev/video2 when two cameras are plugged in i... |
Answering so I can close this question full credit to @ridgy and @dirkt for their help. With the command:
udevadm info -n video0 -q path
Or similarly with ls -l /sys/class/video4linux/, a path of the form /devices/pci0000:00/0000:00:10.0/usb7/7-2/7-2:1.0/video4linux/video0 can be found. That in combination with the l... | How to map /sys/bus/usb/devices to /dev/video*? |
1,316,460,239,000 |
I'm interested in creating musical programs like these:
http://www.youtube.com/watch?v=GtQdIYUtAHg&feature=player_embedded
Essentially these programs just generate sequences of integers, which (apparently), when fed directly into a 8khz audio stream (like "/dev/audio"), produce interesting music.
My problem is that ... |
This worked out fine for me:
./a.out | aplay
| How can I create a direct 8khz audio pipe in Ubuntu? |
1,316,460,239,000 |
On most Linux systems udev usually creates symlinks in
/dev/disk/by-uuid/
/dev/disk/by-path/
which point to actual device nodes (/dev/sda, /dev/sdb, etc).
I don't have udev on my system, and I would like to generate these symlinks manually. I know I can use blkid to generate the by-uuid name.
But how can I generate t... |
This script would do the trick, at least for most typical scenarios. It requires on blkid, lsscsi and sed:
#!/bin/bash
mkdir -p /dev/disk/by-{path,uuid}
for dev in `blkid -o device | grep -v block`; do
ln -s "$dev" "/dev/disk/by-uuid/$(blkid -o value -s UUID "$dev")"
done
lsscsi -v | sed 'N;s/\n//' |\
sed 's/.*\... | Command to generate /dev/disk/-by-path/ name on a system without udev daemon |
1,316,460,239,000 |
Writing to a custom character device using
cat 123 > /dev/chardev
gives
cat: write error: Invalid argument
I have changed the permissions to 666 and even tried it with sudo. Still the same results.
Also tried echo in similar way
I use Arch linux 4.8.
Edit: The code for the driver
#include <linux/module.h>
#includ... |
In the kernel, each driver provides a series of methods for the various operations that can be performed on a file: open, close, read, write, seek, ioctl, etc. These methods are stored in a struct file_operations. For devices, the methods are provided by the driver that registered that particular device (i.e. that par... | cat: write error: Invalid argument |
1,316,460,239,000 |
My system disk usage is like this:
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 50G 39G 12G 77% /
devtmpfs 5.8G 0 5.8G 0% /dev
tmpfs 5.8G 240K 5.8G 1% /dev/shm
tmpfs 5.8G 50M 5.8G 1% /run
tmpfs ... |
For all the tmpfs mounts, "Avail" is an artificial limit. The default size for tmpfs mounts is half your RAM. It can be adjusted at mount time. (man mount, scroll to tmpfs).
The mounts don't share the same space, in that if you filled the /dev/shm mount, /dev would not show any more "Used", and it would not necessa... | Do tmpfs and devtmpfs share the same memory region? |
1,316,460,239,000 |
A wrongly written script deleted /dev/null on my system. I did find an answer here and tried it out. But as soon as I write something to the new /dev/null, the system crashes. I'm afraid that answer's not for BSD.
Can anyone help?
It's FreeBSD 10.3
|
On FreeBSD:
mknod /dev/null c 15 0 root:wheel
chmod 0666 /dev/null
As you found out, numbers 15 and 0 are not portable to other systems.
| How to create /dev/null on BSD? |
1,316,460,239,000 |
This image from TLDP is pretty awesome.
It shows that before giving user space actual read, write, open access to the filesystem the blocks get mapped onto the virtual filesystem.
and Wikipedia says there are 3 versions of file systems on different layers.
So, are the standard (sd nodes) referring to the physical or,... |
tl;dr: /dev/sdaX represents a partition. I think a fundamental misconception you have is the difference between filesystems and partitions. A partition is really simple - basically it's just a section of the disk which is defined in a partition table at the beginning of the disk. A filesystem, however, is a much more ... | what are /dev/sdxx nodes? |
1,316,460,239,000 |
Background
It seems I only know enough linux to get myself in trouble.
I'm working on a couple of embedded systems (two different models) both running linux. I've been troubleshooting a modem support code that I had working with the newer one of the two. I stopped the code and tried to manually load the usbserial driv... |
You can manually create the /dev entry using
mknod /dev/ttyUSBn c 188 n
Parameters:
mknod is widely known tool to create /dev entries
/dev/ttyUSBn: device name
c : char device
188 : major device number
n : minor device number,ttyUSB0, ttyUSB1, etc.
But the device should be created automatically according to t... | How do I recreate /dev/ttyUSB## devices that I deleted? |
1,316,460,239,000 |
Currently I am running into an issue where I can't seem to find a way to identify which WiFi adapter I want to use as my primary in Kali (v 2017.1)
My laptop has a normal PCI WiFi card inside however I have a RTL8812AU USB 3.0 adapter as well. The way I know I'm using my internal is because I can only see the 2.4Ghz b... |
It turns out I did need to fully remove and reinstall the WiFi driver, and now both do show up when executing ifconfig as wlan0 and wlan1 respectively. As well as both appearing in the network-manager GUI (see image).
The steps I took were:
Uninstalling the driver by running sudo apt remove realtek-rtl88xxau-dkms fo... | Kali Linux and RTL8812AU |
1,316,460,239,000 |
I am reading an article on LWN and it has an important statement:
Raw devices (/dev/raw/rawN) are a special case of O_DIRECT I/O. These
devices can be opened without specifying O_DIRECT, but still provide
direct I/O semantics. As such, all of the same rules apply to raw
devices that apply to files (or devices) ... |
No, /dev/raw is different from the conventional /dev/sda block device. According to The Linux 2.4 SCSI subsystem HOWTO: Chapter 11. Raw devices:
A raw device can be bound to an existing block device (e.g. a disk) and be used to perform "raw" IO with that existing block device. Such "raw" IO bypasses the caching that... | What happened to /dev/raw/? |
1,316,460,239,000 |
I am trying to set up a ssh-chroot jail on one of my NAS servers. The system runs on NAS4Free (which is based on nanobsd). The user should be able to run only one command, which is a bash-script that opens ssh to another server and executes one command there.
To setup the chroot I have this in my sshd config.
Match Us... |
I created dev/null using mknod dev/null c 2 2
Your knowledge is outdated. Things do not work this way any more, now that NAS4Free is based on the likes of FreeBSD 10 and 11. (Nor are those the device numbers for the null device anyway.) Read the mknod manual. You can still run mknod to create device nodes in an ... | ssh in chrooted jail doesn't work because of /dev/null operation not supported |
1,316,460,239,000 |
I'm using the Raspbian (a distribution made for Raspberry Pi, which is based on Debian).
I have some scripts that use i2c.
Normally only root has read and write permissions for i2c.
I'm using this command to add i2c r/w permissions for normal user:
# chmod a+rw /dev/i2c-*
However after reboot, these devices have thei... |
You can do this using udev. Create a file in /etc/udev/rules.d with the suffix .rules, e.g. local.rules, and add a line like this to it:
ACTION=="add", KERNEL=="i2c-[0-1]*", MODE="0666"
MODE=0666 is rw for owner, group, world. Something you can do instead of, or together with that, is to specify a GID for the node,... | How can I set device rw permissions permanently on Raspbian? |
1,316,460,239,000 |
I want to run something like
% sudo grep -i -a 'some-string' <drive device>
On Linux, <drive device> would be something like /dev/sda1. How can I find the equivalent on Darwin?
(In case it's not obvious, I'm on a last-ditch-effort hunt for accidentally deleted data.)
|
If the filesystem takes over the whole disk, OS X currently uses a name like /dev/disk5. If the disk is partitioned, it adds an s# suffix, like /dev/disk5s2 for the second partition. (s is short for "slice," a BSDism functionally equivalent to a partition.)
Disks are numbered sequentially in discovery order by the OS,... | equivalent of `grep -a /dev/sda1` on Darwin? |
1,316,460,239,000 |
When mounting a hard drive via UUID and another via device file, how can I make sure, that the first one is always /dev/sdaX and the second /dev/sdbX and not the other way round?
Some explanation of what I'm trying to do: I'm plugging together a raspberry pi zero, a USB hub, an external hard drive and a sd card (all p... |
I noticed that the devpath attribute is constant for my USB ports. You could add a new udev rule and create specific symlinks based on the ports the devices are plugged in then. Just add a new file into your /etc/udev/rules.d directory, that looks like this:
#new symlink for my front USB port:
KERNELS=="2-1.8", SUBSYS... | How to make sure that certain devices always use the same device file? |
1,316,460,239,000 |
How to programmatically detect when a device raises an interrupt? This can be when a device is connected or disconnected.
And also this case: for example: when a finger is held over a fingerprint scanner, an interrupt is raised. How to detect and possibly trap this interrupt?
I want to write an application using Gtkmm... |
I can try to trap the Interrupt at a lower level and inform the gtkmm application.
No, that is a kernel space activity. Fortunately, the kernel does report the outcome of certain events via interfaces accessible from userland.
It's a little ambiguous in your question whether you want to detect when a block device i... | How to programmatically detect when a device raises an interrupt? |
1,316,460,239,000 |
I'm writing a script, and I'm interested in being able to identify the transport class (fc - "fibre channel", scsi, iscsi, etc.) for a given block device. I can retrieve this information via ls -l /dev/disk/by-path on RHEL, but I'd rather query sysfs if that's at all possible (for a variety of reasons, including porta... |
Unless I get a better answer, I'm going to take this as my solution. It's very indirect but appears to work. Basically, I judged from the fact that udevd was able to make the path in /dev/disk/by-path, it must be in sysfs because to my knowledge that's all udev really does: Takes sysfs information and performs configu... | Can you identify transport via sysfs? |
1,316,460,239,000 |
I'd like to know how to create a terminal device to simulate a piece of hardware connected through a serial port. Basically, tty device with a certain baud rate that can be read from and written to between two processes. From what I understand, a psuedo-terminal is what I'm looking for, and the makedev can apparently ... |
That's probably how pty device files get created, but you don't want to do that whenever you want a pty. Any given machine usually has a complement of pty device files already created.
Pseudo TTYs are fairly OS specific and you don't mention what you want to do this on. For a modern linux, I'd take a look at openpty(3... | Creating a terminal device for interprocess communication |
1,316,460,239,000 |
I am attempting to use a TCA8418 keypad (which operates over I2C) and I have the driver loaded into the kernel, but the device was not recognized so I am instantiating it myself and am unable to bind the driver. I get the following error:
# echo -n "1-0034" > /sys/bus/i2c/drivers/tca8418_keypad/bind
-bash: echo: write... |
I was missing platform data for this device.
I was able to get it working by inserting the platform data directly into the code for the driver module:
static uint32_t tca8418_km_data[] = {
KEY(0, 0, KEY_F1),
KEY(0, 1, KEY_F2),
KEY(0, 2, KEY_F3),
...
};
static const struct matrix_keymap_data tca8418_mk... | Binding an I2C device driver |
1,316,460,239,000 |
I'm reading through the Linux Kernel Module programming guide and I am a bit onfused about how device drivers work.
I tried following along and making a basic device driver, which shows up in /proc/devices, which is great. According to the guide, to interface with the driver in Linux, a userspace program can interact ... |
Files in /dev are mostly created by the udev process which receives events from the kernel by listening to the netlink socket for NETLINK_KOBJECT_UEVENT (see man 7 netlink). The events are sent when a new kernel object (kobject) is created. These objects are also seen in the /sys sysfs filesystem. In particular, files... | Where does a device file come from? |
1,316,460,239,000 |
I'm investigating dynamic device name mapping via udev.
The goal:
On a multi user system, each user can allocate and free devices like usb-serial converters or PCIe cards (FPGAs). If an user allocates a device, the /dev/<user>/<device> nodes shall be created with a dynamic name and permissions for the allocating user.... |
1. Question:
I am not sure, but take a look at /lib/udev/rules.d/60-persistent-serial.rules
2. Question:
If udev itself assigns the device names I would put them all in a subdirectory of /dev. If not in /run/$UID/devices.
| Where is the default device name (e.g. /dev/ttyUSBx) specified? |
1,316,460,239,000 |
I'm building an embedded Linux system, based on Gentoo. Using udev, all tty devices are probed with a PROGRAM stanza to determine if they are a modem.
Right now the system boots up with 64 /dev/tty*. When udev probes the tty devices, the system runs out of memory.
How can I reduce the number of produced tty devices to... |
I'm not sure exactly how the device nodes are created (i.e. the exact sequence of events that lead to their creation), but I'm pretty sure the kernel creates the underlying devices for the 63 /dev/ttyN devices (plus /dev/tty) internally, and udev does the work of making them available inside /dev (except for /dev/tty ... | Change the number of generated /dev/tty devices |
1,316,460,239,000 |
I am a bit confused with how linux hard drive/ storage device, block files are named.
My questions are:
How are IDE devices and partitions named?
How are EIDE devices and partitions named?
How are PATA devices and partitions named?
How are SATA devices and partitions named?
How are SCSI devices and partitions named?
... |
Introduction
First of all, all the devices populate the /dev folder.
Also, it is important to note that (E)IDE and PATA terms usually refer to the same thing, which is the interface standard PATA. IDE and PATA are interchangable terms in this context.
There was a major change in naming conventions for block devices in... | Linux block devices naming |
1,444,956,591,000 |
I have a USB remote presenter that appears as a keyboard.
Using evtest I can see the input events from the device.
How can I capture those events in a shell script?
I had see some solutions using C but I would prefer something with only bash if possible.
I already tried something with xbindkeys, but my keyboard events... |
@JeffSchaller, thank you for the edits.
Based on @IporSircer's answer (thanks!), I was able to create the following script:
#!/bin/bash
device='/dev/input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd'
event_blank='*code 48 (KEY_B), value 1*'
event_esc='*code 1 (KEY_ESC), value 1*'
event_f5='*code 63 (KEY... | How can I run a shell script on input device event |
1,444,956,591,000 |
$ timeout 1 cat /dev/zero > file1
$ wc -c file1
270422016 file1
$ du file1
264084 file1
Questions :
(1) How do 270422016 null characters come out to be 264084 bytes (i.e 258M).
$ truncate -s 270422016 file2
$ wc -c file2
270422016 file2
$ du file2
0 file2
Questions :
(2) file2 has been created with same number o... |
du does not show size in bytes, but (in this case) 1024-byte-blocks. So the numbers are actually identical ( 264084 * 1024 = 270422016 )
truncate creates a sparse file provided the filesystem supports such things
/dev/zero actually produces infinite \0 bytes which are then written to file, and writing zeroes consumes... | Difference between writing file from /dev/zero and truncate |
1,444,956,591,000 |
The /proc/devices file lists devices by major revision number and name. On my system it shows (partially):
Block devices:
259 blkext
7 loop
8 sd
9 md
11 sr
65 sd
66 sd
67 sd
68 sd
69 sd
70 sd
71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
253 device-mapper
254 mdp
What are all those 'sd' ... |
The first disk /dev/sda is 8:0 (major:minor), but the major number 8 contains the next 15 disks too (Documentation/devices.txt in the kernel source):
8 block SCSI disk devices (0-15)
0 = /dev/sda First SCSI disk whole disk
16 = /dev/sdb Second SCSI disk whol... | What are all those 'sd' devices in /proc/devices |
1,444,956,591,000 |
UPD: Changed question title from manage devices to discover information about devices
One of the frequent thing I do is look up info about devices on my systems. And I am constantly find myself confused about various different commands on Linux to query available disks, network adapters, graphics cards etc.
For exampl... |
There is no single standard or tool to query hardware devices on Linux systems in general. Depending on your host's architecture, and which of its components you must query, and how much detail you need about it, you may need one or more tools specific to that component. However some commands/tools are in wider use an... | Is there a uniform way to discover information about devices? |
1,444,956,591,000 |
Simple codger question from the days of UNIX... Does Linux have character special files which correspond directly to a block special file? Back in my day üë¥üèª each disk in UNIX had both a block special and a character special file. Also, these special files were permanent inodes in the root file system.
I don't s... |
No, Linux doesn't have (and AFAIK never had) those block/char pairs.
If you want to do "raw" i/o (bypass the block buffer cache) you should either open the device with O_DIRECT or explicitly attach a raw device to it.
| Does a Linux block special file have a corresponding character special file |
1,444,956,591,000 |
I've got a USB flash drive I want to use on printers, audio equipment, and other various devices.
In my experience, most Linux is very forgiving about what partition table and FS type I use on my flash drives, but other non-linux devices aren't so nice in that regard and my flash drive is usually rejected by these thi... |
I've only seen msdos partition tables (MBR) on new flash drives.
It's usually FAT32. But you can only store files up to 4GB in size on this fs type. I would go for NTFS or exFAT instead, but this depends on the compatibility of your devices.
| Partition table & filesystem for a USB flash drive |
1,444,956,591,000 |
in my bash script I use the syntax lsblk | grep sd in order to capture all disk in my HW machines ( not include flash card or rom )
I just worry that some disk device name will be diff from sd , and I will missed these disks
is it possible ?
lsblk | grep sd
sda 8:0 0 150G 0 disk
├─sda1 ... |
Most disk drivers use the sd prefix, but not all. Historically sd stood for “SCSI disk”, but most disks use a protocol which is close to SCSI, and most of Linux's disk drivers use the generic sd layer plus a controller-specific part. However, this is not an obligation, so you need to check with your hardware. For exam... | Do all disks devices in my HW machines start with - sd? |
1,444,956,591,000 |
Under the /sys/class/scsi_device folder I have the following:
root@linux01:/sys/class/scsi_device # ls
1:0:0:0 2:0:0:0 2:0:1:0 3:0:0:0
How can I know how each of these devices is related to the disk?
For example, how can I determine if device 2:0:1:0 is disk /dev/sdb?
root@linux01:/sys/class/scsi_device # sfdisk... |
An easy way to get the correspondence is to look at the device/block subdirectory in the /sys hierarchy:
# ls -1d /sys/class/scsi_device/*/device/block/*
/sys/class/scsi_device/1:0:0:0/device/block/sr0
/sys/class/scsi_device/2:0:0:0/device/block/sda
/sys/class/scsi_device/2:0:1:0/device/block/sdb
/sys/class/scsi_devic... | Correspondence between SCSI device entries in /sys and the disks in /dev |
1,444,956,591,000 |
I need to create /dev/shm on an embedded ARM system.
From "Installed The Latest Changes to Current and......".
I see that it can be created with mkdir /lib/udev/devices/shm, but I'm wondering what is supposed to be at that location? The only directory I have at that location is /lib/modules/, there's no devices/ or ... |
An embedded system may have a static /dev, rather than use udev to populate it. If you don't have /lib/udev, then presumably your system isn't running udev. In that case, you need to create /dev/shm on the root filesystem.
If the root filesystem is an initramfs, rebuild your initramfs with an extra line in the initram... | can not create /dev/shm |
1,444,956,591,000 |
In Unix/Linux terminology, are the words 'device' and 'drive' synonymous?
|
No. Drives are devices, but not all devices are drives.
The Wikipedia article on device files lists a number of non-drive devices. For example, audio hardware is a device. Serial & parallel ports are devices. USB-connected gadgets are devices.
Keep in mind that some devices that are not drives may identify as such... | Is 'device' synonymous with 'drive' in Unix-like OS's? |
1,444,956,591,000 |
I would like to know if my definitions of devfs, devtmpfs and udev in Linux are clear and accurate.
devfs is the kernel implementation of /dev [Deprecated]. Does this get populated by the kernel like the case fordevtempfs? According to @Gilles answer yes it does. Then both devfs and devtempfs hardcode names of device... |
Pretty much correct on udev and devtmpfs, with the caveat that udev is not required (pretty much, if you have no devices that need special handling from userspace and don't need the symlinks, you don't technically need udev).
As far as devfs, I think you're correct, but I'm not 100% certain. As a general rule, unless... | Are my definitions for devfs, devtmpfs and udev in Linux right? |
1,444,956,591,000 |
Is it possible to transport whole device as in /dev entry over TCP? I'm talking about transporting e.g. joystick over TCP or mouse/rs232 port/framebuffer dev, soundcard dev, disks, etc.
I'm mostly interested in input devices - keyboards, joysticks, tablets, mice, etc. in a more generic fashion than specialized softwar... |
As long as those are USB devices, what you're looking for has been possible for several years with USB/IP. It has since been introduced in Linux 3.17. See the usbip package on Debian-like systems. You may even have Windows clients (i.e. accessing USB devices plugged on a Linux server).
As for the block devices, Linux ... | Is it possible to transport any device over TCP? |
1,444,956,591,000 |
How can I uniquely identify which device is on USB hub 6-0:1.0: port 2?
I receive messages in my dmesg every now and then and I want the system to tell me which device is connected to that port.
EDIT: OK, I can figure out which hub it is, but how can I figure out which device is on port 2 (out of four).
udevadm info ... |
I don't know of any utility that can give you this information directly, but you can get it by using a few different utilities.
Shortest route:
udevadm info -q all -p /sys/bus/usb/devices/6-0:1.0
This will give you output of which one of the lines will look like the following (obviously this output won't match your ... | How can I uniquely identify which device is on USB `hub 6-0:1.0: port 2`? |
1,444,956,591,000 |
I am curious about how data is copied back and forth between CPU and GPU memories when I run a CUDA program. Specifically, I want to know how the Linux kernel is involved in this process.
I had a few possible assumptions:
The CUDA user library sees the GPU as a file and calls read(2) and write(2) for every transactio... |
The application asks the kernel to mmap a set of buffers at startup, creating this mapping is a privileged operation.
Normal operation just fills these buffers with data (such as textures, vertices or commands), and finally makes a single kernel call to start the submitted command queue. This start strobe is the only ... | From the Linux kernel's point of view, how does a user program communicate with a CUDA GPU? |
1,444,956,591,000 |
My understanding of this is fairly minimal so bear with me. From what I gather so far, the i2c subsystem on Linux identifies devices that are attached, and then matches them against loaded driver modules somehow. Where it identifies a match, it calls that driver's probe function which actually kicks off the driver set... |
I²C doesn’t support device enumeration, so the kernel provides four different ways of initialising I²C devices:
listing them in a devicetree (the Warp i.MX7 Board does this with ov2680), in ACPI tables, or in board files (ignore the latter, it’s only provided for backward compatibility);
instantiating them explicitly... | How does the i2c subsystem match devices against drivers? |
1,444,956,591,000 |
When I do lsof +c 0 | grep /dev/zero, I see the following two lines:
sshd 19064 root DEL REG 0,4 497862 /dev/zero
sshd 19064 root DEL REG 0,4 498725 /dev/zero
The DEL keyword is what intrigues me - from the manpages, it means:
DEL for a Linux map file that has been deleted
Howe... |
DEL doesn't indicate that that process deleted /dev/zero, but that that process is using /dev/zero and the instance of /dev/zero that was being used has since been deleted. For example, if I have a command (say some-command) that uses /some/file and I do:
$ some-command &
$ rm /some/file
$ touch /some/file
Then lsof ... | Why did sshd delete my /dev/zero? |
1,444,956,591,000 |
I have a collection of WebCam's lying around. Some of them are new, some go back a decade -- have to love not having to "upgrade" devices in Linux!
Somehow I've developed the impression that manufacturers come up with different ways to convince consumers that this year's product is different from last year's (repeat ... |
There are a couple of tools you can use:
v4l2-ctl --all
That's probably the most useful, if you want more info on the formats use:
ffmpeg -hide_banner -f v4l2 -list_formats all -i /dev/video0
| How do you determine the capabilities of a WebCam? |
1,444,956,591,000 |
I have an extremely bizarre problem, occurring somewhere at the intersection of terminal, su, w3m and /dev/null:
when I su - from user1 to user2, following command does not work:
$ w3m zz.html 2>/dev/null
Error occurred while reset 800b: errno=25
but the same command works fine without the 2>/dev/null redirection:
$ ... |
An Update due to comment
Apparently the non-sense with - has been fixed at at Debian. The core of the issue still remains the same - mixing environments.
The issue is the /proc/*/fd/*!
To quote excellent answer from the user1686, don't forget to upvote it, Permission denied on /dev/stderr after sudo.
The core of the ... | terminal: Error occurred while reset 800b: errno=25 |
1,444,956,591,000 |
I have a buildroot generated kernel (3.6.11) and root file system running on an x86 device. It uses busybox and I am trying to set the BIOS hardware clock using hwclock. I get this error whenever I invoke hwclock :
can't open '/dev/misc/rtc': No such file or directory
I understand this as I only have a /dev/rtc devic... |
I can explain some of the symptoms, but not tell you how to get hwclock to work.
There is often some confusion regarding the meaning of the word device in a unix context. It can mean:
A filesystem entry of type character device or block device.
The kernel entity behind that filesystem node.
The logical entity connect... | Unable to use busybox implementation of hwclock |
1,444,956,591,000 |
Running lsblk (an excellent command for getting info about the disk configuration from within scripts and OS-agnostic high-level languages) on Fedora 29 like so:
$ lsblk --output NAME,FSTYPE,ROTA,PARTTYPE,TYPE,RAND,TRAN
NAME FSTYPE ROTA PARTTYPE TYPE RAND TRAN
sda ... |
A "1" in the RAND column means the device driver for the device adds randomness to the kernel's random number generator. This random number generator produces random numbers that can be read from the /dev/random special file. The disk drive device driver uses timing variations as the source for randomness. These timin... | lsblk column "RAND" aka "adds randomness" - what does it mean? |
1,444,956,591,000 |
I've been trying to understand the /dev/console device, but there are a few things I'm not clear on:
What is the purpose of this device? From what I can gather it's just a place for the kernel to display messages, is that right?
The virtual terminal that is assigned as the console isn't allowed to have job control. W... |
This book gives a good introduction to Linux ttys, and fgreping for register_console in Linux kernel’s drivers/char/*.c shows what’s going on with Linux console. There are many implementations of the system console available in the Linux kernel. A specific Linux installation can decide which particular device should s... | /dev/console points to tty0? |
1,444,956,591,000 |
Let's suppose you have two hard-disks:
one internal (boots GNU/Linux (Debian));
one external (USB).
fdisk -l detects both, but will not tell you which is /dev/sda and which is /dev/sdb. lsusb will tell you there is an external USB device connected, but will not tell you whether it has been mapped to /dev/sda or /dev... |
ls -l /sys/class/block/sd?
The sd? entries are symbolic links that show how the disk is connected to the computer. There'll be a /usb in there for a USB disk.
udevadm info -a -n sda
This shows all the identifying information the kernel can get at directly for sda. You'll see how the disk is connected in more detail,... | GNU/Linux: how to detect hard disk mappings? |
1,444,956,591,000 |
I understand that you can write custom udev rules to create a symlink in /dev directory.
But what is the use of having a symlink in /dev?
What is the symlink linking to?
I know you can interact with regular links in the /dev directory but not understanding what a symlink does.
ACTION=="add", SUBSYSTEM=="usb", ATTRS{id... |
Typically it's to give a known fixed pathname to access the device; /dev/mydevice is fixed but depending on the order things are plugged in it might be /dev/ttyUSB0 or /dev/ttyUSB1 or /dev/ttyUSB2 or...
This can be useful for devices which can present multiple endpoints; eg I have a USB HUBZ device that presents zigbe... | What's the reason to add a symlink to /dev directory with udev rules? |
1,444,956,591,000 |
Related, but not duplicates:
/dev/fd inconsistency
How does /dev/fd relate to /proc/self/fd/?
Why does process substitution result in a file called /dev/fd/63 which is a pipe?
On Ubuntu 18.04 and 20.04, where Ubuntu has alias ll='ls -alF' defined in ~/.bashrc, I see the following outputs for the "floppy drive" /dev... |
What does all this stuff mean?
/proc is a filesystem through which the kernel reports various information to processes. It's mostly for information about processes, hence the name “proc[esses]”. For each running process, there's a subdirectory /proc/<PID> where <PID> is the process ID.
/proc/self is a “magic” symbol... | What does the output of `ll /proc/self/fd/` (from `ll /dev/fd`) mean? |
1,444,956,591,000 |
Etries in my /proc/iomem are all 00000000-00000000
The same with /proc/ioports. They're all 0000-0000
Like:
00000000-00000000 : reserved
00000000-00000000 : System RAM
00000000-00000000 : reserved
I'm running 4.10.3-1-ARCH x86_64
Any advice on how to find out the reason by myself is also welcomed, thanks.
|
Try using sudo in front of your command, like sudo less /proc/io{mem,ports}
| Why entries in my /proc/iomem are all 00000000-00000000? |
1,444,956,591,000 |
Why is it that I cannot mmap /dev/random or /dev/urandom on Linux?
I get errno 19 which is ENODEV.
When I try the same code with /dev/zero it works.
int fd = open(path, O_RDONLY);
assert (fd > 0);
void* random = mmap(NULL, size, PROT_READ, MAP_PRIVATE | MAP_FILE, fd, 0);
int err = errno;
assert... |
You cannot mmap() /dev/random or /dev/urandom. Nor can you seek() them for that matter. And as a general rule, you cannot mmap() unseekable things. Pipes are another example of things you cannot mmap() because they are not seekable.
/dev/random and /dev/urandom are fundamentally stream-based, sequential access, device... | mmap /dev/random |
1,351,532,173,000 |
I am using Fedora 16. My /dev/sda2, mounted on / (root) with something like 50G got filled 100%:
[foampile@~ 13:13:39]> df
Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 51606140 49025452 0 100% /
devtmpfs 2988452 0 2988452 0% /dev
tmpfs 2999424 ... |
Q1. Try something like sudo du -a -m -x | sort -k1n -r | head -n40. The -a flag to du says to be recursive. The -m flag displays sizes in MB. The -x stays on a single filesystem. This will list both files and directories, and only the 40 largest (because of the -n40 option to head). Some du implementations have a -t S... | Disk size management |
1,351,532,173,000 |
We are currently working on building a system for data visualisation for different sensors.
To make development of the Linux application possible we would need to emulate the behaviour of the different character devices as the device drivers and the hardware design aren't done yet.
So is there a way to receive the s... |
You could use cuse Character Device in Userspace which is a part of the fuse library, available as a package in most systems. An example "driver" is cuse.c.
When you compile and run this example as:
sudo ./cuse -f --name=mydevice
it creates /dev/mydevice and receives all the open, close, read, write, ioctl calls on ... | Emulating a character device from userspace |
1,351,532,173,000 |
Sometimes I just need to read from a serial device, so I skip the complexities of minicom or screen and just cat. However, this only works if I first set the baud rate of the terminal using stty <baud> before attempting to open the file.
This data is likely already (or can be) buffered in the kernel and, in this case... |
It looks like you might be a bit confused about how this all works.
First, /dev/ttyACM0 does not represent the USB link, or even the USB endpoint for whatever serial adapter you have connected, it represents the UART inside the adapter that handles the serial communications. Data you read from it will not include ... | What are the implications of setting the baud rate of a terminal from userspace? |
1,351,532,173,000 |
[root@SERVER ~] ls -la /dev/vg/root
lrwxrwxrwx 1 root root 17 2012-10-28 10:29 /dev/vg/root -> ../mapper/vg-root
[root@SERVER ~]
QUESTION: Why are there symlinks? Why there couldn't be only 1 entry in the /dev for a normal LV in an LVM?? (OS: ubuntu 10.04lts)
|
On Linux, LVM is a volume management system that uses the kernel device mapper. Basically, physical volumes contain metadata that describe how blocks of data on a physical volume should be mapped to create a device mapper block device.
LVM is not the only thing that uses the device mapper, you can create mapped volume... | Why are there symlinks in /dev? (LVM) |
1,351,532,173,000 |
Following this guide to setup a macvtap works great.
An excerpt from the guide loosk like this:
# ip link add link eth1 name macvtap0 type macvtap
# ip link set macvtap0 address 1a:46:0b:ca:bc:7b up
# ip link show macvtap0
The guide then goes on to explain that you can do:
#qemu-system-x86_64 -net nic,model=virtio,ad... |
The device name is created based upon the interface index:
snprintf(tap_name, IFNAMSIZ, "tap%d", dev->ifindex);
[...]
devt = MKDEV(MAJOR(macvtap_major), vlantap->tap.minor);
classdev = device_create(&macvtap_class, &dev->dev, devt,
dev, tap_name);
If OP's ip link show macvtap0's answ... | Get which /dev/tapX got associated to a macvtap without guessing |
1,351,532,173,000 |
I have a CH341a Programmer and when I plug it into a usb port everything seems to be working except it doesn't get assigned to a Device Path (eg /dev/ttyUSB0).
Does anyone have any clue as to why this might be happening, or how to resolve this issue?
Here are some of the things I've done to troubleshoot.
lsusb
Bus 002... |
Your device isn't being assigned a serial device path because it's not a serial port. From your lsusb output, we see:
Bus 001 Device 004: ID 1a86:5512 QinHeng Electronics CH341 in EPP/MEM/I2C mode, EPP/I2C adapter
The key part is in EPP/MEM/I2C mode. The device is not configured as a UART; if it were, we would see:
B... | Why isn't my CH341a Device Getting Assigned a Device Path (/dev/ttyUSB0) |
1,351,532,173,000 |
I have what I hope is not a huge problem, but it could end up being a very large problem.
For some context, I mistakenly ran this command on my 27" iMac:
sudo dd if=ubuntu-rescue.img of=/dev/sdt bs=1m
After which, it gave me the following output:
233+1 records in
233+1 records out
244570112 bytes transferred in 2.275... |
I was surprised to discover that my Mac Book Air does have a /dev/sdt character special device. Since I could not fathom its nature, I looked up my copy of Mac OS X for Unix Geeks. At page 60, there is the list of all entries in /dev. sdt is indeed mentioned, with the unenlightening explanation:
sdt Un... | How to inspect the contents of /dev/sdt |
1,351,532,173,000 |
Note: There is a related question here which describes output for this person's specific situation and for their block device "/dev/sdb", but i am trying to set something up for a specific partition (mine is "/dev/sdb1") and my question is not answered. I would like to know where the official documentation is and how ... |
I did not find documentation, but the source code seems fairly clear
P = path (or devpath)
N = name
L = link_priority - The default is 0
S = link (or symlink)
E = property. The E is probably because properties are accessed with ENV{key}
| Where is the udev documentation for describing what "P", "N", "L", "S", "E" prefixes mean in `udevadm info` output and how they relate to rules? |
1,351,532,173,000 |
I'm in the process of designing and building a quantum random number generator for high security applications (and potentially data centres). As part of this, I would like to feed the random numbers generated by my device into /dev/random/ so that the end-users don't need to modify their applications to use a new RN s... |
replace /dev/random with my device driver
That's extremely difficult to pull off as you'd also have to replicate all current and future interfaces, or you'd break a lot of things. Maybe take a look at the source code to get an impression of it (output and input interfaces documented in length in a sourcecode comment... | Adding entropy to /dev/random |
1,351,532,173,000 |
I'm running Linux Mint 18/2 with 4.10.0-38-lowlatency kernel and KDE5 desktop.
I'm testing lots of USB flash memory with a custom bash script and f3 and I had a strange situation today. One drive didn't disappear from /dev/ when it was physically disconnected from the machine.
I also noticed that any sync command will... |
You can't delete the /dev/sdX file, instead you need to clear the device. As root:
echo "1" > /sys/block/sdX/device/delete
Or using sudo, do
sudo bash -c 'echo 1 > /sys/block/sdX/device/delete'
or
echo 1 | sudo tee /sys/block/sdX/device/delete
| Disconnected block device remains in /dev/, sync commands unkillable |
1,351,532,173,000 |
Looking through /sys/fs/selinux, I found this:
# ls -l /sys/fs/selinux/null
crw-rw-rw-. 1 root root 1, 3 Jan 24 02:47 /sys/fs/selinux/null
Which is identical to /dev/null:
# ls -l /dev/null
crw-rw-rw-. 1 root root 1, 3 Jan 24 10:47 /dev/null
So what's the point of SELinux having its own null device?
|
This is scarcely explained in Implementing SELinux as a Linux Security Module
This results in a populated selinuxfs filesystem and sets up the special null
device node used by SELinux when it closes unauthorized files upon a
context-changing execve.
Apparently programs cannot use /dev/null directly while in SELi... | Why does the SELinux filesystem have it's own null device? |
1,351,532,173,000 |
My problem
I have the following lines in /etc/devd.conf which execute the usbhidaction for a /dev/uhid* device with the named vendor and product id.
attach 100 {
match "vendor" "0x046a";
match "product" "0x0107";
action "/usr/local/bin/sudo -u my_user /usr/bin/usbhidaction -f $device-name -p /var/hid_run/... |
Devd runs BEFORE rc and therefore before devfs - this was carefully chosen by its creator - you can see his reasoning here: http://www.usenix.org/events/bsdcon03/tech/full_papers/losh/losh.pdf (Chapt. 7.2)
Devd runs entirely in user space, there is no issue with root privileges.
Unless you choose to sudo - which is w... | Why are devd rules applied before devfs rules? |
1,351,532,173,000 |
So when I were tweaking my laptop touchpad input, I came across this directory, and I found something weird.
Maybe checking the command output is better than me trying to describe it:
[root@T480-arch serio1]# pwd -P
/sys/devices/platform/i8042/serio1
[root@T480-arch serio1]# file ./*
./bind_mode: ASCII text
./descri... |
/sys is a virtual file system, and files therein aren’t really files, they’re interfaces into the kernel. The four files you’ve encountered are handled by the psmouse driver, and they have the unusual behaviour of returning ENOENT on reads if the device being examined has an “SMBus companion”. (This is a common featur... | ls says file exists, but file says no such file or directory |
1,351,532,173,000 |
In some cases when we are not near the HW Linux machine, we are only able to see disks as the following:
/dev/sdd 20511312 199536 20295392 1% /grd/sdd
/dev/sdb 20511312 487852 20007076 3% /grd/sdb
/dev/sde 20511312 91572 20403356 1% /grd/sde
/dev/sdf ... |
You can try hdparm -i {device}, like:
# hdparm -i /dev/sda
/dev/sda:
Model=SAMSUNG MZ7TD512HAGM-000L1, FwRev=DXT05L0Q,
SerialNo=S151NYADA01701
Config={ Fixed }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=16
CurCHS=16383/16/63, CurSects=1651... | how to know if disks are from Jbod or integral as part of the HW machine |
1,351,532,173,000 |
Following on from this question: rsync's relationship with special files
In order to back up device files, rsync at the destination needs to be able to call mknod. The usual approach would be to tell rsync to log in as root and use the switch --super. (e.g.
rsync -avz --super ./this root@thatserver:/backup/this)
I ... |
You can add a capability to a binary file. For example, on the remote copy
/bin/rsync to the user's home directory, eg /home/user/rsync and make it
executable by them alone, then add the capability:
sudo setcap CAP_MKNOD=ep /home/user/rsync
When the user runs this rsync on the remote it will be able to create
device ... | How can I give a user the CAP_MKNOD capabillity? |
1,351,532,173,000 |
I want to set world read/write permissions on a raw block device file (yeah, I know). I can set the permission to 666, but it goes back to 660 immediately after I touch it or write to it. Why?
[root@mysystem udev]# ll /dev/sdz6
brw-rw-rw-. 1 root disk 65, 150 Aug 30 12:09 /dev/sdz6
[root@mysystem udev]# touch /dev/sdz... |
Setting permissions in udev manually will almost never work. You should really look at adding a rule in /etc/udev that will set "MODE=0666" on the device in question. That will make it so the system creates it that way.
(adding per comment discussion)
| Vanishing permission on device file (RHEL 6.1) |
1,351,532,173,000 |
I have a loop device which shows up when I do losetup --all that I have been unable to remove.
So, I basically got myself into this issue because a created a raw image of a microSD card and then I used kpartx to mount the partitions contained within the image.
The commands that I initially used to mount the image and ... |
Since the PPID is 2, this process 10693 is a kernel process, and that explains why your kill -9 did not work.
You said you have tried sudo losetup --detach /dev/mapper/loop1. That was almost but not quite correct: try sudo losetup -d /dev/loop1 instead. But it only works after the partition loop devices have already b... | Can't remove or unmount loop device on Debian |
1,351,532,173,000 |
Background Info
I am currently trying to build a Linux From Scratch (LFS) partition.
This is my first attempt and I'm doing this to challenge myself, but I'm having trouble getting started.
I'm using a Raspberry Pi 3, with a 16gb Micro SD, currently installed with Ubuntu 20.04LTS, as my base.
I'm having trouble alloca... |
Your system has a SD/MMC card reader that does not use the (originally SCSI-based) unified storage device naming. It uses a different device name style: your whole-disk device is /dev/mmcblk0, and its partitions are listed as mmcblk0p<N> where <N> is the number of the partition. And yes, it's normal for SD/MMC card re... | cfdisk: cannot open /dev/sda |
1,351,532,173,000 |
I generally get how the whole major/minor device number thing works for a given device (though please correct me if I'm way off here), and how a major device number essentially relates to a class of device (be that a block device or character device/character special), while the minor number relates to a specific type... |
On my system, /proc is 6h, and /dev is 5h.
A quick test:
# for x in a b c d e f g h i j; do mkdir $x; mount -t tmpfs tmpfs $x; done
# stat */.
gave numbers 33h to 3dh with 35h missing from the middle (it was used by /run/user/1000/gvfs). Seems like just dynamic allocation with the first free number used at mount time... | How are minor device numbers assigned for unnamed/non-device mounts (major number 0)? |
1,351,532,173,000 |
I've been having a strange issue the past couple of months where the second USB device to be plugged into my laptop is unresponsive, despite showing up in lsusb and dmesg seemingly without issue.
This is the case with both my USB mouse and USB keyboard. Whichever device is plugged in first (to either USB port, it does... |
Facepalm
It seems that once upon a time while attempting to setup a backup HDD I accidentally began writing backup data to /run/media/$USER/BackupData while the volume was not actually there... In turn there was a dump of random backup data in the run filesystem clogging it up. After rming this backup data I plugged ... | USB device (keyboard or mouse) shows in `lsusb` but does not work if it is the second USB device to be plugged in |
1,351,532,173,000 |
I am working on a project, in which the ultimate goal is to successfully wipe iOS from an iPhone and install TinyCore Linux in it's place. I expected the iPhone to function like an external drive when connected to a computer running Linux (i.e. a mountable device or partition containing the phone's entire storage, inc... |
As it turns out, there's already a tweak to do this on Cydia. It's called Apple File Conduit "2".
| Access iphone storage as device/partition |
1,351,532,173,000 |
I have one dvb-t and one dvb-s card in my system which are in
/dev/dvb/adapter0
and
/dev/dvb/adapter1
Is there a way to find out which card is currently working? and which one isn't?
|
You can use lsof to see which processes are using a file. In your case:
$ lsof /dev/dvb/adapter0
$ lsof /dev/dvb/adapter1
Each call will give you a list of the processes having requested a handler (file descriptor) to your device. If nothing is printed, you can conclude that your device is not currently in use. Here'... | Which device is working |
1,351,532,173,000 |
My solution (ArchLinux ARM on RaspberryPi) requires that a non-privileged user has to have access to the /dev/ttyAMA0 port. In final implementation that user will be automatically logged in and a start-up script would be launched, but that is off-topic.
The problem is that the /dev/ttyAMA0 port (owned by root:tty) has... |
It turns out that this problem was specific to RaspberryPi, since the /dev/ttyAMA0 serial port that's linked to the hardware GPIO pins by default is initialized for virtual console access.
I had to remove any reference to /dev/ttyAMA0 in /boot/cmdline.txt, reboot, and the /dev/ttyAMA0 now was with proper group permiss... | Changing the /dev/tty* permissions at startup |
1,351,532,173,000 |
Background
I have been rebuilding a small home NAS. This server represents my first 'real' foray into the world of server administration and it has taught me quite a bit already. Originally, the thing was setup using FreeNAS on a thumb drive with 3 magnetic disks configured in a raidz1. I have since resolved to mig... |
ada devices are drives connected to newer SATA ports. Some people missed the memo so DevFS was modified to provide symlinks to these device names as the traditional ad devices. However, the system likely already has some older SATA ports or IDE ports, so those will occupy the lower ad device numbers (ad0, ad1, etc). ... | FreeBSD: Remove symlinks in devfs |
1,351,532,173,000 |
I've run into an error stemming from lacking permissions when using the CDIO library to issue an eject command to my USB CD-ROM drive. I always get an error message like this:
INFO: ioctl CDROM_SEND_PACKET for command PREVENT ALLOW MEDIUM REMOVAL (0x1e) failed: Operation not permitted
The ioctl call is part of the cd... |
OK, after a hint from one of the maintainers of libcdio, I found out that the version I installed was out of date and contained a bug based on improper use of O_RDWR vs. O_RDONLY. After the update, suddenly everything works fine. Nevertheless thank you for your hints!
| How to I set the permissions necessary to make the ioctl CDROM_SEND_PACKET command run? |
1,351,532,173,000 |
TL;DR: How can I boot a squashfs partition from initramfs with a predictable partition name? /dev/sda2 won't work because the device names get reordered randomly and sometimes it will boot from the wrong partition.
We use a custom installation of Gentoo that looks like this:
/dev/sda1: /boot ext4 (unencrypted)
/dev... |
There was no need to rely on any special tools for this.
Knowing the squashfs partition is always second in the partition scheme is enough: just set the UUID of the first partition of the pendrive, use $(findfs UUID=first-pendrive-partition) and do sed s/1/2/ on the result.
The system always detects the correct partit... | Predictable partition name for squashfs partition in initramfs |
1,418,080,813,000 |
When USB devices are connected in Linux the kernel assigns them a minor device number (i.e. the 0 in /dev/ttyUSB0). It seems that if I have a device at /dev/ttyUSB0, when I remove it and plug in a new USB device then new device will get a distinct device number. But if I wait long enough or add enough devices eventual... |
I'll half-answer my own question: I couldn't find any clear documentation of how device numbers are reused, but I did find a way to assign a more unique number to a device.
The trick is to use udev's IMPORT statement to generate a random number, for example this rule:
KERNEL=="ttyUSB*", IMPORT{program}="/bin/bash -c '... | How does Linux decide when to reuse USB minor device numbers? |
1,418,080,813,000 |
I have a remote serial device attached to /dev/ttyAMA0 that requires a serial command to be issued before a program connects so that the program will read the return string and automatically recognize it. I can not change the behavior of the main program.
Is there any way to run a script when a userland program access... |
I ended up monitoring the log file and triggering the even when it wanted to connect.
tail -f /tmp/lw.stdout.log | grep -q --line-buffered "INFO: Connecting to USB,/dev/ttyAMA0" && echo -n $'\cx' > /dev/ttyAMA0
| Run script on /dev/tty access |
1,418,080,813,000 |
This is probably a silly-sounding question, but one that I think there exists an objectively right answer to which makes me compelled to ask it.
I am trying to understand the fundamentals of linux systems and especially how device drivers work so I went on the hunt for a good book on the subject. Essential Linux Devi... |
The documentation available on-line has just gotten that good in the meantime.
In all seriousness, I think that people interested in (general) kernel driver programming can easily find enough documentation on the web to get them so far started, that they can then start completing their knowledge by reading the existin... | What has happened w.r.t books about linux device driver programming in the last eight years? [closed] |
1,418,080,813,000 |
I'm trying to use the following command:
dd if=/dev/urandom of=/dev/sg11 bs=16K count=1
But when executing it, I get the following error:
dd: writing `/dev/sg11': Function not implemented
When I try with dd if=/dev/urandom of=/dev/sg11 bs=16K count=1 conv=fsync, then I get a cannot allocate memory error, which becom... |
/dev/sgxx is a SCSI-generic device, which allows sending and receiving of raw SCSI commands. When you write to the device, you are expected to start the write with a SCSI header, which defines the operation you wish to do.
Writing random data to an sg device is really a bad idea. You'll be sending random SCSI commands... | dd outputting: "function not implemented" when trying to write to /dev/sg11 |
1,418,080,813,000 |
A shell in Linux (for example: bash) have its stdin and stdout and stderr file descriptors all point to the same device file, for example, the following are thestdin and stdout and stderr file descriptors for bash:
Now /dev/tty1 is not a "real" file that you can read from and write to, it is a device file that points... |
A device node points to a single device, which in Linux is handled by the kernel. When bash reads from /dev/tty1, it reads from the device driver managing the first terminal; when it writes to it, it writes to the same device driver.
| Can a device file in Linux point to multiple files? |
1,418,080,813,000 |
I have three identical servers, all three same cabeling and correctly placed hard-disk. Allthough one of the server got /dev/sdg /dev/sdh for the sata-ssds while the other two servers got them on /dev/sda /dev/sdb - Im using Proxmox with ZFS.
The SATA-SSDs are connected onBoard (SATA-Cabeling to Board) while the Hard-... |
The /dev/sd* names are simply assigned in detection order, which may vary from one boot to the next if storage driver module loading order is not exactly the same each time, or if disks are plugged or unplugged. The current wisdom is to use something else in your configuration:
in /etc/fstab, you could use the UUID= ... | How does Debian or Linux in general assign device-names like /dev/sdX on ZFS? |
1,418,080,813,000 |
If I use:
strace echo 'a
b
c' > file
The bottom lines are:
write(1, "a\nb\nc\nd\n", 8) = 8
but in
strace echo 'a
b
c
d' > /dev/pts/0
These lines are:
write(1, "a\n", 2) = 2
write(1, "b\n", 2) = 2
write(1, "c\n", 2) = 2
write(1, "d\n", 2) ... |
This is very simple.
The external echo command that you are running from strace is very probably the one from GNU coreutils. This is written in the C programming language, and uses the C runtime library functions such as putchar() and fputs() to write what it needs to write to the program's standard output.
In the C ... | Why does terminal takes input line by line? |
1,418,080,813,000 |
I am installing CentOS Linux distribution.
At the partition step, CentOS tells me that it has detected a sda HD in my machine and I should create partitions and assign mount points for this disk.
But I found the logic a little twisted. I understand that Linux treat everything as file and sda is usually the device fil... |
What /dev/sda means
There are four levels: raw disk, raw partition of that disk, formatted filesystem on a partition, and actual files stored within a filesystem.
/dev/sda means an entire disk, not a filesystem. Something with a number at the end is a partition of a disk: dev/sda1 is the first partition of the /dev/sd... | How could Linux use 'sda' device file when it hasn't been installed? |
1,418,080,813,000 |
I have a hard drive in a USB enclosure that I am doing some data recovery on. The drive is in extremely bad shape and frequently resets on reads.
The device registers as /dev/sdb. Sometimes, probably about once in every few thousand resets, for some reason it switches over to /dev/sdc. The only way to get it to go bac... |
Access the device through the /dev/disk/by-xxx paths.
These paths remain the same for the device/partition, with symlinks to the proper /dev/sdXY device itself, maintained by the system. So while the device might reconnect to another virtual device, the path you can use doesn't change.
/dev/disk/by-uuid/
Every drive... | Prevent USB storage from using different device on reset |
1,418,080,813,000 |
I'd like to mess around a bit with controlling the Apple logo on the outside of my MacBook Pro from Ubuntu. (I'd like to hook it up to my music and have it light up and down with the decibels :])
Does anyone know what this device is and how I could control it? Is it a device in /sys/devices?
|
yes. it's a translucent piece of plastic whose brightness directly correlates to the brightness of your display.
All you need is something that will dim and brighten your display in time to your music.
| Is there any way to control the light value of the Apple logo on a MacBook? |
1,418,080,813,000 |
Post-POST, post-BIOS screen, post-GRUB; when I boot Debian with a SD card or USB stick plugged in, one of the first things to pop up on the screen (so quickly that usually I don't even notice) looks a little something like:
[sdX] no caching page mode present
text, text, X starts about halfway through that long list o... |
"sd" stands for SCSI disk. When a disk device is first detected, the kernel (among other things) requests the device's caching mode page, which will indicate if the device has an onboard memory buffer that sits in front of the media (disk, flash memory, whatever). In your case the device doesn't have a caching mode ... | What's the difference between 'no caching page mode present' and 'assuming drive cache. write through.' |
1,418,080,813,000 |
Due to a broken udev setup on a machine from which I'm trying to rescue data (see this post of mine) I'm trying to write to a "character special" device corresponding to a USB flash drive, but am encountering difficulty.
What I would expect is that (with root permissions) I could do this:
echo "test 123" > /dev/bus/us... |
Those are "raw USB" devices. Using them requires several USB-specific ioctl() functions: just writing raw data into them from the shell is unlikely to accomplish much at all. The data would have to be formatted into valid USB packets first, and the ioctl() functions used to establish connection to the right USB endpoi... | How to write to a character special device? |
1,418,080,813,000 |
Random Access Memory (RAM) is a block device, why Linux uses a character device file instead of a block device file for user-processes to interface with /dev/mem?
$ ls -l /dev/mem
crw-r----- 1 root kmem 1, 1 Jul 24 19:05 /dev/mem
|
The answer is in the question: RAM isn’t a block device, it can be accessed and modified without constraints (physically) and doesn’t need any buffering.
/dev/mem on Linux is handled by drivers/char/mem.c which implements a number of character devices: /dev/mem, /dev/kmem (before 5.13), /dev/null, /dev/port, /dev/zero... | Why Linux uses character device interface for /dev/mem? |
1,418,080,813,000 |
I know that the file /dev/ptmx is used to generate a master file for a pseudo-terminal. But I have found out that Fedora has another ptmx file (/dev/pts/ptmx):
What is the purpose of this second file?
|
The reason, like with many things in the world of computing, is history and backwards compatibility.
Back in 2.4.* kernels, before udev (the current virtual filesystem solution for /dev) existed in Linux, there was two competing solutions, the "traditional Unix way" of having the devices in a real directory on a root ... | Why does Fedora have two `ptmx` files? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.