Archives For November 30, 1999

This is a beginners guide shows how to decrease, move, and/or increase file/system partition in Ubuntu 24.04 LTS.

Sometimes you need to shrink a partition to free up some un-allocated disk space for other use. Or Ubuntu system is a bit small, that you need to increase its size for long time use.

In my case, I want to shrink the Ubuntu 22.04 partition to free up some space, then use the free space to increase the dual-boot Ubuntu 24.04 partition that’s a bit small for me. There’s another partition (contains personal data) sits in between the 2 Ubuntu system, so I also need to move it before being able to expand the 24.04 system.

Continue Reading…

This tutorial shows how to automatically mount external disk partitions on startup of Ubuntu, Fedora, Debian, and most other Linux.

I bought a new SSD recently. Now, I have 2 solid-state drives (SSDs) connected on my computer. Ubuntu 22.04 is installed on one SSD drive, while another one contains VirtualBox Virtual Machine files.

As result, I have to click open the external SSD partition in file manager every time on startup to mount it. So the files on that SSD are accessible via mount point (usually “/media/username/xxx“). Or, all virtual machines in VirtualBox will be marked as “Inaccessible”.

To make life easier, it’s possible to auto-mount the external file partition. So user doesn’t have to make one more mouse click in file manager every time on startup. And, here’s what I did in Ubuntu 22.04.


UPDATE: For most desktop Linux, there’s an easier way to auto-mount disk driver or partitions on startup. See this tutorial for details.


Step 1: Get Device Name or ID of External Disk Partition

First, search for and open the “Disks” tool from system app launcher.

Launch Disk

When it opens, select the disk in left pane, and highlight the desired file partition in right. There, copy or write down the Device name (usually /dev/xxx), and UUID.

In my case, I need to get the info about:

  • UUID: 428E68968EE68846F
  • Device name: /dev/nvme0n1p2
  • file system type: NTFS (optional)

In case, your Linux Distro does not have “Disks” utility or you’re running a Linux server. Open terminal and run command:

df -h

Then find out the disk partition name you want to auto-mount on startup. (NOTE: You need to mount the external disk first).

Step 2: Get the user/group ID for current user

To auto-mount the external partition by using current user ownership, you also need to get the user ID and group ID.

For the default user that created while installing Linux, the ID is usually 1000. Just in case, open terminal and run command to get it:


get user id

Step 3: Enable Auto-Mount Disk Partition via /etc/fstab

Now, you can edit the “/etc/fstab” file to do the auto-mount configuration that works in most Linux!

To do so, open terminal and run command:

sudo gedit /etc/fstab

For Ubuntu 22.10+ and Fedora workstation, replace gedit with gnome-text-editor. For other Linux, either use your system text editor or nano that works in most Linux.

When the file opens, add the new line in the bottom:

UUID_or_Device_Name  Mount_Point  File_system_type  Options  0  0

In my case, I can use:

/dev/nvme0n1p2 /media/ji/sandisk  ntfs  defaults,uid=1000,gid=1000,umask=022  0  0

There are 6 parts in the new line separated with spaces. They are:

  • Part 1: the device name or UUID. See yours via Step 1.
  • Part 2: the mount point to access the external disk files. If you’ve associated your apps with the external disk files, it’s better to use the previous mount point (See screenshot in Step1).
  • Part 3: the file system type of disk partition (e.g., ext4, fat, ntfs). Get it in step 1, or use “auto” to auto-detect.
  • Part 4: mount options separated with commas but NO space between them. Here I use:
    • defaults – means rw (read & write), auto (auto mount), exec, dev, etc. Run man mount to see more about it.
    • uid – specify the owner.
    • gid – specify the group
    • umask – specify the permissions. The first 0 means read, write and execute permission for user, and the two number 2 mean read and execute permission for group/others.
  • Part 5: Either to backup. Set 0 to not backup.
  • Part 6: Either to check and repair file system. 0 for No.

When done, save the file. For nano text editor, press Ctrl+X, type y and hit Enter to save it. And, the change will apply in next boot.

In addition

The uid=1000,gid=1000,umask=022 section specify the ownership and permissions, but it only works for non-Linux file systems, such as NTFS, FAT, etc, disk partitions.

If you’re going to auto-mount external partition with Linux file-system, such as Ext2/3/4, XFS, JFS, try to change the ownership manually after mount.