Moving Data to another partition

I am fairly new to Ubuntu and don't quite understand all of the partitions and what they do. When I set up Ubuntu, I thought I was setting it up so that all of my files, picture, downloads, and others would go to a 60gb partition. I got a message today saying that i was running out of space on by root partition. Evidently nothing is going to the 60gb partition. I am on a dual boot system. I would love to have everything that is every downloaded or saved from a word processor, picture too, to go to the 60gb partition. Do I need to completely re-install Mate? Can I move some things?
I have attached screen shots of gparted windows.

Screenshot at 2021-03-08 09-47-35

From the list, you have the root filesystem mounted on sdb6. sda2 is not mounted anywhere.

Yes, you can move the files. First mount /dev/sda2 in a convenient place (like /mnt). Then move all the directories you want moved to /mnt. Then unmount /mnt and mount it where it needs to go.

If this doesn't make sense, you probably need to read on how the Unix filesystems work. I would not attempt to lead someone blindly typing commands--you can lose all the data--you need to understand what you're doing.

You can do this all through Caja also. You will need to sudo to mount a filesystem.

When you finish moving the data, you will need to modify your /etc/fstab so that sda2 will be mounted in the correct place after a reboot.

A backup of the data is always a good idea first.

(Added information): One key concept is that you can access almost any device, network, remote mount, drive, cd, dvd, usb, etc., from the filesystem without specifying drive letters, partitions, or anything else. All of that is taken care of by mounting the device or partition onto a place in the filesystem. Also, linux allows overlay mounting, so a directory may have files in it, then another drive mounted in the same place would temporarily show different files in what appears to be the same location. On unmounting the second drive, the original files would reappear. This is important to understand when you're moving data around to temporary locations.

1 Like

thanks. It's certainly a bit overwhelming. In windows, I can ht click on a folder and change location. Any suggestions on places to read and become more knowledgeable about what you are talking about?

One other thing. Here is what I wanted to do when setting up Ubuntu Mate. I wanted to program to start on my SSD drive, but then I wanted all programs and data to be saved on by SATA drive. I guess that didn't work.

Your going to need a swap partition on the new HD, unless your going to use the old swap partition, which wouldn't make since. avoid swap file.
Also you may experience delay when booting on new HD. If you do after changing swap uusi in fstab, then execute this sudo update-initramfs -u -k all

It is hard to write about because there are so many variations. However, my system is set up in a similar way.

In Linux (or any Unix variant) everything that you do, save, customize should be stored in /home/ Everything else not in /home is systemwide. Unix was built from the ground up assuming a multiuser system, with built in protections to keep everyone else from fiddling with your "stuff". All configuration is in /etc All executable files are in /sbin /bin /usr/sbin /usr/bin (and some others like /opt /usr/local/sbin /usr/local/bin) The package manager takes care of putting all the manual pages, executables, configuration files, and anything else in the correct place in the filesystem for you.

The important concept is that the filesystem is on a different layer than the underlying devices: how directories correspond to the underlying devices and partitions is determined by where they are mounted.

At a terminal window, just as your regular user, you can look at all mounted devices with the command

~/$ mount

That will give you a long list. Included on the list will be something like

/dev/sdb6 on / type ext4 (rw,relatime)

/dev/sdb2 on /boot/efi type ext4 (rw, relatime)

Now try this command:

~/$ cat /etc/fstab

That will give you a similar list, showing everything that the kernel is configured to mount, mostly automatically at boot time.

Right now, your data is (I assume) in /home/ maybe in the Documents folder, or on the Desktop. To the system, that is /home//Documents or /home//Desktop. Where it physically resides depends on the mount list you looked at earlier. For instance, you can mount /dev/sda2 (which is currently probably empty, being just partitioned and formatted) on /home//Documents and suddenly, looking at the Documents folder would show it empty, but anything you saved to Documents would physically now go to /dev/sda2. If you then unmounted /dev/sda2, your newly saved documents would become inaccessible, and the older ones underlying would reappear.

So what you will need to do is:

  1. mount /dev/sda2 in a temporary location (like /mnt) so it can be accessed
  2. copy your entire /home/ to /mnt
  3. edit /etc/fstab, adding a line that mounts /dev/sda2 on /home/ at boot time
  4. reboot, and see that everything works as expected: files saved go to /dev/sda2 (check to see that disk space free decreases using your favorite way)
  5. unmount /dev/sda2
  6. delete your original /home/
  7. reboot

The problem with giving you a formula to type in is I don't know if you have actually stored everything in the assumed places. And you can lose your data from a power outage or a mistaken command.

Here's a link to start with, and it has further references:
https://linuxhomeserver.com/understanding-the-linux-filesystem-structure/

In Windows you can move shell folders (My Documents, Downloads, My Music etc...) using the folders' properties.
In Ubuntu you can achieve the same result by editing the file /home/yourusername/.config/user-dirs.dirs.
This is dirtier than moving your /home/ folder in a proper way but still works.

  1. Backup your files (always do that).
  2. Copy the folders located in /home/yourusername/ you would like to move on the 60gb partition.
  3. Edit the /home/yourusername/.configuser-dirs.dirs file with the new paths.
    Example:
    XDG_DOWNLOAD_DIR="$HOME/Downloads" is default and your new Downloads folder is located in /mnt/lol/Downloads/. The line should be XDG_DOWNLOAD_DIR="/mnt/lol/Downloads".
    Save the file, exit. Reboot and enjoy. if it worked, the new folders on your 60gb partition should have icons like the old ones in your /home/yourusername folder. You should now be able to remove the old folders you copied that should still be located in /home/yourusername/ in order to free some space.

If you want to do it the proper way, just look online for tutorials about "linux how to move home folder to another partition (or another drive)". There are plenty of them.

@verndog, I think you misread the original post. OP doesn't want to move his entire system to a new HD, just the user data. There is no need for changing anything about swap.

Not to be argumentative, but swap files have their use in modern systems. If you have plenty of RAM (16GB, maybe even 8GB) you will never, ever actually use any swap, and certainly will never need a swap during boot-up, which is the only time a swap file is inaccessible. A swap file uses zero space unless it is needed.

With the way current kernels handle disk caches and out-of-memory condition, there is little risk from not having a true partition for swap. If the kernel runs out of memory, the OOM will free up caches, then infrequently used processes to reclaim space.

I would certainly never waste expensive SSD space for a dedicated swap partition, even if I had to have one. Swap would go on the oldest, slowest spinning rust available, and only there until I could afford to buy some more RAM.

But all that is beyond the scope of OPs question. And they are my opinions for systems I run. They are not what I did 15 or 20 years ago with the hardware of that day.