How can I reallocate disk space between 2 Linux Users (while dual booting w/Windows)

eregon497

New Member
Joined
Sep 8, 2020
Messages
6
Reaction score
0
Credits
78
Hello, I'm still fairly fresh to Linux - only 2-3 months in.

So i have a computer that has both Linux and Windows 10 installed. Grub is loading every time i boot - I installed Windows first and then Linux after (which is the way I want). My computer only has a single drive. In Windows I partitioned the drive into 3:
-C Drive (330GB)
-D drive (399/400GB)
-Unallocated space for the Linux installation

Then i installed Linux OS.
Now i did a sudo adduser to make another Linux account. It didn't ask me how much space it was going to allocate for the new user, so I was only surprised to find out afterwards. Then i noticed i have 2 Linux partitions which are: /dev/sda8 and /dev/sda9
I find that allocating 93.13 GB for the new user (/dev/sda9) is way too much. I only want it to be around 20 GB.

How can i allocate the space from /dev/sda9 (new user) to /dev/sda8 (old user)?

Do i use window's Disk management tool or Linux's gparted (or is there any rule of thumb on what to follow/use when re allocating hard disk space especially if you're on dual boot?) Is there any consequence of

Also in Linux, how do I know what user is assigned to what sda#? (I only managed to find out this info on a file manager)

Attached are the screenshots of my Gparted from Linux and Windows Disk Management Tool

Z111.png
Z2222.jpg
 


the path to a user in linux should be /home/user so /home should be the space of all user for a linux OS. My guess is that /dev/sda8 is the root system of a linux distro and /dev/sda9 is the home space for users of that root install .

/dev/sda7 not sure whats going on with that partition . you've got 24.9 gig unallocated that can be used or absorbed and next to that a swap . you've got /dev/sda9 , /dev/sda10 and un-allocated you could play with.

Assuming there is nothing used of importance in /home , you could delete partitions /sda9 /sda10 which should give you one bigger unalloacted. From there you use gPArted to set up partitions and of the size you want. When you create a partition smaller than the unallocated it will take everything into account, and whats left will be unallocated


One way of seeing who is using what from Linux ; boot up linux and simply use this command :
Code:
sudo df

from booted slackware mine is : bash-5.0# df
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 32768 1292 31476 4% /run
devtmpfs 1947296 0 1947296 0% /dev
/dev/sda3 56743956 37845592 15986316 71% /
tmpfs 1987516 10384 1977132 1% /dev/shm
cgroup_root 8192 0 8192 0% /sys/fs/cgroup
/dev/sda1 101590 23064 78526 23% /boot/efi
bash-5.0# du
85836 .
bash-5.0#
thats showing me /dev/sda3 is root partition and yes my main install is at /dev/sda3



if i go to /home i see a directory with andrew in it; if you created another user from booted linux it should end up in /home but a thought just occurred to me is /home accessible i.e mounted from your linux distro ?

from booted linux distro whats output of
Code:
sudo   /etc/fstab
ps on my slackware laptop i don't have a lot of hd capacity. I only did a root install, then when i installed users it goes into a directory /home/username but that is within partition of root install
 
Last edited:
so /dev/sda1 to /sda6 is windows. /dev/sda7 is boot partition

but a thought just occurred to me is /home accessible i.e mounted from your linux distro ?

Yes, it is accessible and mounted. I can see it from the Dolphin file manager under devices while logged into the root account's perspective.

I also did a root install, however it looks like the sudo adduser command even made a separate partition for it. (I'm guessing - non root and root user can't mix together in one partition, which is why this has happened. - If that's the case then all i'm after will be to just shrink the /home partition a tad smaller.)

Here is the output of cat/etc/fstab

# /etc/fstab: static file system information. #

# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda8 during installation UUID=8b822f48-dbe0-437a-81ae-a5a173c82df3 / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda7 during installation UUID=ec7a0a26-6e08-419c-8c99-101e4120ece0 /boot ext4 defaults 0 2
# /boot/efi was on /dev/sda2 during installation UUID=C630-FB38 /boot/efi vfat umask=0077 0 1
# /home was on /dev/sda9 during installation UUID=3fd3f060-b4b4-4d2a-ba7e-9b75cd5c0e82 /home ext4 defaults 0 2
# swap was on /dev/sda10 during installation UUID=a32eb59a-92a6-4c29-a13b-f201d274c1e1 none swap sw 0 0 /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0

I'm also curious though why does gparted see 3x unallocated spaces separately as the way it is and not as a unified whole? In windows disk management tool it sees unallocated space collectively.
 
Last edited:
You are mistaken. Adding a new user does not create a new partition, and it does not change the size of any partitions. All 4 of your Linux partitions (sda7, sda8, sda9, and sda10) were created when you installed Linux originally. It will be helpful if you actually tell us what Linux you installed.

sda7 (/boot) contains the Linux kernel, the init files, and likely the GRUB bootloader.

sda8 ( / ) contains the bulk of the "operating system" itself, including core utilities, libraries, logs, programs included with Linux and programs you may have installed yourself. The root user home folder is here too, in /root. This is the only home folder stored here, because root is special. This partition has plenty of room left to grow, and it will grow as you use Linux more and install new programs.

sda9 (/home) contains the home folder(s) for all users (except root). This is where many of your software settings are stored (each user has their own settings). Documents, Downloads, Pictures, Music, etc, are folders available for each user on the system. By default, no user is restricted to how much space they may use. But there are settings that can restrict users space allocations, if that is a problem. /home is your largest partition, and it should be. This is where you store everything, and this is primarily what you need to backup to save your data.

sda10 (linux-swap) is not always created as its own partition anymore. Often a swap file is created instead. This is a matter of which Linux distro you installed. You can see it is currently not being used on your system, and that is probably because you have plenty of RAM and swap is not needed. (But don't delete it.)

If your Linux and Windows systems are working well, I would not make any changes. "If it ain't broke, don't fix it!" as the saying goes. It's always a good idea to keep an eye on hard drive (or partition) space to be sure you don't get too full, but you are in good shape with a lot of room to explore and learn with your new Linux. Enjoy!
 
Ok, but i would still like to make my dev/sda8 partition larger, i would rather have most of the stuff in one partition than having 2 partitions.

So i moved the home directory of the user at sda9 to sda8 via this command:
usermod -m -d /newhome/username username

But i did push ahead and unmount and deleted my /dev/sda9 partition using gparted (its newly created and has absolutely nothing valuable inside it)

Now i want to resize my sda8 partition to make it bigger.

Is it necessary to delete the swap file partition at /dev/sda10 before resizing the /dev/sda8 partition?
(so as to be able to use both the unallocated space that is surrounding the linux swap partition i.e. - avoid segmenting, marked with orange X)

If so, how do i regenerate the linux swap partition afterwards?
(I have 20GB of ram, i'm ok with the 5.59GB of Linux swap file, i can afford to retain the same file size but if there's any better value suggested, let me know)

Z85446345.png



at 4:35 of the video - the guy explains that he should delete the swap partition and then create a new partition in order for the swap partition to be at the last segment. Does the swap partition always need to be on the end or be the last linux partition amongst all other linux partitions?
 
in theory the partitions are listed as they are physically in terms of /dev/sda1 -> sda9 they are out of sequence. but i think you can stretch that /dev/sda8 into the unallocated of 93.13 .

Now then you can view partitions using gParted from the OS that you are booted from but you can not do anything with them using gPArted from the OS you are booted from since they need to be unmounted. So you need to boot from Live Linux OS and do it from there. Basically if that unallocated of 93.13 is next to /dev/sda8 then it would be a case of left click on /dev/sda8 then right click move/resize and then drag /dev/sda8 partition into unallocated
 
Actually now i'm stuck in emergency mode just after deleting the dev/sda9 partition and then rebooting (i didn't delete the Linux swap file partition). I already made a bootable Linux USB cd, but I don't know where to go from here.

I tried sudo fsck /dev/sda8 and it completed, then i rebooted but still same result. Still stuck at recovery mode. Alsochecked that the UUID of my /etc/fstab file's /boot/efi is the same as the one shownin blkid

I can still access the files at sda8 from my Linux bootable usb.
 
Ok wow. silly me hahaha.

I fixed it by just looking at the /etc/fstab file and then i saw the deleted partition previously which was sda9. I simply put a # before it.

I was looking on some guides but they don't mention the need of editing this file. Luckily i read somewhere about this topic and recalled.

Now since /dev/sda9 is gone, I can completely remove the line from the /etc/fstab file and then proceed to the Live Linux OS Boot and unmount my /dev/sda8 then resize
 
Ok success

I did quite a bit of research before finalizing my decision on how to allocate the remaining space. I extended my root partition to 120 GiB and the remaining I gave it to my /home partition, amounting to around 40GiB

If anyone's been following me, here are the steps i took:

1.) First, move all the files safely from the partition that we will be deleting to the partition that we will be using

Change the user's home directory:
usermod -d /newhome/username username

usermod is the command to edit an existing user.
-d (abbreviation for --home) will change the user's home directory.

OR

Change the user's home directory + Move the contents of the user's current directory:
usermod -m -d /newhome/username username
-m (abbreviation for --move-home) will move the content from the user's current directory to the new directory.

See: https://stackoverflow.com/questions/20797819/command-to-change-the-default-home-directory-of-a-user


2.) Go to Gparted, unmount the old partition and delete it

3.) Go to nano /etc/fstab and comment out the partition that you deleted with a #. If you don't do this, You will be STUCK IN RECOVERY MODE.
(Because fstab is going to look for and complain where the hell is your deleted partition)

4.) Now boot into a bootable Live Linux USB. This is because you need to unmount the partition that you were currently using
Go to Gparted > unmount the partition that you will resize > then increase the size accordingly > then mount it back.

5.) You can choose to add a new partition if you'd like and if there is still availabe space to do so.
>>If you do choose to add a new partition, mount it afterwards then do

sudo blkid -> Take note of your new partition's UUID. You will then need to register it to the /etc/fstab file

sudo nano /etc/fstab -> You will then put the new Partition UUID here. For example, if your new partition was /dev/sda9, you look at the UUID value from the previous step and then type it here in the fstab file.

Note: Be sure that your UUID from the output of sudo blkid command matches with your /etc/fstab

I was wondering whether I should go and just stick with a / partition or have both a / and a /home partition. This article helped me to decide to do the latter:


as well as this extra info: https://askubuntu.com/questions/25158/software-installed-on-root-partition-or-on-home-partition
 

Staff online


Top