PopOS

How to Mount a Device on Pop!_OS

After formatting or partitioning a disk, mount a drive on your operating system. When external devices are connected in Windows, they are automatically mounted, which does not happen in Linux. The system automatically mounts and creates a username with a directory.

Sometimes, you may have to manually connect the device to access it in the system. Here, the drives are mounted on it through the mount points on the virtual file system. It allows the Linux users to navigate the file system and create and delete the files. In this guide, we will guide you on how to mount a device on Pop!_OS using different approaches.

How to Mount a Device on Pop!_OS

Here, we will use the various tools and approaches to mount a device on Pop!_OS including GUI and terminal.

The GUI Approach

You can mount the device through the GUI methods. Here are a few approaches that you can try:

Approach 1:

  • First, open the file manager to mount a device.
  • From the side pane, navigate to the device by clicking the other location.
  • Click on the device that you want to mount and click on the mount.
  • This way, you can mount your device by following these simple steps.
  • To unmount the device using this method, right-click on it and click on Unmount.

Approach 2:

  • Go to the Applications menu and search for the “Disks” application in the search box.
  • As soon as you see its icon, open it by double-clicking it. When you open the app, you will see that the connected devices’ status is “Not Mounted”.
  • To mount the device, click on the play button. It automatically attaches your USB device by creating a mount point.
  • Once you click the play button, you will see a drive icon. Clicking on this icon directly opens your mounted device in the file manager. From here, you will be able to see all the data information of the device.
  • Similarly, you can unmount the device on Pop!_OS by clicking the play button again.

Note: When the device size is less than 2GB or the operating system has the same format as the device, you can easily mount the drive through the GUI method.

The CLI Approach

You can’t mount the devices which are larger than 2GB with the GUI method on Pop!_OS since the device needs to be partitioned and formatted if the device size is large. For this, we have to use the command line only.

Mounting the devices via the CLI allows you to have more control over the state of the filesystem that they are mounted on. Follow the following steps to mount the device on Pop!_OS via the CLI method.

Detecting the USB Drive: To detect the attached device in your system, run any of the following commands:

Lsblk

lsblk -f

sudo fdisk -l

Upon running the provided commands, you can see all the entries which are labeled as “loop”. However, the objective is to find a result that identifies the physical disk that is attached to the system as sdb or sda. You can easily find the drive’s name by comparing it to the listed capacity of the attached drive.

Creating a Partition: You must partition the drive for an external device. So, create a mount point and format the partition. To partition the device, use the “parted” command:

sudo parted /dev/sdb

The previous command sets up the terminal in the partitioned environment. You must allow a large partition size if the same partition is more than 2 GB. For this, run the following command in the terminal:

mklabel gpt

Set the partition by running the following command:

mkpart primary 0GB 4GB

You can set the partitioned environment to any value that you want. Here, we set the partition to 0-4GB. Now, exit the partitioned environment by running the following command:

quit

Formatting the Partition: Format the partition with the same file format as the system, i.e. ext4, by running the following command:

sudo mkfs.ext4 /dev/sdb

Creating a Mount Point (Directory) to Mount the USB Drive: When an external drive is automatically mounted, it is often mounted inside the media directory by default. The CLI method is helpful since you can create and specify the directory where you want to mount the USB drive.

Here, we use the following “mkdir” command to create a mount point:

sudo mkdir /media/pendrive

Mount the USB Drive to the Created Directory: Use the following “mount” command to mount the drive in the previously-created directory:

man mount

If your device system has a FAT32 or FAT16 file system, execute the following command:

sudo mount <device> <dir>

sudo mount /dev/sdb1 /media/pendrive

If there is a file system other than FAT32 or FAT16, such as ntfs-3g, specify the file system using the following command:

sudo mount -t ntfs-3g /dev/sdb /media/pendrive

Note: This method is for newer devices that require formatting and partitioning. Once formatted and partitioned, you can skip this process to connect to the external devices. You have to directly mount the USB using the “mount” command.

Check the Mounted Drive: The system mounts the device in the directory as soon as you run the previous command. You can check whether your device is mounted or not by running the following command:

lsblk

The last column of the previous command’s output tells the mount point of the listed devices. If your output lists a mount point, the device is mounted.

You can also find the mounted devices by piping the grep command with the mount command.

sudo mount | grep sdb

Here, “sdb” is the disk name for the drive.

Bonus Tip: You can view the contents of the mounted device, but change the current directory in the created mount point. First, go to the directory from which you can access your device. Use the following command for it:

cd /media/sdb

ls –l

How to Permanently Mount a Device on Pop!_OS

The system will have the mounted device until you reboot it. Hence, edit the file which is located at /etc/fstab to permanently mount the device.

The “fstab” file is one of the important files in the filesystem as it stores static information about mount points, filesystems, and many other configuration options. On Pop!_OS, you can list the permanently mounted partitions using the “cat” command on the fstab file which is located in /etc. Use the following command:

cat /etc/fstab

Now, get the partition associated with UUID using the “blkid” command as follows:

blkid | grep <UUID>

The UUID of the partition has to be obtained to add the device to the fstab file. For this, use the “blkid” command with the name of the partition to be mounted as follows:

blkid /dev/sda1

You can now add it to the fstab file once you get the UUID for the device partition. Open the /etc/fstab file and run the following command to partition the new drive:

sudo nano /etc/fstab

This way, you can permanently connect your device to Pop!_OS.

Finally, add the following details to the file:

Path of the device /dev/sdb
Mount point (where the device is mounted) /mnt/sdb
Partition format of the device ext4

Now, your device is automatically mounted back after the system restart. For different file formats, you must change the drive’s partition format.

How to Unmount the Device on Pop!_OS

After unmounting the device, you can use it on another system. You can unmount the devices via the “umount” command in the terminal. This command safely removes the device.

To unmount a device on Pop!_OS, you have to specify the name of the device to be unmounted and the mount point location with the umount command.

sudo umount /media/pendrive

sudo umount -l /dev/sdb

If the device is busy, you must use the -I parameter with the umount command. As soon as the device finishes its work, it unmounts the device.

Conclusion

This guide explains the methods to mount the devices on the Pop!_OS distro. If your device size is more than 2GB, you cannot mount the device through the GUI method. You must use the command line.

Mounting a large device via the command line must be partitioned and mounted, but the device remains mounted until the system is rebooted. You can permanently mount a device by modifying the fstab file.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.