Add free space to a partition.

New to Debian (Or Linux in general)? Ask your questions here!

Add free space to a partition.

Postby hack3rcon » 2020-06-18 16:26

Hello,
The "home" directory is 100% full and I want to add some free space to it from other partition. I have 1TB HDD as below:
Code: Select all
$ sudo fdisk -l
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: WDC WD10XXXX-11F
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x6e3c3092

Device     Boot      Start        End   Sectors   Size Id Type
/dev/sda1  *          2048     206847    204800   100M  7 HPFS/NTFS/exFAT
/dev/sda2           206848  314574847 314368000 149.9G  7 HPFS/NTFS/exFAT
/dev/sda3        314574848 1134036991 819462144 390.8G  7 HPFS/NTFS/exFAT
/dev/sda4       1134039038 1953523711 819484674 390.8G  f W95 Ext'd (LBA)
/dev/sda5       1134039040 1742213119 608174080   290G  7 HPFS/NTFS/exFAT
/dev/sda6       1840457728 1934010367  93552640  44.6G 83 Linux
/dev/sda7       1934012416 1953523711  19511296   9.3G 82 Linux swap / Solaris
/dev/sda8       1742215168 1744166911   1951744   953M 83 Linux
/dev/sda9       1744168960 1840453631  96284672  45.9G 83 Linux

My goal is to add free space from "sda5" to "sda6":
Code: Select all
/dev/sda6       45911048  43460960     94888 100%

But, I don't like to loss any data. On both partitions I have data.
Any GUI tools or suggestion?

Thank you.
hack3rcon
 
Posts: 386
Joined: 2015-02-16 09:54

Re: Add free space to a partition.

Postby ruwolf » 2020-06-18 18:24

You should always make backup of your important data before partition manipulations.
Gparted can change sizes of partitions...
User avatar
ruwolf
 
Posts: 410
Joined: 2008-02-18 05:04
Location: Slovakia, Banovce nad Bebravou, Matice slovenskej 1260/4-7

Re: Add free space to a partition.

Postby cuckooflew » 2020-06-18 18:53

https://wiki.debian.org/DiskFreeSpace?action=show&redirect=DiskFull
---snip----use the above link and read it all>>>
When your Home directory becomes full, you will not be able to save any file, and some applications might refuse to start correctly.---snip----

================================================
Usually Gparted will give you a warning, if there is a risk,or chance of losing the data. But still it is best to make a backup before resizing any a partitions, sometimes things go wrong, and usually they are things that you thought would never happen, or things you never thought of.
https://wiki.debian.org/Partition (also lists all the tools available for Debian)
---snipped,but important to read all of it ----:the before parts are relevant as well ----:
After Partitioning

After partitioning, the partition numbers of the unaltered partitions may change. For example, a partition that used to be identifed as /dev/sda7 may change to /dev/sda6 after the deletion of a partition. In this case, a number of configuration files needs to edited:

The fstab file needs to be altered so that the swap partition and the various static mount points will work properly

If the partition number for the swap partition was altered, the /etc/initramfs-tools/config.d/resume file also needs to be edited. This file indicates the partition used for hibernation; the swap partition is generally used for this purpose. update-initramfs -u needs to be ran afterwards to update the initramfs image.
Please Read.. What we expect you have already Done.
Does any one know about this ?
Users browsing this forum: Google Knows, and
My grand father knows all about everything:
…one flew east, one flew west,
One flew over the cuckoo’s nest.
cuckooflew
 
Posts: 403
Joined: 2018-05-10 19:34
Location: Some where out west

Re: Add free space to a partition.

Postby p.H » 2020-06-18 20:35

hack3rcon wrote:The "home" directory is 100% full

Not completely full. Still ~2 TB (5% reserved) free space left. You could make this space available by setting the reserved count/ratio to 0 with tune2fs -r/m.

hack3rcon wrote:My goal is to add free space from "sda5" to "sda6":

Good luck. sda8 and sda9 stand in the way (not in order), so you will have to move them (and sda6 too)

I'd rather delete the swap partition sda7, use the free space to extend sda6, reduce any other partition by 8 GB and create a new swap partition with the same UUID/LABEL. This way no need to move any partition.
p.H
 
Posts: 1365
Joined: 2017-09-17 07:12

Re: Add free space to a partition.

Postby hack3rcon » 2020-06-20 04:46

I turned the swap partition and deleted it by "cfdisk" , but system can't boot :(
It show me:
Code: Select all
error: file '/grub/i386-pc/normal.mod' not found

How can I solve it?
hack3rcon
 
Posts: 386
Joined: 2015-02-16 09:54

Re: Add free space to a partition.

Postby p.H » 2020-06-20 06:13

I guess that deleting sda7 renumbered other logical partitions, including the /boot partition (formerly sda8 ?). I hate logical partitions for this. Debian's GRUB core image uses the /boot partition number when it is in the same drive (I hate GRUB for this).
First, you must set the right partition number at the GRUB prompt to boot :
Code: Select all
set prefix=(hd0,msdos7)/grub
insmod normal
normal

assuming that the /boot partition is now sda7. Could be any number starting from sda5.

Once booted, reinstall GRUB with
Code: Select all
dpkg-reconfigure grub-pc

or
Code: Select all
grub-install /dev/sda

to record the right partition number.

Bottom line : don't use a logical partition for /boot.
p.H
 
Posts: 1365
Joined: 2017-09-17 07:12

Re: Add free space to a partition.

Postby NFT5 » 2020-06-21 00:26

Well that certainly turned a molehill into a mountain. :roll:

The solution was in the first reply:
ruwolf wrote:You should always make backup of your important data before partition manipulations.
Gparted can change sizes of partitions...


For the record, in GParted, right click on the partition that you want to make smaller and select "Resize/Move".

You'll get a dialogue box like this:
Image

Leave "Free space preceding" at 0 and increase "Free space following" by the amount that you want to decrease the partition size by.

Click on the "Resize/Move" button, accept the proposed changes and then "Apply".

This will be fairly quick and will leave you with a smaller partition and some free space between it and the next partition.

Now right click on the partition that you want to increase the size of and again select "Resize/Move". This time decrease the "Free space preceding" to 0. This should increase the size of the partition but sometimes transfers the free space to the end. Make sure that free space before and after are 0 (or 1) and then click "Resize/Move" and go through the process to apply the changes. This will take a bit longer as the data needs to be moved within the partition but is a relatively safe procedure. As always, back up before you start anything like this.
User avatar
NFT5
 
Posts: 391
Joined: 2014-10-10 11:38
Location: Canberra, Australia

Re: Add free space to a partition.

Postby cuckooflew » 2020-06-21 06:00

ruwolf wrote:You should always make backup of your important data before partition manipulations.
Gparted can change sizes of partitions...

and I said "
Usually Gparted will give you a warning, if there is a risk,or chance of losing the data. But still it is best to make a backup before resizing any a partitions, sometimes things go wrong, and usually they are things that you thought would never happen, or things you never thought of.

This OP , I think does not read most of what anyone suggests,......
Any way reconfiguring Grub or re-installing it might work, Hopefully this taught it a lesson, but probably not. Sheesh,..
Please Read.. What we expect you have already Done.
Does any one know about this ?
Users browsing this forum: Google Knows, and
My grand father knows all about everything:
…one flew east, one flew west,
One flew over the cuckoo’s nest.
cuckooflew
 
Posts: 403
Joined: 2018-05-10 19:34
Location: Some where out west

Re: Add free space to a partition.

Postby hack3rcon » 2020-06-22 07:49

p.H wrote:I guess that deleting sda7 renumbered other logical partitions, including the /boot partition (formerly sda8 ?). I hate logical partitions for this. Debian's GRUB core image uses the /boot partition number when it is in the same drive (I hate GRUB for this).
First, you must set the right partition number at the GRUB prompt to boot :
Code: Select all
set prefix=(hd0,msdos7)/grub
insmod normal
normal

assuming that the /boot partition is now sda7. Could be any number starting from sda5.

Once booted, reinstall GRUB with
Code: Select all
dpkg-reconfigure grub-pc

or
Code: Select all
grub-install /dev/sda

to record the right partition number.

Bottom line : don't use a logical partition for /boot.

Thank you so much.
Problem solved but, my system is become slow and I see some errors when system booting. My PC has 16GB RAM and I removed the Swap partition and system not have any Swap. Can it cause any problem?
Errors are:
Code: Select all
$ cat /var/log/daemon.log | grep swap
Jun 23 12:12:04 Xen systemd[1]: swap.target: Job swap.target/start failed with result 'dependency'.
Jun 23 12:12:04 Xen systemd[1]: dev-disk-by\x2duuid-11944d2e\x2d448f\x2d4cec\x2d9cb2\x2dd1e1a27a9554.swap: Job dev-disk-by\x2duuid-11944d2e\x2d448f\x2d4cec\x2d9cb2\x2dd1e1a27a9554.swap/start failed with result 'dependency'.
Jun 23 12:13:33 Xen systemd[1]: dev-disk-by\x2duuid-11944d2e\x2d448f\x2d4cec\x2d9cb2\x2dd1e1a27a9554.swap: Job dev-disk-by\x2duuid-11944d2e\x2d448f\x2d4cec\x2d9cb2\x2dd1e1a27a9554.swap/start failed with result 'dependency'.

And:
Code: Select all
$ cat /var/log/boot.log
[ TIME ] Timed out waiting for device /dev/disk/by-uuid/11944d2e-448f-4cec-9cb2-d1e1a27a9554.
[DEPEND] Dependency failed for /dev/disk/by-uuid/11944d2e-448f-4cec-9cb2-d1e1a27a9554.
[DEPEND] Dependency failed for Swap.

And:
Code: Select all
/dev/disk/by-uuid$ ls
0BA31B820BF55977                      835eb957-6ab2-41cb-b8ce-68b5abd61c6c
21666f8e-48dc-4ba8-b4be-fe52fbba8f0d  DEA89B8EA89B6435
2787D0F735E01280                      E0886C5A886C30E8
3c20650b-ae38-4b70-b9be-d11cf101c93b  E4109E0F109DE936
78EC7D9BEC7D547A

Which kind of partition is good for "/boot" ?
hack3rcon
 
Posts: 386
Joined: 2015-02-16 09:54

Re: Add free space to a partition.

Postby sickpig » 2020-06-22 11:59

hack3rcon wrote:My PC has 16GB RAM and I removed the Swap partition and system not have any Swap. Can it cause any problem?

https://wiki.archlinux.org/index.php/swap#Swap_file
User avatar
sickpig
 
Posts: 376
Joined: 2019-01-23 10:34

Re: Add free space to a partition.

Postby p.H » 2020-06-22 12:49

hack3rcon wrote:I see some errors when system booting. My PC has 16GB RAM and I removed the Swap partition and system not have any Swap. Can it cause any problem?

As you can see. The system expects a swap partition but cannot find it. This is why I wrote
p.H wrote:create a new swap partition with the same UUID/LABEL.

so that the system finds it at boot. However a missing swap should not make the system slower after boot, unless it really needs swap.

If you consider that your system does not need any swap, just comment it in /etc/fstab.

hack3rcon wrote:Which kind of partition is good for "/boot" ?

A primary partition, which is less likely to be renumbered, or an LVM logical volume (not partition).
LVM would have made all this resizing much easier.
p.H
 
Posts: 1365
Joined: 2017-09-17 07:12

Re: Add free space to a partition.

Postby hack3rcon » 2020-06-23 20:56

p.H wrote:
hack3rcon wrote:I see some errors when system booting. My PC has 16GB RAM and I removed the Swap partition and system not have any Swap. Can it cause any problem?

As you can see. The system expects a swap partition but cannot find it. This is why I wrote
p.H wrote:create a new swap partition with the same UUID/LABEL.

so that the system finds it at boot. However a missing swap should not make the system slower after boot, unless it really needs swap.

If you consider that your system does not need any swap, just comment it in /etc/fstab.

hack3rcon wrote:Which kind of partition is good for "/boot" ?

A primary partition, which is less likely to be renumbered, or an LVM logical volume (not partition).
LVM would have made all this resizing much easier.

Which kind of tasks or process need swap?
How can I create a partition with same UUID?
hack3rcon
 
Posts: 386
Joined: 2015-02-16 09:54

Re: Add free space to a partition.

Postby sickpig » 2020-06-24 01:51

Code: Select all
man mkswap|grep -i uuid
       -U, --uuid UUID
              Specify the UUID to use.  The default is to generate a UUID.
User avatar
sickpig
 
Posts: 376
Joined: 2019-01-23 10:34

Re: Add free space to a partition.

Postby p.H » 2020-06-24 08:13

hack3rcon wrote:Which kind of tasks or process need swap?

Hibernation.
Any use case which requires more virtual memory (including disk cache) than available physical RAM.

hack3rcon wrote:How can I create a partition with same UUID?

Create the swap partition with any partitioning tool.
Format it with
Code: Select all
mkswap -U <uuid> /dev/sdXY

or, if the swap is already formatted, just change the UUID :
Code: Select all
swaplabel -U <uuid> /dev/sdXY

You can find the swap UUID in /etc/fstab.
p.H
 
Posts: 1365
Joined: 2017-09-17 07:12


Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 12 guests

fashionable