18

There are many questions on automatically mounting or problems encountered during mounting that I've read here. But none on how to manually mount a partition.

26

The first step is to list all your partitions to find the one you want to mount:

$ lsblk -o NAME,FSTYPE,LABEL,SIZE,MOUNTPOINT
NAME        FSTYPE  LABEL                    SIZE MOUNTPOINT
sdb                                         14.4G 
├─sdb4      iso9660 Ubuntu 18.04 LTS amd64   1.4G /media/rick/Ubuntu 18.04 LTS amd64
├─sdb2                                         1M 
├─sdb5      ext4    casper-rw                6.4G /media/rick/casper-rw
├─sdb3      vfat    usbboot                  244M 
└─sdb1      ntfs    usbdata                  6.4G /media/rick/usbdata
sr0                                         1024M 
sda                                        931.5G 
├─sda4      ntfs    WINRETOOLS               450M 
├─sda2                                       128M 
├─sda5      ntfs    Image                   11.4G 
├─sda3      ntfs    HGST_Win10               919G /mnt/d
└─sda1      vfat    ESP                      500M 
nvme0n1                                      477G 
├─nvme0n1p5 ext4    NVMe_Ubuntu_16.0        44.6G /
├─nvme0n1p3                                   16M 
├─nvme0n1p1 ntfs                             450M 
├─nvme0n1p8 ext4    Ubuntu18.04             23.7G 
├─nvme0n1p6 swap    Linux Swap               7.9G [SWAP]
├─nvme0n1p4 ntfs    NVMe_Win10             391.2G /mnt/c
├─nvme0n1p2 vfat                              99M /boot/efi
└─nvme0n1p7 ntfs    Shared_WSL+Linux           9G /mnt/e

For this example, we will mount nvme0n1p8 which has the label Ubuntu18.04. To credit sources, we'll be following this article as a guide.

Create mount point directory

The next step is to create a directory under /mnt that the newly mounted partition will be referred to as:

sudo mkdir /mnt/Ubuntu18.04

Mount the partition to the new directory

The final step is to mount the partition to the new directory:

$ sudo mount -t auto -v /dev/nvme0n1p8 /mnt/Ubuntu18.04
/dev/nvme0n1p8 mounted on /mnt/Ubuntu18.04.

Notice we prepend /dev/ to the names provided by lsblk above.

Now let's see what we've just mounted:

$ ll /mnt/Ubuntu18.04
total 24
drwxr-xr-x 3 root root  4096 Apr 26 17:00 ./
drwxr-xr-x 6 root root  4096 Apr 27 20:51 ../
drwx------ 2 root root 16384 Apr 26 17:00 lost+found/

lost_found is needed for fschk command (File System check). It is automatically created and normally we don't have to "fiddle" with it.

Unmount the partition

When we are finished we can unmount the partition using the -l parameter which safely unmounts the partition:

$ sudo umount /dev/nvme0n1p8 -l

Script method

A script to mount partition is available in this answer:

This screen appears tailored to your unique machine environment:

mount-menu 1.png

0

mount /dev/sda1 /mnt

would be enough in most cases. -t auto is used as default here which uses heuristics to find the filesystem type:

If no -t option is given, or if the auto type is specified, mount will try to guess the desired type. (Source)

If you work with sensitive data specifiy the filesystem type rather explicitely:

Warning: the probing uses a heuristic (the presence of appropriate 'magic'), and could recognize the wrong filesystem type, possibly with catastrophic consequences. If your data is valuable, don't ask mount to guess. (Source)

mount -t ext4 /dev/sda1 /mnt
  • Does this mean -t auto is the same as it being omitted? The verbose part makes sense. – WinEunuuchs2Unix Jun 16 '20 at 1:26
  • @WinEunuuchs2Unix yes, exactly! Edited my answer to make that more clear. Also, added a warning from the man page. – Willi Mentzel Jun 16 '20 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.