Hot answers tagged

112

Linux automatically detects SSD, and since kernel version 2.6.29, you may verify sda with: cat /sys/block/sda/queue/rotational You should get 1 for hard disks and 0 for a SSD. See this answer for more information...


32

When a program reads or writes data from a file, the requests go to a kernel driver. If the file is a regular file, the data is handled by a filesystem driver and it is typically stored in zones on a disk or other storage media, and the data that is read from a file is what was previously written in that place. There are other file types for which different ...


31

I think you might be able to accomplish what you want using network block devices (NBD). Looking at the wikipedia page on the subject there is mention of a tool called nbd. It's comprised of a client and server component. Example In this scenario I'm setting up a CDROM on my Fedora 19 laptop (server) and I'm sharing it out to an Ubuntu 12.10 system (client)...


28

Use smartctl to retrieve vendor information, sudo smartctl -a /dev/sdb If you see a line like this, Rotation Rate: Solid State Device That would be a SSD drive.


22

SCSI is not only a type of hardware interface, but also a command protocol, which is used for abstraction of most of the modern storage devices. Linux scsi driver is a high level driver that handles a variety of storage hardware. Protocol: http://en.wikipedia.org/wiki/SCSI_command Extract from SCSI on wikipedia: Other technologies which use the SCSI ...


20

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 device: readlink -f /sys/class/block/...


19

One alternative to nbd (if you're interested) is using iSCSI. tgtd can be configured to have a /dev device as its backing storage for a particular iSCSI IQN. If you're on a RHEL system so you just need to install scsi-target-utils and then configure/start tgtd on the source system. Configuration of tgtd can get involved but Red Hat provides plenty of ...


18

Yes, you can do this with the /sys filesystem. /sys is a fake filesystem dynamically generated by the kernel & kernel drivers. In this specific case you can go to /sys/block/sda and you will see a directory for each partition on the drive. There are 2 specific files in those folders you need, start and size. start contains the offset from the beginning ...


17

You can look in /sys/block: -bash-3.2$ ls -ld /sys/block/sd*/device lrwxrwxrwx 1 root root 0 Jun 8 21:09 /sys/block/sda/device -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0 lrwxrwxrwx 1 root root 0 Jun 8 21:10 /sys/block/sdb/device -> ../../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0 lrwxrwxrwx 1 root root 0 Jun 8 ...


17

There're handy dmsetup ls --tree and lsblk utils.


17

libata does not have a noprobe option at all; that was a legacy IDE option... But I went and wrote a kernel patch for you that implements it. It Should apply to many kernels very easily (the line above it was added 2013-05-21/v3.10-rc1*, but can be safely applied manually without that line). Update The patch is now upstream (at least in 3.12.7 stable ...


14

With lsblk (part of the util-linux package): lsblk -d -o name,rota NAME ROTA sda 0 sdb 0 sdc 1 where ROTA means rotational device (1 if true, 0 if false)


14

You can throttle a pipe tar -cf - . | throttle -M 1 | tar -C /your/usb -xvf - -b -k -m limits are in bits -B -K -M are bytes


12

hdparm -i /dev/sdb That should give you the model and serial number of the drive.


12

Run udevadm info -a -n /dev/sda and parse the output. You'll see lines like DRIVERS=="ahci" for a SATA disk using the ahci driver, or DRIVERS=="usb-storage" for an USB-connected device. You'll also be able to display vendor and model names for confirmation. Also, ATTR{removable}=="1" is present on removable devices. All of this information can also ...


12

You can do that with the device mapper and its snapshot target. Basically, you'd do the same as what LVM does when you create a writable snapshot. dev=/dev/read-only-device ovl=/path/to/overlay.file newdevname=newdevice size=$(blockdev --getsize -- "$dev") loop=$(losetup -f --show -- "$ovl") printf '%s\n' "0 $size snapshot $dev $loop P 8" | dmsetup ...


12

Use "geom disk list". This will show all disk-like devices (technically, every instance of GEOM "DISK" class).


11

I think I found the answer: blkid From the man page: The blkid program is the command-line interface to working with the libblkid(3) library. It can determine the type of content (e.g. filesystem or swap) that a block device holds, and also attributes (tokens, NAME=value pairs) from the content metadata (e.g. LABEL or UUID ...


11

Hardware problems have physical hardware solution. Did you consider to unsolder or cut the power supply of the drive ? EDIT: Ok if thats not an option people are using this before to hot-plug a hard drive. You could use that to disable your drive. echo 1 > /sys/block/sdb/device/delete Note that any other process can force a scan of the SATA bus, and ...


11

There are multiple ways of accomplishing this. 1. Add your user to the group that owns the device Generally in most distros, block devices are owned by a specific group. All you need to do is add your user to that group. For example, on my system: # ls -l /dev/sdb brw-rw---- 1 root disk 8, 16 2014/07/07-21:32:25 /dev/sdb Thus I need to add my user to ...


10

you can remount with sync option and then remount it back with async: mount -o remount,sync /mountpoint mount -o remount,async /mountpoint Using remount option will not mess with processes using remounted filesystem.


10

I would suggest you use udev to set parameters for the SSD disks. This way you can configure a specific queue scheduler that is more appropriate for SSD, etc. You can also apply parameters only to some of the devices, based on a lot of parameters. You can obtain the specific attributes necessary to match your devices (eg. the disk model and manufacturer) by ...


10

I would assume you are trying not to disrupt other activity. Recent versions of Linux include ionice which does allow you to control the scheduling of IO. Besides allowing various priorities, there is an additional option to limit IO to times when the disk is otherwise idle. The command man ionice will display the documentation. Try copying the file ...


10

If I understand your question you want to know which device was used for a given mount. For this you can use the df command: $ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/fedora_greeneggs-root 50G 21G 27G 44% / devtmpfs 3.8G 0 3.8G 0% /dev tmpfs 3....


10

Globbing (which is what you're doing with your wildcard matching) will expand the current command line. For example: ls [abc]1 gets expanded to: ls a1 b1 c1 Globbing only works where the command allows multiple arguments. While umount /dev/sdc2 /dev/sdd2 Works, there's no way to express the same thing for mount. So you have to loop it: for m in $(...


10

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 computer by hitting the wrong key. Consider the kinds of power tools used in civil construction and what you can screw up by doing one little thing wrong. Could those things be made more preventable? Probably, but the counter ...


9

It's a Xen device. See e.g. Xen on Debian wiki


9

On recent version of Linux, there are /dev/disk/by-{id,label,path,uuid} directories that contain automagic symlinks to the various /dev/sdX and /dev/sdXN entries (I believe all of these are setup by udev). These provide more stable and informative names for your disks and partitions. I find /dev/disk/by-label/ the most useful (especially if you label your ...


9

Have a look under the /sys/ directory. In particular, /sys/block/ contains symlinks to block devices in /sys/devices/. /sys/block/sdX/removable looks like it will read as 1 for a removable device, and 0 otherwise. This gives you a basic check for removability. I'm not sure if there's a better way to check if it's a USB device, but readlink /sys/block/sde ...



Only top voted, non community-wiki answers of a minimum length are eligible