How to use the command pmount (with examples)
- Linux
- December 25, 2023
pMount is a command-line utility that allows users to mount arbitrary hotpluggable devices as a normal user. This command is especially useful for situations where root access is not available or desirable. With pmount, users can mount devices based on their filesystem type, specify a mount point, and even set the access mode.
Use case 1: Mount a device below /media/
(using device as mount point)
Code:
pmount /dev/to/block/device
Motivation:
This use case is useful when you want to mount a device and use its device name as the mount point. By default, pmount mounts the device under the /media/
directory.
Explanation:
/dev/to/block/device
: represents the device you want to mount. Replaceto/block/device
with the actual device name, such as/dev/sdb1
.
Example output:
The device /dev/sdb1
is mounted under /media/sdb1
.
Use case 2: Mount a device with a specific filesystem type to /media/label
Code:
pmount --type filesystem /dev/to/block/device label
Motivation:
Sometimes, you may want to mount a device with a specific filesystem type to a custom mount point. This use case allows you to specify the filesystem type and the desired mount point.
Explanation:
--type filesystem
: specifies the filesystem type of the device./dev/to/block/device
: represents the device you want to mount. Replaceto/block/device
with the actual device name.label
: represents the label you want to assign to the mounted device.
Example output:
The device /dev/sdb1
with the filesystem type “ext4” is mounted under /media/label
.
Use case 3: Mount a CD-ROM (filesystem type ISO9660) in read-only mode
Code:
pmount --type iso9660 --read-only /dev/cdrom
Motivation:
Mounting a CD-ROM in read-only mode allows you to access the content without making any changes. This can be useful when you want to view the contents or copy files from a CD-ROM.
Explanation:
--type iso9660
: specifies the filesystem type of the CD-ROM as ISO9660.--read-only
: forces the mount in read-only mode./dev/cdrom
: represents the CD-ROM device.
Example output:
The CD-ROM is mounted in read-only mode under /media/cdrom
.
Use case 4: Mount an NTFS-formatted disk, forcing read-write access
Code:
pmount --type ntfs --read-write /dev/sdX
Motivation:
This use case is useful when you want to mount an NTFS-formatted disk with read-write access. It allows you to modify, delete, and add files to the mounted NTFS partition.
Explanation:
--type ntfs
: specifies the filesystem type of the NTFS-formatted disk.--read-write
: forces the mount in read-write mode./dev/sdX
: represents the NTFS disk device. ReplacesdX
with the actual device name, such as/dev/sdc1
.
Example output:
The NTFS-formatted disk is mounted under /media/sdc1
with read-write access.
Use case 5: Display all mounted removable devices
Code:
pmount
Motivation:
When working with various removable devices, it can be helpful to have a way to quickly view all the mounted devices. This use case allows you to display a list of all the currently mounted removable devices.
Explanation:
This command without any arguments displays all mounted removable devices.
Example output:
/dev/sdb1 on /media/sdb1 type ext4 (rw,nosuid,nodev,relatime,adata_cluster)
/dev/sdc1 on /media/sdc1 type ntfs (rw,nosuid,nodev,relatime,uid=1000,gid=1000,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096,uhelper=udisks2)
Conclusion:
The pmount command is a versatile tool for mounting hotpluggable devices as a normal user. It offers various options to mount devices with different filesystem types and access modes. With pmount, users can easily mount devices, view mounted devices, and perform read-only or read-write operations on them without requiring root access.