Questions tagged [lsblk]
118 questions
12
votes
3 answers
Can I shorten this filter, that finds disk sizes over 100G?
My goal is to get the disks greater than 100G from lsblk.
I have it working, but it's awkward. I'm pretty sure it can be shortened. Either by using something totally different than lsblk, or maybe I can filter human readable numbers directly with…
chalybeum
- 173
- 1
- 7
11
votes
4 answers
Why does writing random data using dd result in disk partitions?
Prior to running the dd command, the command lsblk returned the output below:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
The command dd if=/dev/urandom of=/dev/sda conv=fsync…
Motivated
- 309
- 3
- 11
7
votes
2 answers
How do I tell which partition I booted from?
Is there a way to know which partition you actually booted from?
fdisk -l reveals a "Boot" column that I definitely don't have on my NVME. Is this just legacy information?
Device Boot Start End Sectors Size Id Type
/dev/sda1 * …
celvro
- 73
- 6
7
votes
2 answers
Make lsblk list devices by-id
I'm constantly having the situation where I want to correlate the output of lsblk which prints devices in a tree with their name in the scheme of /dev/sdXY with the drives /dev/disk/by-id/ names.
Rovanion
- 921
- 1
- 7
- 17
6
votes
4 answers
How to capture all disks that don’t have a file system
I want to capture all disks that do not have a filesystem ( all disks that mkfs not runs on them )
I tried the below, but still gives the OS ( sda ).
What is the best approach with lsblk or other command to capture all disks that are without…
yael
- 12,598
- 51
- 169
- 303
6
votes
1 answer
Why is usb-drive not visible with `lsblk` after having been ejected from Thunar?
If I put a USB-drive in, it will automount. I can see it with lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 1 7,5G 0 disk
└─sdb1 8:17 1 7,5G 0 part /media/user/usb-drive
If I unmount it with umount
umount…
PetaspeedBeaver
- 1,207
- 3
- 15
- 32
5
votes
3 answers
bash + how to compare arg to one of the disks in linux machine
I can capture the disk devices of my Linux machine with the following command:
lsblk -lnb | numfmt --to=iec --field=4 | grep disk | awk '{print $1}'
sda
sdb
sdc
sdd
In my bash script I used the line below to test if the script's argument matches…
yael
- 12,598
- 51
- 169
- 303
5
votes
3 answers
Iterate lines of string variable in bash
I have a script where I want to list USB devices using the command lsblk.
The command:
$ lsblk -o NAME,TRAN,VENDOR,MODEL | grep usb
which results in
sdb usb Kingston DataTraveler 2.0
sdc usb Kingston DT 101 G2
I want to save the result…
schrodingerscatcuriosity
- 12,087
- 3
- 29
- 57
5
votes
4 answers
lsblk + capture only the disks
I want to capture only the disks from lsblk
as showing here fd0 also appears in spite its not really disk for use
in this case we can just do lsblk | grep disk | grep -v fd0
but maybe we missed some other devices that need to filter them by grep…
yael
- 12,598
- 51
- 169
- 303
5
votes
2 answers
Can i list unmounted drives without fdisk or lsblk?
I have an Inteno dg200 Router running some Iopsys linux version (kernel 3.14 or so, I believe)
I've had some trouble getting a fileshare running using the USB ports and my external harddrive. The system supports it. But no matter what I put in, it…
rasmus91
- 352
- 1
- 4
- 9
4
votes
1 answer
Is there a scriptable way to identify the nth partition of a disk?
Suppose I have a disk located at /dev/DISK_NAME. I'm curious if there is a command to find the nth partition of this disk.
It seems like this sort of thing should be possible with lsblk. The best I can come up with is:
lsblk -nlpo NAME,TYPE…
Brian Fitzpatrick
- 2,755
- 3
- 23
- 43
4
votes
1 answer
How to set a disk's (not partition) LABEL?
I've been searching around, and can't find a clear answer, or I find that the answer is 'no' when my system shows me otherwise.
I'm running Arch Linux, and while attaching new HDD into a ZFS pool I noticed that my main SSD system drive has a LABEL…
Lockszmith
- 628
- 5
- 14
4
votes
3 answers
Do all disks devices in my HW machines start with - sd?
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…
yael
- 12,598
- 51
- 169
- 303
4
votes
0 answers
Inaccessible drive with the message: unknown filesystem type '(null)'
Short story:
A disk with partitions sdb1-sdb4 and filetype ext4 now shows up as sdb with no file type. While trying to mount sdb I get the messages:
mount: /dev/sdb is write-protected, mounting read-only
mount: unknown filesystem type '(null)'
I…
Aunt Jemima
- 177
- 1
- 3
- 10
3
votes
1 answer
How does lsblk obtain sector size?
My disk is sda. There is the size file /sys/dev/block/8:0/size. Its unit is sectors. When I run strace lsblk I can see it reading this file.
But how does lsblk get the sector size to later show the total disk size in bytes?
Because I cannot see…
zomega
- 821
- 7
- 19