Questions tagged [block-device]

A data storage device that supports reading/writing data in fixed-size blocks, sectors, or clusters.

Filter by
Sorted by
Tagged with
16
votes
4answers
7k views

Find filesystem of an unmounted partition from a script

I'm writing a custom automated install using AIF (Arch Installation Framework), and I need to find the filesystem on a partition given a partition. So far I have this: grok_partitions () { local ...
70
votes
3answers
88k views

What are character special and block special files in a unix system? [duplicate]

How are character special files and block special files different from regular files in a Unix-like system? Why are they called “character special” and “block special” respectively?
14
votes
1answer
5k views

GNU/Linux: overlay block device / stackable block device

GNU/Linux has union mount that overlays dirs. So you can mount a writeable dir on top of a read-only dir. When the writeable dir is unmounted the read-only dir is untouched. I am looking for the same ...
53
votes
4answers
111k views

Determine what device a directory is located on

If I do # cd / # ln -s /home test # cd test # mount --bind $PWD /mnt the entry in /proc/mounts is /dev/sda2 /mnt ext4 rw,noatime,data=ordered 0 0 which is the device that is mounted to /home and ...
23
votes
4answers
15k views

How to tell Linux Kernel > 3.0 to completely ignore a failing disk?

I have a Samsung laptop (Chronos s7) with one SATA hard disk on bus ata:1, which is detected as /dev/sda, an 8G SSD on ata:2, /dev/sdb, and various other devices on the rest of SATA interface. The ...
27
votes
8answers
66k views

How to determine which sd* is usb? [duplicate]

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 ...
18
votes
1answer
28k views

Give a specific user permissions to a device without giving access to other users

I have a card reader attached on /dev/sdb. What I do is giving all permissions to owner, group and the rest of the world, using: sudo chmod 777 /dev/sdb Can I just use another combination, allowing ...
17
votes
5answers
5k views

Is there a way to sync only one partition?

Is there a way to sync only one partition instead of all partitions? Something like "sync /dev/sdc1".
139
votes
3answers
636k views

How to list disks, partitions and filesystems in Linux? [duplicate]

In Windows, if you type LIST DISK using DiskPart in a command prompt it lists all physical storage devices, plus their size, format, etc. What is the equivalent of this in Linux?
28
votes
2answers
46k views

What is a block device? [duplicate]

I know many examples of block devices (HDD's, SSD's, files, ...), but I haven't heard a simple definition of it. Especially since files are apparently included in the definition I feel a bit confused.....
6
votes
1answer
5k views

Udev rule is not being used?

I'm setting up udev to handle my external USB hard drive when it gets plugged in and removed (no mounting yet). So far, I've made two new rules in /etc/udev/rules.d/10-local.rules to log adding/...
4
votes
2answers
3k views

Linux Mint: drives' map changing at reboot brings fstab error

I've set up fstab to auto mount media drives on a Linux Mint machine. The OS is installed on a IDE/ATA Disk while 3 SATA disks hold data to share. The BIOS has the ATA disk as first boot device. All ...
3
votes
1answer
1k views

What are the pros and cons of badblock's two non-destructive tests?

I use badblocks to test my 32GB class-10 microSD card that I use to boot my RPi. I already have a functioning file system on it, so I don't want to scan it with the -w option (destructive read-write ...
211
votes
9answers
267k views

How to know if a disk is an SSD or an HDD

I want to know whether a disk is a solid-state drive or hard disk. lshw is not installed. I do yum install lshw and it says there is no package named lshw. I do not know which version of http://pkgs....
15
votes
4answers
4k views

Why does one need a loop device at all?

I previously used to create image files using dd, set up a filesystem on them using mkfsand mount them to access them as mounted partitions. Later on, I have seen on the internet that many examples ...
6
votes
3answers
5k views

When and why do block devices need to be partitioned? [duplicate]

Possible Duplicate: The merits of a partitionless filesystem So I've got a block device, say /dev/sda or /dev/loop0. Clearly if I want to boot from the former, or I want to subdivide it into ...
3
votes
1answer
667 views

Is a device being a block or character device determined purely by hardware?

From https://unix.stackexchange.com/a/472920/674 A "character device" and "block device" are abstractions, usually used in Unix-style systems in classifying various devices. Is a device being a ...
12
votes
2answers
7k views

How to get block device name from partition device name?

I'm looking for a portable way to obtain parent block device name (e.g. /dev/sda) given the partition device name (e.g. /dev/sda1). I know I could just drop the last character, but that wouldn't work ...
5
votes
1answer
510 views

Can ext4 filesystem withstand a bad sector (unreadable)?

If a hdd bad sector happens in the metadata for /home/user/me on an ext4 fs would that mean data loss for all subdirectories? Background: I know that many users are satisfied with the ext4 ...
3
votes
1answer
273 views

Command to reread partitions from media

When I insert media (e.g. an SD card) the system (Ubuntu 12.04) reads the partition table and creates all the /dev/*[1234] links to each partition. If I repartition the media I have to physically ...
-4
votes
1answer
85 views

Are there implications between block/character device and random/sequential access? [closed]

Operating System Concepts says: Devices vary on many dimensions, as illustrated in Figure 13.7. • Character-stream or block. A character-stream device transfers bytes one by one, whereas a ...
3
votes
2answers
800 views

How to make sure that certain devices always use the same device file?

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 ...
2
votes
1answer
4k views

Permanently mounting loop device

I created a file touch /datastore/virtual/pseudoblock created a loop device with it sudo losetup /dev/loop0 /datastore/virtual/pseudoblock (although I got a warning about its size) and then ...
2
votes
1answer
426 views

Block device cache v.s. a filesystem

Block devices provide buffering. This means that write() on a block device can return success, before the kernel has written the data to the device. A program can wait for all the buffered writes by ...
2
votes
2answers
1k views

What do device type numbers mean?

file /dev/* prints the description of a bunch of files as "block special (M/N)" and "character special (M/N)", where M and N are numbers. For example: $ file /dev/null /dev/null: character special (1/...
0
votes
2answers
379 views

Do “serial ports” or “parallel ports” apply to character devices only, but not to block devices?

From http://haifux.org/lectures/86-sil/kernel-modules-drivers/node10.html A Character ('c') Device is one with which the Driver communicates by sending and receiving single characters (bytes, ...
42
votes
4answers
22k views

How can I mount a block device from one computer to another via the network as a block device?

Is it possible to export a block device such as a DVD or CDROM and make it so that it's mountable on another computer as a block device? NOTE: I'm not interested in doing this using NFS or Samba, I ...
20
votes
3answers
60k views

partitioning using 2 hard disks (SSD and non-SSD) in linux [closed]

I have the following free spaces on 2 disks: SSD - 240G (sda) non-SSD - 240G (sdb) I understand that I should use SSD to install packages and non-SSD just for storing data. What's the best ...
36
votes
7answers
65k views

How do I correlate /dev/sd devices to the hardware they represent?

A drive is beginning to fail and I only know the device by its /dev/sdb device file designation. What are the ways that I can use to correlate that device file to an actual hardware device to know ...
29
votes
8answers
18k views

Make disk/disk copy slower

Is there a method of slowing down the copy process on Linux? I have a big file, say 10GB, and I'd like to copy it to another directory, but I don't want to copy it with full speed. Let's say I'd like ...
19
votes
7answers
82k views

Mapping between logical and physical block device names

I cannot figure out the mapping between different logical and physical block device names. The output of "cat /proc/diskstats" is : 104 0 cciss/c0d0 ... 104 1 cciss/c0d0p1 ... 104 2 cciss/...
14
votes
3answers
42k views

Persistent blockdev setra read ahead setting

I've got some SSDs mounted up on /dev/sda1 and /dev/sdb1 on a SLES 11 SP2 server, and I was able to tweak the read ahead setting with blockdev --setra: sudo blockdev --setra 4096 /dev/sda sudo ...
14
votes
3answers
13k views

How to read the in-memory (kernel) partition table of /dev/sda?

I accidentally overwrote my /dev/sda partition table with GParted (full story on AskUbuntu). Since I haven't rebooted yet and my filesystem is still perfectly usable, I was told I might be able to ...
10
votes
3answers
1k views

How can `dd` be used to right-shift data blocks?

Consider a 100MB raw block device as a simple example. That is 204800 blocks of 512 bytes each for a total of 102760448 bytes. The challenge is to shift the first 98MB (200704 blocks) so there is a ...
7
votes
1answer
159 views

Has 'sync' been proved to be necessary when writing to a block device with 'dd'?

Every time I've written a file to an empty raw block device, e.g. # dd if=image.iso of=/dev/sdb status=progress I've never used any type of sync (i.e. sync; conv=fsync; conv=fdatasync; oflag=sync; ...
6
votes
1answer
3k views

Run shell script when new volume mounted

I'm interested in running an rsync script whenever any new volume is mounted on my Debian box. What are some potential triggers / strategies for listening for a new volume mount?
19
votes
5answers
8k views

Mounting multiple img files as single loop device

Is there a way to take a disk img file that is broken up into parts and mount it as a single loop device?
10
votes
1answer
3k views

Find out if a specific device is an USB mass storage

Context I'm automating SD card imaging from an existing dd factory image. The SD card is always connected through an external USB card reader and thus appears in the system as a SCSI block device /...
6
votes
1answer
4k views

Obtain device name and mount point if partition label is known

How to obtain the partition device name and mount point when the file system label is known? There are several possibilities: Linux File system label to device name The device name can be obtained ...
4
votes
5answers
8k views

From df device name to physical drive name (vendor / type)

Seeing the device name by df, is it somehow possible to resolve it to the physical drive name such as vendor / type. /dev/sda3 915.4G 34.9G 880.0G 4% /share/HDA_DATA /dev/sdd3 ...
4
votes
2answers
1k views

why does blktrace only write blocks of 8?

I want to understand the I/O pattern a database is writing to disk to decide how many disks to use for best performance. To analyse the I/O pattern I want to use blktrace and I have to grok it first. ...
7
votes
1answer
1k views

How does cat 'know' the optimum block size to use?

From reading this, it seems that when copying data to a different hard drive, cat automatically uses the optimum block size (or very near it). I wonder how it determines the optimum block size, and ...
6
votes
3answers
23k views

how to set block size using blockdev command

Anyone can provide me any test case for the below command: blockdev --setbsz BYTES to set/change the block size. I have tried like below but no luck. $ blockdev --setbsz 2048 /dev/sda5 blockdev: ...
5
votes
3answers
5k views

How to get disk name that contains a specific partition

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 ...
5
votes
1answer
1k views

Low-level disk access in FreeBSD

I'm developing a utility that needs to do low-level random access of disks (read individual sectors). In Linux I accomplish this by accessing the corresponding block device (e.g. /dev/sda). However, ...
5
votes
2answers
904 views

raid 1/LVM at the level of directories (aka mknodding a directory)

I just experienced data loss, so I am interested in some form of data duplication. I was thinking of mdadm and companions to raid 1 through software. However, I just want a given, not too big ...
4
votes
1answer
3k views

Harddrive with 4096 physical sector size reported as 512 behind USB bridge

I bought a new (in 2017) 4 TB harddrive, so I expected it to have a 4096 physical sector size. Indeed, $ hdparm -I /dev/sdh ... Logical Sector size: 512 bytes Physical Sector ...
3
votes
2answers
368 views

Why does this change render my Block Device unbootable?

I'm working with Amazon Linux in AWS and attempting to setup multiple file systems on a single EBS Volume (block device) for compliance reasons. I'm doing this by mounting an EBS Volume to an already-...
3
votes
1answer
1k views

How to tell if a block device needs cache flushes

I want to know if a particular block device claims to requires cache flushes. From the xfs faq (emphasis mine): Q. Should barriers be enabled with storage which has a persistent write cache? ...
3
votes
1answer
264 views

Find/replace on block device?

Let's say I have an unmounted block device /dev/sda, and I want to replace all instances of MyPassWord with XXXXXXXXXX. (Hopefully my goal is obvious.) What's the easiest way to do this?