Add a storage partition & modify system to suit

Here is where you can post tips and tricks to share with other users of MX. Do not ask for help in this Forum.
Post Reply
Message
Author
User avatar
handy
Posts: 611
Joined: Mon Apr 23, 2018 2:00 pm

Add a storage partition & modify system to suit

#1 Post by handy »

Note: Please let me know if you see any problems in the following:

Introduction

As happens to most of us, our storage system was OK when we initially devised it, then, as it happens, the years have gone by & it becomes inefficient & a bit messy. So, time for a makeover.

Before I wrote this tutorial, I spent some hours reorganizing my partitions - 11 -> 12 hours of GParted work (so long due to my having a LOT of data, which by its existence makes the process much slower). During this time I removed the /swap partition; enlarged my / partition, even though it still had ~2GB of free space which should have been fine for the way I use my system.

A /swapfile was used to replace the /swap partition (see the "How to create a Swapfile... tutorial for more on this subject). I put my new /swapfile in the / partition.

I also shrunk my /home partition as near as small as I could with the size of the data it was holding, so that I could then create a new partition on the same drive. This new partition was to become the new location for my personal data.

Note: You have to use live media when editing system partitions, as the partition editing can only be done on partitions that are not mounted - meaning that they have to be in an unusable state before they can be edited.

I had to create that new partition, then reboot, then move all of my personal storage data over to the new partition. Then reboot the GParted live CD (any live media that has GParted on it should do the job) & shrink my /home down to 20GB, which is far larger than it needs to be in my new layout, but I have the disk space to spare, so why not? (I could always change it with GParted in the future if I had to.)

My system then needed to be configured to work with these changes as I will go into below.

The new partition layout

/boot - 102MB ext2 (half full)
/ - 20GB ext4 (carries the 4GB /swapfile & still has 5GB free)
/home - 20GB ext4 (12GB free)
/bdata - 892GB ext4


Manipulating the Partitions

The GParted boot CD (based on Debian) was used to delete /swap & to modify the size of all (bar /boot) of the partitions on the 1TB (931.51GB formatted) drive. I had to, delete, shrink, move, expand, create (reboot & move my personal data across from /home to the new /bdata , then reboot GParted) shrink, expand.

As previously mentioned, this took 11 -> 12 hours. The larger the partition & the more data involved the longer it takes to process a partition.

IMPORTANT NOTE: It is always best practice, to NEVER give any partition editing software that you use, no matter what OS/distro you are using it on, more than one job to do at a time. Meaning, that if you are using for example GParted, which does allow you to give it a string of jobs to do & then Apply them, don't do that. You may get away with it 20 times, you may not.

Our data can be just too valuable to loose, especially if we don't have a backup, then beyond loosing our valuable time, we may have lost irreplaceable data (baby photos for instance). That said, GParted has never put a foot wrong for me & I've been using it for ~13 year - one process at a time though. ;) /rant


Modifying the system to suit these changes

I had to comment out the call for mounting the /swap partition in /etc/fstab , change the path buttons in Worker (I'm probably the only one reading this that uses the wonderful Worker file utility, so, for all that statement was worth...) to suit the new partition layout. For anyone doing the same thing you need to think about anything that you may have done that needs to be reconfigured to use these new paths (more on this later).

Then in the Terminal I used the blkid command to get the UUID of the new /bdata partition so I could add a call to it into the /etc/fstab :

Code: Select all

 [handy@mantrix ~]$ blkid
 /dev/sda1: UUID="41c2c2b3-5ad8-43bc-9bf0-84d3b429127d" TYPE="ext2" 
 /dev/sda2: LABEL="big.data" UUID="9fe95af9-529e-4f68-b83c-7fa9e7fb3ba1" TYPE="ext4" 
 /dev/sda3: LABEL="my.system" UUID="6dfe5e6b-86b9-4301-b385-8cc3816ada8c" TYPE="ext4" 
 /dev/sda4: LABEL="my.home" UUID="b993339d-dbb3-4fbd-adb4-e61baf43cd7f" TYPE="ext4" 
 /dev/sdb1: LABEL="store" UUID="05e6f212-4003-430b-a7d9-a53d98fad0b5" TYPE="ext4" PARTUUID="8cb60e1f-8d16-4d9c-bccc-3a2cd5396836" 
As you may have noticed, the new partition was given the /dev/sda2: spot (which once belonged to /swap).

I Copied the UUID for the new partition into /etc/fstab & created a call for this new partition, like so:

Code: Select all

 UUID=9fe95af9-529e-4f68-b83c-7fa9e7fb3ba1 /mnt/bdata ext4 defaults      0       1
Then as root I made the directory /mnt/bdata , so that the new partition is accessible. You can do this in the Terminal like so (replace <directory.name> with the name you want to call your new partition:

Code: Select all

 sudo mkdir /mnt/<directory.name>
Due to GParted doing its work with root permissions we need to change the ownership (owner:group) of the new partition, which we do by modifying the ownership of the directory name (that was created in the last command above) from root:root to <user.name>:users. To do that use the following Terminal command:

Code: Select all

 sudo chown <user.name>:users  /mnt/<new.partition's.name>
Configure the system to use new default storage directories

Firstly, I had to check both the ~/.bash_profile & the /etc/profile files & modify the '''PATH''' variables where I had added paths that were now incorrect. Most users here won't have changed anything in these two files, though it is just too easy to do, to not check them for safeties sake. When looking at these files, check the PATH line for anything that relates to your moved storage directories. You probably won't have any differences unless you added them. These lines in my files follow, you will see where I have replaced the original paths with /mnt/bdata

~/.bash_profile

Code: Select all

 PATH=$PATH:/mnt/bdata/scripts
 export PATH
 
 PATH=$PATH:~/games/ut2004
 export PATH
 
 PATH=$PATH:~/games/ut2004/System
 export PATH
/etc/profile

Code: Select all

 # Set our default path
 PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/mnt/bdata/scripts:"
 export PATH
Then I needed to change the paths for what are considered to be the standard default /home/<user>/ storage directories - Downloads, Video, Music & so on. I had previously changed these paths, also, I don't want to use capital letters in the beginning of their names.

~/.config/user-dirs.conf

Code: Select all

# This file is written by xdg-user-dirs-update
# If you want to change or add directories, just edit the line you're
# interested in. All local changes will be retained on the next run
# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
# absolute path. No other format is supported.
# 
XDG_DESKTOP_DIR="$HOME/desktop"
XDG_DOWNLOAD_DIR="/mnt/bdata/downloads"
XDG_DOCUMENTS_DIR="/mnt/bdata/documents"
XDG_MUSIC_DIR="/mnt/bdata/music"
XDG_PICTURES_DIR="/mnt/bdata/pictures"
XDG_VIDEOS_DIR="/mnt/bdata/pictures"
Once you have done this, check that you don't have new (likely empty) default directories in your ~/ that were created by the above file(s) on boot. Any such void files should be deleted after you have modified either the user based ~/.config/user-dirs.conf or if for some reason you have had a need to edit the root based /etc/xdg/user-dirs.defaults file instead (the user based ~/.config/user-dirs.conf takes precedence over the root based file).

~/.bashrc may need some paths changed as well, depending on what you call from it.

I also had to tell qBittorent, Vivaldi (& any other browsers I'm testing) where their particular download directories had moved to. Any other applications that were set to save data into the documents, or any other directory that has moved (or been created as a default, in either of the two directories above) will need to have their config's modified too. & so it goes...

Creating a /swapfile

Now, if you do choose to not have a /swap partition but you would still like to have swap space (which of course you can choose to easily have at any time in the future), then there is a very functional option available to you called a /swapfile. For simple information on how to set one up, have a look at the how-to in this section.
1_MSI: MAG B560 TORP', i5, RAM 16GB, GTX 1070 Ti 12GB, M2 238GB + USB, MX-23 Fb to Openbox
2_Lenovo: Ideapad 520S, i5, RAM 8GB, GPU i620, HDD 1TB, MX-21 - Openbox
3_Clevo: P150SM-A, i7, RAM 16GB, nVidia 8600, 2x 1TB HDD & M.2 256 GB, MX-21 - Openbox

Post Reply

Return to “Tips & Tricks by users”