Almacenamiento
A diferencia de Windows, en Linux no existen letras para diferenciar los diferentes medios de almacenamiento. Simplemente se "montan" sobre diferentes rutas dentro de lo que conocemos como "raiz" o / Las carpetas más comunmente dedicadas a esto suelen ser /media para almacenamientos temporales y removibles y /mnt para montar unidades locales que permanezcan. Sin embargo estas son las mejores prácticas pero tecnicamente se puede montar en cualquier ruta. Los sistemas operativos de escritorios se comportan diferente a los servidores. En estos normalmente las cosas se montan automaticamente en una ruta predefinida. En los servidores se tienen que tomar manualmente todas las decisiones. Existen diferentes comandos para ver los dispositivos de almacenamiento
Comando LSBLK
Si escribimos LSBLK solo, nos muestra los dispostivos de almacenamiento y sus particiones, esten o no en uso dentro del sistema. lsblk Si le agregamos -f se nos mostrarán más detalles que veremos más adelante como tipos de filesystem UUID, espacio, ocupación y punto de montajes lsblk -f
Comando MOUNT
Con el comando MOUNT podremos ver tanto los dispositivos fisicos en uso como los temporales y virtuales mount Si nos fijamos las lineas que empiecen por barra podremos identificar los dispositivos reales. Otra opciones mount | grep ^/
El comando "disk free" o df que si le colocamos -h nos mostrará la ocupación de los diferentes almacenamientos, sus tamaños y puntos de montaje en un lenguaje humano. df -h nuevamente veremos los que inicien en / los dispotivos reales df -h | grep ^/
Tamaño de archivos y carpetas con el comando DU
Si tenemos que saber que carpetas ocupan más dentro de una ruta podemos usar el "disk usage" o du. En este caso también lo podemos usar con el -h y para que nos sume lo que esté dentro le ponemos -s de "summarize". Para simplificar los juntamos y escribimos de la siguiente forma du -hs Sin embargo es más útil agregarle las rutas a definir al final o simplemente agregarle un asterisco al final para que tome todas las carpetas dentro de la ruta en que estemos parados. du -hs * Si no poseemos permisos en la carpeta a veces es necesario correrlo con sudo. Por ejemplo sudo du -hs /usr/*
#############################################################################################################
Temas
Dispositivos de Almacenamiento o de bloques
-Unidades
-Particiones
--Tablas
Distintos de tipos de tablas de particiones
-MBR o DOS : Master Boot Record
ANTIGUO: hasta 4 primarias y luego extendidas y Max 2TB
-GPT : GUID Partition Table
MODERNO: hasta 128 particiones
Distintos ejemplos de dispositivos
/dev/sda /dev/vda /dev/nvme0n1 /dev/mmcblk0
--/dev/sda1 --/dev/vda1 --/dev/nvme0n1p1 --/dev/mmcblk0p1
--/dev/sda2 --/dev/vda2 --/dev/nvme0n1p2 --/dev/mmcblk0p2
/dev/sdb /dev/vdb /dev/nvme0n2 /dev/mmcblk1
--/dev/sdb1 --/dev/vdb1 --/dev/nvme0n2p1 --/dev/mmcblk1p1
--/dev/sdb2 --/dev/vdb2 --/dev/nvme0n2p2 --/dev/mmcblk1p2
UUID Identificador único universal
Distintos ejemplos de File systems (ejemplo biblioteca)
-Linux (ext2 / ext4 / btrfs / xfs / swap)
-Windows (ntfs / fat16 / fat32 / exFAT)
-Mac (HFS / APFS)
Diferencia entre montajes y letras de unidades
- A: B: C:
- /
¿Qué es área de intercambio o Archivo de paginación?
-Sistemas operativos multipropósito
-Manejo de procesos
--CPU
--Memoria
--Paginado
NAME
lsblk - list block devices
SYNOPSIS
lsblk [options] [device...]
DESCRIPTION
lsblk lists information about all available or the specified block devices. The lsblk
command reads the sysfs filesystem and udev db to gather information. If the udev db is not
available or lsblk is compiled without udev support, then it tries to read LABELs, UUIDs
and filesystem types from the block device. In this case root permissions are necessary.
The command prints all block devices (except RAM disks) in a tree-like format by default.
Use lsblk --help to get a list of all available columns.
The default output, as well as the default output from options like --fs and --topology, is
subject to change. So whenever possible, you should avoid using default outputs in your
scripts. Always explicitly define expected columns by using --output columns-list and
--list in environments where a stable output is required.
Note that lsblk might be executed in time when udev does not have all information about
recently added or modified devices yet. In this case it is recommended to use udevadm
settle before lsblk to synchronize with udev.
The relationship between block devices and filesystems is not always one-to-one. The
filesystem may use more block devices, or the same filesystem may be accessible by more
paths. This is the reason why lsblk provides MOUNTPOINT and MOUNTPOINTS (pl.) columns. The
column MOUNTPOINT displays only one mount point (usually the last mounted instance of the
filesystem), and the column MOUNTPOINTS displays by multi-line cell all mount points
associated with the device.
...
...
-f, --fs
Output info about filesystems. This option is equivalent to -o
NAME,FSTYPE,FSVER,LABEL,UUID,FSAVAIL,FSUSE%,MOUNTPOINTS. The authoritative information
about filesystems and raids is provided by the blkid(8) command.
...
...
NAME
df - report file system disk space usage
SYNOPSIS
df [OPTION]... [FILE]...
DESCRIPTION
This manual page documents the GNU version of df. df displays the amount of disk space
available on the file system containing each file name argument. If no file name is given,
the space available on all currently mounted file systems is shown. Disk space is shown in
1K blocks by default, unless the environment variable POSIXLY_CORRECT is set, in which case
512-byte blocks are used.
If an argument is the absolute file name of a disk device node containing a mounted file
system, df shows the space available on that file system rather than on the file system
containing the device node. This version of df cannot show the space available on un‐
mounted file systems, because on most kinds of systems doing so requires very nonportable
intimate knowledge of file system structures.
...
...
-h, --human-readable
print sizes in powers of 1024 (e.g., 1023M)
...
...
FDISK(8) System Administration FDISK(8)
NAME
fdisk - manipulate disk partition table
SYNOPSIS
fdisk [options] device
fdisk -l [device...]
DESCRIPTION
fdisk is a dialog-driven program for creation and manipulation of partition tables. It
understands GPT, MBR, Sun, SGI and BSD partition tables.
Block devices can be divided into one or more logical disks called partitions. This
division is recorded in the partition table, usually found in sector 0 of the disk. (In
the BSD world one talks about `disk slices' and a `disklabel'.)
All partitioning is driven by device I/O limits (the topology) by default. fdisk is able
to optimize the disk layout for a 4K-sector size and use an alignment offset on modern
devices for MBR and GPT. It is always a good idea to follow fdisk's defaults as the
default values (e.g., first and last partition sectors) and partition sizes specified by
the +/-<size>{M,G,...} notation are always aligned according to the device properties.
CHS (Cylinder-Head-Sector) addressing is deprecated and not used by default. Please, do
not follow old articles and recommendations with fdisk -S <n> -H <n> advices for SSD or
4K-sector devices.
Note that partx(8) provides a rich interface for scripts to print disk layouts, fdisk is
mostly designed for humans. Backward compatibility in the output of fdisk is not
guaranteed. The input (the commands) should always be backward compatible.
...
...
-l, --list
List the partition tables for the specified devices and then exit.
If no devices are given, the devices mentioned in /proc/partitions (if this file
exists) are used. Devices are always listed in the order in which they are specified
on the command-line, or by the kernel listed in /proc/partitions.
...
...
jgalvez@debian:~$ lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sr0
vda
├─vda1 ext4 1.0 8a702aaf-62ba-4240-b5c4-5b87b350a789 16,6G 5% /
├─vda2
└─vda5 swap 1 60c968c6-3e40-4f6e-b7db-bccba108c834 [SWAP]
jgalvez@debian:~$ sudo fdisk -l
Disco /dev/vda: 20 GiB, 21474836480 bytes, 41943040 sectores
Unidades: sectores de 1 * 512 = 512 bytes
Tamaño de sector (lógico/físico): 512 bytes / 512 bytes
Tamaño de E/S (mínimo/óptimo): 512 bytes / 512 bytes
Tipo de etiqueta de disco: dos
Identificador del disco: 0x8e9d9509
Disposit. Inicio Comienzo Final Sectores Tamaño Id Tipo
/dev/vda1 * 2048 39942143 39940096 19G 83 Linux
/dev/vda2 39944190 41940991 1996802 975M f W95 Ext'd (LBA)
/dev/vda5 39944192 41940991 1996800 975M 82 Linux swap / Solaris
jgalvez@debian:~$ df -h
S.ficheros Tamaño Usados Disp Uso% Montado en
udev 461M 0 461M 0% /dev
tmpfs 97M 644K 97M 1% /run
/dev/vda1 19G 1,1G 17G 6% /
tmpfs 484M 0 484M 0% /dev/shm
tmpfs 5,0M 0 5,0M 0% /run/lock
tmpfs 1,0M 0 1,0M 0% /run/credentials/systemd-journald.service
tmpfs 1,0M 0 1,0M 0% /run/credentials/systemd-udev-load-credentials.service
tmpfs 1,0M 0 1,0M 0% /run/credentials/systemd-tmpfiles-setup-dev-early.service
tmpfs 1,0M 0 1,0M 0% /run/credentials/systemd-sysctl.service
tmpfs 1,0M 0 1,0M 0% /run/credentials/systemd-tmpfiles-setup-dev.service
tmpfs 484M 0 484M 0% /tmp
tmpfs 1,0M 0 1,0M 0% /run/credentials/systemd-tmpfiles-setup.service
tmpfs 1,0M 0 1,0M 0% /run/credentials/getty@tty1.service
tmpfs 97M 8,0K 97M 1% /run/user/1000
jgalvez@debian:~$
##################################################################################################################
jgalvez@ubuntu:~$ lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sr0 iso9660 Joliet Ubuntu-Server 24.04 LTS amd64 2024-04-23-12-46-09-00
vda
├─vda1
├─vda2 ext4 1.0 0216824a-0785-410e-89c5-d1dc264f8933 1.5G 5% /boot
└─vda3 LVM2_mem LVM2 00 SDaeX7-rirX-tpPP-MyDJ-SMMX-VJ8z-9q9dZR
└─ubuntu--vg-ubuntu--lv
ext4 1.0 18199f91-f1b7-4fc7-9ad4-4ae3dc2f1a13 5.1G 43% /
jgalvez@ubuntu:~$ sudo fdisk -l
Disk /dev/vda: 16 GiB, 17179869184 bytes, 33554432 sectors
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: 355084F4-0BFA-49B4-86EB-D5147CBE9D23
Device Start End Sectors Size Type
/dev/vda1 2048 4095 2048 1M BIOS boot
/dev/vda2 4096 3674111 3670016 1.8G Linux filesystem
/dev/vda3 3674112 33552383 29878272 14.2G Linux filesystem
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 10 GiB, 10737418240 bytes, 20971520 sector
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
jgalvez@ubuntu:~$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 197M 1.2M 196M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 9.8G 4.2G 5.1G 46% /
tmpfs 984M 0 984M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/vda2 1.7G 95M 1.5G 6% /boot
tmpfs 197M 12K 197M 1% /run/user/1000
jgalvez@ubuntu:~$
jgalvez@opensuse:~> lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sr0
vda
├─vda1
├─vda2 btrfs 40306143-7493-49af-9e8c-37558660dfc5 16G 12% /usr/local
│ /var
│ /srv
│ /root
│ /opt
│ /home
│ /boot/grub2/x86_64-efi
│ /boot/grub2/i386-pc
│ /.snapshots
│ /
└─vda3 swap 1 cf4fc72e-314e-48b7-ab7b-57d1955e3630 [SWAP]
jgalvez@opensuse:~> sudo fdisk -l
Disco /dev/vda: 20 GiB, 21474836480 bytes, 41943040 sectores
Unidades: sectores de 1 * 512 = 512 bytes
Tamaño de sector (lógico/físico): 512 bytes / 512 bytes
Tamaño de E/S (mínimo/óptimo): 512 bytes / 512 bytes
Tipo de etiqueta de disco: gpt
Identificador del disco: C39693D0-2CEB-4019-8B12-FE7B7043EF08
Disposit. Comienzo Final Sectores Tamaño Tipo
/dev/vda1 2048 18431 16384 8M Arranque de BIOS
/dev/vda2 18432 39065599 39047168 18,6G Sistema de ficheros de Linux
/dev/vda3 39065600 41943006 2877407 1,4G Linux swap
jgalvez@opensuse:~> df -h
S.ficheros Tamaño Usados Disp Uso% Montado en
/dev/vda2 19G 2,3G 16G 13% /
devtmpfs 4,0M 0 4,0M 0% /dev
tmpfs 987M 0 987M 0% /dev/shm
tmpfs 395M 808K 394M 1% /run
/dev/vda2 19G 2,3G 16G 13% /.snapshots
/dev/vda2 19G 2,3G 16G 13% /boot/grub2/i386-pc
/dev/vda2 19G 2,3G 16G 13% /boot/grub2/x86_64-efi
/dev/vda2 19G 2,3G 16G 13% /home
/dev/vda2 19G 2,3G 16G 13% /opt
/dev/vda2 19G 2,3G 16G 13% /root
/dev/vda2 19G 2,3G 16G 13% /srv
/dev/vda2 19G 2,3G 16G 13% /var
/dev/vda2 19G 2,3G 16G 13% /usr/local
tmpfs 987M 0 987M 0% /tmp
tmpfs 198M 4,0K 198M 1% /run/user/1000
jgalvez@opensuse:~>
jgalvez@fedora:~$ lsblk -f NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS sr0 zram0 [SWAP] vda ├─vda1 ├─vda2 xfs d4ddc871-3ee4-4db1-aa8f-21cd0fbdf739 679,8M 29% /boot └─vda3 LVM2_member LVM2 001 jssacm-7R9X-dud9-y2Ad-7KHk-I7ec-z0VjhY └─fedora-root xfs bee39ba3-b445-4e6d-9471-4ded342e2547 13G 13% / jgalvez@fedora:~$ sudo fdisk -l Disk /dev/vda: 20 GiB, 21474836480 bytes, 41943040 sectors 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: 5089F24D-CBA1-4396-9C91-7D216D327966 Device Start End Sectors Size Type /dev/vda1 2048 4095 2048 1M BIOS boot /dev/vda2 4096 2101247 2097152 1G Linux extended boot /dev/vda3 2101248 41940991 39839744 19G Linux LVM Disk /dev/mapper/fedora-root: 15 GiB, 16106127360 bytes, 31457280 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/zram0: 1,91 GiB, 2055208960 bytes, 501760 sectors Units: sectors of 1 * 4096 = 4096 bytes Sector size (logical/physical): 4096 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes jgalvez@fedora:~$ df -h S.ficheros Tamaño Usados Disp Uso% Montado en /dev/mapper/fedora-root 15G 2,0G 14G 13% / devtmpfs 4,0M 0 4,0M 0% /dev tmpfs 981M 0 981M 0% /dev/shm tmpfs 393M 1,1M 392M 1% /run tmpfs 981M 0 981M 0% /tmp /dev/vda2 960M 281M 680M 30% /boot tmpfs 197M 4,0K 197M 1% /run/user/1000 jgalvez@fedora:~$