65

I am using Ubuntu Minimal + LXDE. I am wondering how can I auto-mount a partition (internal) on boot automatically. Currently I do something like

mount /dev/sda3 /media/works

But I want it to be permanent. Also I have GParted, but the Partition > UnMount is greyed out (yes, unmount, even though I haven't mounted it)

karel
  • 122,292
  • 133
  • 301
  • 332
Jiew Meng
  • 10,677

4 Answers4

67

Unmount is greyed out because the partition isn't there to be unmounted. You haven't mounted it yet.

To make the partition auto-mount, first find out the UUID of /dev/sda3 by doing:

sudo blkid

I'll assume you're using ext4 on /dev/sda3. Open up gedit like so:

sudo -H gedit /etc/fstab

(Or, in the command line, sudo vim or sudo nano instead of gksudo gedit.)

Now you want to add a line to the bottom of that file. It should look something like this (UUID will be different):

UUID=03ec5dd3-45c0-4f95-a363-61ff321a09ff /media/works ext4 defaults  0      2

For more info on fstab, this is a good resource.

karel
  • 122,292
  • 133
  • 301
  • 332
boehj
  • 2,091
34

Use Disks utility. Select the disk, then click Additional partition options icon. Choose Edit Mount Options from drop-down menu.

BHP
  • 463
5

I'm using Ubuntu Server and I made the permanent mount as follows with a disk already formatted in ext4.

I have listed my disks and partitions with

sudo fdisk -l

After that, I listed the UUID of the partition I would like to mount permanently with the following command:

sudo blkid /dev/sda2

To mount the partition I created a target location with

sudo mkdir -p /home/files

then I wrote

sudo mount /dev/sda2 /home/files

Now we need to find out the name of the new device that has to be permanently mounted. First in the Ubuntu Disk Utility look after the partition, right click on it and under "Device" note down the name e.g "/dev/sda2" or /dev/nvme0n1p2 and the UUID, to make sure you have the right device. Or use the terminal with "sudo blkid" if you don´t have a GUI.

Then back in terminal get the PARTUUID of the device, because this is needed later in fstab.

sudo blkid /dev/sda2

/dev/sda2: LABEL="something" UUID="SOME-THING" BLOCK_SIZE="512" TYPE="exfat" PTTYPE="dos" PARTLABEL="something" PARTUUID="6d81205-fc60-44ce-9da2-3565aa"

Note the PARTUUID that is shown.

We need to put the mounted partition in the /etc/fstab file Don't forget to make a backup first. run

sudo cp /etc/fstab /etc/fstab.bkp

To avoid breaking the file system you need to look at the structure that is already in /etc/fstab for the disks that are already auto-mounted. In my case it is like this

sudo cat /etc/fstab

/ was on /dev/sdb3 during curtin installation

device dir type options dump fsck

/dev/disk/by-uuid/866f0e5d-e590-450c-beff-507620a4afbd / ext4 defaults 0 1

On the site Arch Linux Wiki it is presented what this structure means. Below is an excerpt:

  • <device> describes the block special device or remote file system to be mounted; see #Identifying file systems.
  • <dir> describes the mount directory.
  • <type> the file system type.
  • <options> the associated mount options; see mount(8) §FILESYSTEM-INDEPENDENT_MOUNT_OPTIONS and ext4(5) §MOUNT_OPTIONS.
  • <dump> is checked by the dump(8) utility. This field is usually set to 0, which disables the check.
  • <fsck> sets the order for file system checks at boot time; see fsck(8). For the root device it should be 1. For other partitions it should be 2, or 0 to disable checking.

Edit the /fstab file with

sudo vim /etc/fstab

or

sudo nano /etc/fstab

In the file I added the following line

/dev/disk/by-uuid/6d81205-fc60-44ce-9da2-3565aa /home/files ext4 defaults 0 2

Save the file at the end

You can test by restarting the machine

David DE
  • 2,316
0

For Booting time mount. you have to provide only auto option. It will work , provide mount id, mount place in your folder, file type, auto, 0, 1.

zwcloud
  • 103