Mounting Techniques
Manual Mounting Methods
Using mount Command
The most common method for mounting virtual disks in Linux involves the mount
command:
## Basic mount syntax
mount [options] device_path mount_point
## Example: Mounting a raw disk image
mkdir /mnt/virtual-disk
mount /path/to/virtual-disk.img /mnt/virtual-disk
Permanent Mounting with /etc/fstab
For persistent mounts across system reboots, use /etc/fstab
:
## /etc/fstab entry format
/path/to/virtual-disk.img /mnt/virtual-disk ext4 defaults 0 0
Mounting Techniques Workflow
graph TD
A[Select Disk Image] --> B[Prepare Mount Point]
B --> C{Filesystem Type?}
C -->|ext4| D[Mount with ext4 Options]
C -->|ntfs| E[Mount with NTFS Support]
C -->|fat| F[Mount with FAT Options]
Mounting Options
Option |
Description |
Example |
-t |
Specify filesystem type |
mount -t ext4 |
-o ro |
Mount read-only |
mount -o ro /dev/disk |
-o loop |
Mount disk image |
mount -o loop disk.img |
Advanced Mounting Techniques
Loopback Mounting
Loopback mounting allows treating files as block devices:
## Loopback mount a disk image
losetup /dev/loop0 /path/to/disk.img
mount /dev/loop0 /mnt/virtual-disk
Automounting with systemd
Create systemd mount units for automatic mounting:
## Example systemd mount unit
[Unit]
Description=Virtual Disk Mount
[Mount]
What=/path/to/virtual-disk.img
Where=/mnt/virtual-disk
Type=ext4
Options=loop
[Install]
WantedBy=multi-user.target
Unmounting Techniques
## Unmount a mounted disk
umount /mnt/virtual-disk
## Force unmount if busy
umount -l /mnt/virtual-disk
LabEx recommends practicing these mounting techniques to enhance Linux storage management skills.