Obtendo Informações Sobre Dispositivos - Linux
Comando mount
O comando mount
/etc/mtab
mount
/etc/mtab
programicio@Programicio:~$ mount sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) udev on /dev type devtmpfs (rw,nosuid,relatime,size=32753672k,nr_inodes=8188418,mode=755,inode64) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000) tmpfs on /run type tmpfs (rw,nosuid,nodev,noexec,relatime,size=6557060k,mode=755,inode64) /dev/nvme2n1p2 on / type ext4 (rw,relatime) /dev/nvme2n1p1 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro) securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,inode64) tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k,inode64) /dev/sda1 on /media/programicio/SP PHD U3 type ntfs3 (rw,nosuid,nodev,relatime,uid=1000,gid=1000,iocharset=utf8,uhelper=udisks2)
Como podemos ver, o comando mount
/dev/sda1
/dev/sda1 on /media/programicio/SP PHD U3 type ntfs3 (rw,nosuid,nodev,relatime,uid=1000,gid=1000,iocharset=utf8,uhelper=udisks2)
Dispositivos com nome no formato /dev/sdX
/dev/sda1
/media/programicio/SP PHD U3
rw
Além do arquivo /etc/mtab
/proc/mounts
/etc/mtabs
df -h
programicio@Programicio:~$ df -h Filesystem Size Used Avail Use% Mounted on tmpfs 6.3G 2.5M 6.3G 1% /run /dev/nvme2n1p2 937G 49G 841G 6% / tmpfs 32G 57M 32G 1% /dev/shm tmpfs 5.0M 16K 5.0M 1% /run/lock efivarfs 192K 162K 26K 87% /sys/firmware/efi/efivars /dev/nvme2n1p1 1.1G 6.1M 1.1G 1% /boot/efi tmpfs 6.3G 112K 6.3G 1% /run/user/1000 /dev/sda1 932G 275G 657G 30% /media/programicio/SP PHD U3
Comando lsblk
O comando lsblk
programicio@Programicio:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS nvme1n1 259:0 0 953.9G 0 disk ├─nvme1n1p1 259:1 0 1G 0 part /boot/efi └─nvme1n1p2 259:2 0 952.8G 0 part / nvme0n1 259:3 0 931.5G 0 disk ├─nvme0n1p1 259:5 0 100M 0 part ├─nvme0n1p2 259:6 0 16M 0 part ├─nvme0n1p3 259:7 0 930.6G 0 part /media/programicio/windows └─nvme0n1p4 259:8 0 773M 0 part nvme2n1 259:4 0 953.9G 0 disk
Partições de Disco
Os principais elementos de um disco rígido/SSD são as partições, que representam seções do disco. A lista de todas as partições em discos é armazenada no arquivo /proc/partitions
programicio@Programicio:~$ cat /proc/partitions major minor #blocks name 259 0 1000204632 nvme1n1 259 1 1100800 nvme1n1p1 259 2 999101440 nvme1n1p2 259 3 976762584 nvme0n1 259 5 102400 nvme0n1p1 259 6 16384 nvme0n1p2 259 7 975849472 nvme0n1p3 259 8 791552 nvme0n1p4 259 4 1000204632 nvme2n1 259 9 1000202240 nvme2n1p1
Para gerenciar discos e partições, utilizamos várias ferramentas, como fdisk
gdisk
programicio@Programicio:~$ sudo fdisk -l /dev/nvme1n1 Disk /dev/nvme1n1: 953.87 GiB, 1024209543168 bytes, 2000409264 sectors Disk model: SPCC M.2 PCIe SSD Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 63F9BAB9-B5B4-45BF-8C12-710E43B7DE90 Device Start End Sectors Size Type /dev/nvme1n1p1 2048 2203647 2201600 1G EFI System /dev/nvme1n1p2 2203648 2000406527 1998202880 952.8G Linux filesystem
No meu caso, o disco é chamado /dev/nvme1n1
/dev/nvme1n1p1
/dev/nvme1n1p2
Podemos obter informações semelhantes com a ferramenta gdisk
programicio@Programicio:~$ sudo gdisk -l /dev/nvme1n1 GPT fdisk (gdisk) version 1.0.9 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Disk /dev/nvme1n1: 2000409264 sectors, 953.9 GiB Model: SPCC M.2 PCIe SSD Sector size (logical/physical): 512/512 bytes Disk identifier (GUID): 63F9BAB9-B5B4-45BF-8C12-710E43B7DE90 Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 2048, last usable sector is 2000409230 Partitions will be aligned on 2048-sector boundaries Total free space is 2703 sectors (1.3 MiB) Number Start (sector) End (sector) Size Code Name 1 2048 2203647 1.0 GiB EF00 2 2203648 2000406527 952.8 GiB 8300