Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
Vaardigheden in dit hoofdstuk
- USB-schijven en ISO-bestanden koppelen en ontkoppelen
Understand mounting
A file system becomes visible only when it is mounted on a folder (the mount point). After umount the folder is just an empty folder again.
findmnt /
TARGET SOURCE FSTYPE OPTIONS
/ /dev/mapper/rhel-root xfs rw,relatime,seclabel
df -h
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
vda 252:0 0 20G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 19G 0 part
├─rhel-root 253:0 0 17G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm [SWAP]
sda 8:0 1 14.6G 0 disk
└─sda1 8:1 1 14.6G 0 partThe RM column = 1 means removable. Here sda1 is a USB stick that is not mounted yet.
Find the new device
Plug the device in, then ask the kernel which name it got.
lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINTS
sda
└─sda1 vfat BACKUP 4A3C-1F2E
blkid /dev/sda1
/dev/sda1: LABEL="BACKUP" UUID="4A3C-1F2E" TYPE="vfat" PARTUUID="0e4c1d2a-01"
journalctl -k -n 15
dmesg -w| Name | Usually is |
|---|---|
/dev/sda, /dev/sdb … | USB disks and sticks (also SATA/SAS disks) |
/dev/sda1 | The first partition on that disk |
/dev/sr0 | The DVD / CD drive |
/dev/nvme0n1 | An NVMe SSD |
/dev/vda | A virtual disk in a KVM machine |
Let op
Names like sda can change from boot to boot. Before you write to a disk, check it with lsblk -f (size, label) — writing to the wrong disk destroys data.
Mount by hand on a server
Make a folder, then mount DEVICE FOLDER. mount finds the file system type by itself.
mkdir -p /mnt/usb
mount /dev/sda1 /mnt/usb
ls /mnt/usb
findmnt /mnt/usb
mount -o ro /dev/sda1 /mnt/usb
mount -o uid=1000,gid=1000 /dev/sda1 /mnt/usb
mount LABEL=BACKUP /mnt/usb| Option | Use it when |
|---|---|
-o ro | You only want to read (safe for evidence or old disks) |
-o uid=…,gid=… | A vfat/exfat stick has no Linux owners; give the files to a user |
-t TYPE | mount can not guess the type |
LABEL= / UUID= | Mount by name or ID instead of the changing device name |
Notitie
RHEL can read vfat (FAT32), ext4, xfs and ISO 9660 (CD/DVD) out of the box. NTFS is not part of RHEL.
Mount it in the desktop
In GNOME, a plugged-in stick is mounted for you under /run/media/USER/LABEL. Without root rights, the tool udisksctl does the same on the command line.
udisksctl mount -b /dev/sda1
Mounted /dev/sda1 at /run/media/student/BACKUP
ls /run/media/student/BACKUP
udisksctl unmount -b /dev/sda1
Unmounted /dev/sda1.
udisksctl power-off -b /dev/sdaudisksctl power-off stops the whole stick, so it is safe to pull it out.
Read an ISO file without a DVD
An ISO file is a full DVD image. Mount it with a loop device to read the files inside.
mkdir -p /mnt/iso
mount -o loop,ro rhel-10.0-x86_64-dvd.iso /mnt/iso
ls /mnt/iso
AppStream BaseOS EFI EULA GPL images isolinux media.repo
losetup -l
umount /mnt/isoOp het werk
A RHEL DVD ISO has the BaseOS and AppStream repositories inside. Mounted under /mnt/iso, it can be a local repository for servers without internet: see Use a local repository.
Remove the media safely
Always umount before you pull the stick out. Linux keeps data in memory and writes it later — pulling too early loses data.
sync
umount /mnt/usb
umount /dev/sda1
umount: /mnt/usb: target is busy.
lsof /mnt/usb
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
bash 4321 student cwd DIR 8,1 4096 1 /mnt/usb
fuser -vm /mnt/usb
eject /dev/sr0"target is busy" means a program still uses a file or a shell is in that folder. Find it with lsof or fuser -vm, close it (or cd away), then try again.
Prepare a stick for Linux and Windows
To give files to people with other systems, format a stick with vfat (FAT32). Formatting erases everything on it.