Tag Info

Hot answers tagged

30

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...


22

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 ...


16

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. You're probably 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 ...


13

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 ...


13

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 ...


13

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 ...


10

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 ...


9

You obviously prefer the SAN solution. Beside the already mentioned iSCSI and NBD, you have also the AoE (ATA over ethernet) approach. This is very easy to do: On the serving side you need to modprobe aoe vbladed 0 0 eth0 /dev/sdc On the client side modprobe aoe aoe-discover aoe-stat e0.0 1000.204GB eth0 1024 up Your devices are in ls ...


8

I don't think you can do it in place but if you have enough space this should work: # Create the files that will hold your data dd if=/dev/zero of=part-00 bs=1M count=4k dd if=/dev/zero of=part-01 bs=1M count=4k # Create the loop devices losetup /dev/loop0 part-00 losetup /dev/loop1 part-01 # Create a RAID array mdadm --create /dev/md0 --level=linear ...


8

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 ...


8

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 ...


7

If you can see the LED on the drive, or listen to the disk noise, you can run sudo cat /dev/sdb >/dev/null and see which drive suddenly becomes continuously active. Or, if you're going by noise, sudo find /mount/point >/dev/null which will make the heads move more (it may be better not to do it on the failing disk, and instead use a process of ...


7

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 ...


6

That's to do with the kernel doing a lot of buffering, including buffering writes to your device. If you issue: cp large_file /mnt/htc/ cp will return as soon as it has finished writeing the data, but (for reasonably "slow" devices/connections) well before that data has actually been written. (Unless cp or the tool you use itself issues fsync or similar ...


6

(You didn't specify your operating system. I'm assuming it's some variant of GNU/Linux, the general concept applies to other UNIXes as well; details may not.) 1. How does one know what the device file for a device is in general? Basically, you have to know which device file name corresponds to which device. Sources of this information are the Linux ...


6

Using sgdisk You can use sgdisk to print detailled information: sgdisk --print <device> […] Disk /dev/sdb: 15691776 sectors, 7.5 GiB Logical sector size: 512 bytes […] When you multiply the number of sectors with the sector size you get the exact byte count that should match the output of dd. Using /sys directly You can also get those numbers ...


5

The device file is how you tell mount what device or other location you want to access. So there's no way it can guess.¹ There are several different kinds of filesystems you can mount. For disk-backed filesystems (the first kind that generally come to mind), the device is a block device. Its name is generally /dev/something, where the something part encodes ...


5

As the inimitable Gilles mentioned in this answer of his, if your kernel uses udev you can use the udevadm command to interrogate a device: udevadm info -n /dev/sda -a (Sadly, in some cases [doubly sad is that it's true in this case for me] udev is not used and/or udevadm is not available.)


5

udev outputs logging information to /var/log/messages, but by default it only logs errors, and it happens you've constructed a command that doesn't do what you want, but also doesn't error out. The >> redirection is handled by your shell, and udev doesn't run the command through a shell, so it's literally running the binary /bin/echo and passing it the ...


5

You can create a new rule to /etc/udev/rules.d/. First read the file /etc/udev/rules.d/README. In the new rule file, add something like KERNEL=="sd?1",ACTION=="mount",RUN+="/path/to/script.sh" (I did not try the above line, try your own rules.) Note that the script will be run as root. You might want to use su to change that. Using ACTION=="add" would ...


5

udev knows your system. so you can get info through udevadm , under /sys/ like this (run as root, or with sudo depending on your distro) udevadm info -a -p /sys/block/sdb udevadm info -a -p /sys/block/sdc reading through the output you'll come across some meaningful results, such as ATTRS{vendor} ATTRS{model} you should be able to get some info about ...


5

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 ...


5

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 ...


5

I dont think lsblk and file -s is that ugly, but there is an alternate way. You can use blkid instead. By default, blkid without any arguments will list the known block devices, and a little bit of information about them, including the filesystem type. The format is also in key=value pair format (by default), which makes it easy to dump into a script. This ...


5

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 ...


5

Instead of cp -a /foo /bar you can also use rsync and limit the bandwidth as you need From the rsync manpage: --bwlimit=KBPS limit I/O bandwidth; KBytes per second and the final command: rsync -av --bwlimit=1 /foo /bar


4

So, question: can I force to map the drives with fixed path? I tried using Labels but it didn't seem to work. Use UUID: $ ls -lF /dev/disk/by-uuid/ total 0 lrwxrwxrwx 1 root root 10 Sep 15 15:35 61965e0c-8aba-4207-9424-1350aa6e051e -> ../../sda2 lrwxrwxrwx 1 root root 10 Sep 15 15:35 e002a7bc-02da-47a8-ab98-1225e6ace6d5 -> ../../sda1 lrwxrwxrwx ...


4

Loop devices with backing file less than 512B are not listed in /proc/partitions, which losetup uses to look up loop devices. I believe the reason why it is not listed there is that by creating such loop device, you get block device which is smaller than its blocksize (512B in case of loop device). So while losetup and kernel allows you to create loop ...


4

/dev/xvde is a xen virtual disk, and /dev/xvde1 and /dev/xvde2 are partitions on that virtual disk. On the Xen host (the dom0), /dev/xvde could be a raw disk or disk partition, an LVM volume, a disk image file, an iscsi disk or something else. From your VM's POV, that's completely irrelevant - just treat it the same as any other disk. It just happens to ...


4

The kernel, and other programs, occasionally look for partitions on the disk, for example at bootup. If you have a partition table: that's great, it will find them, and you can put anything you'd like inside that partition. But if you don't have partitions, then you have to be careful not to put something inside the disk that might look like a partition! ...



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