Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Running low on storage

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
marco26
Posts: 6
Joined: 2016-02-29 12:31

Running low on storage

#1 Post by marco26 »

I'm running Debian 9 that I've installed on a single 256gb SSD. It was setup with LVM and encryption - 30gb /root, 157gb /home and 68gb/sawp.
I have a fair amount of ram (64gb) and never seen the swap partition even get used, would it be safe to reduce the swap partition to 2gb?
Normally I just use gparted live if i need to change something on any partition but I never used LVM or encryption before can i still use it or there is a better method?
If I would add another SSD is it possible with LVM extending my /home partition to it?
Thanks

kopper
Posts: 137
Joined: 2016-09-30 14:30

Re: Running low on storage

#2 Post by kopper »

Your swap is definately too large for any purpose. You'd absolutely do well with less.

There are different opinions on optimal swap size. Here are some considerations to help you determine the best amount for your case. Generally, I've used same amount of space than my RAM, up to 4Gb. I don't have experience of that much RAM in one system so someone else could probably give you better recommendation than me. I still find even 32GB (50-50 rule) way too much, though it would be good to know an example of two about your use case.

EDIT: Misread your RAM amount.
Debian 10.2 Stable with i3
Secure your stuff: Securing Debian Manual
Don't break your stuff: Source List Management DontBreakDebian

marco26
Posts: 6
Joined: 2016-02-29 12:31

Re: Running low on storage

#3 Post by marco26 »

Thanks, I've successfully managed to add another ssd to my LVM volume with the help of Logical Volume Management gui, unfortunately it doesn't allow me to reduce my swap space and i forgot to encrypt the second ssd before adding it to the volume :( But at least I got a nice "big" /home partition.

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: Running low on storage

#4 Post by p.H »

kopper wrote:Your swap is definately too large for any purpose.
Except for hibernation (suspend to disk). It is recommended to have at least as much swap space as RAM.

If you do not use hibernation, you can just remove the swap. Linux works fine without any swap.
marco26 wrote:Normally I just use gparted live if i need to change something on any partition but I never used LVM or encryption before can i still use it or there is a better method?
I do not think that gparted handles LVM nor encryption. You'll have to use the command line. The good news is that LVM allows to do most resizing online, so no need for a live system.

You'll find real logical volume names and UUIDs in /etc/fstab.

Disable all swaps

Code: Select all

swapoff -a
Remove the swap logical volume

Code: Select all

lvremove /dev/mapper/vgname-swaplvname
Comment out the swap line in /etc/fstab.

Or if you prefer to reduce it to 2 GiB and reformat it

Code: Select all

lvresize -L 2G /dev/mapper/vgname-swaplvname
mkswap -U swap_uuid /dev/mapper/vgname-swaplvname
If you do not set the same UUID, the system won't find it and will complain.

Extend the home logical volume by 30 GiB and its filesystem (assuming it is ext4)

Code: Select all

lvextend -L +30G /dev/mapper/vgname-homelvname
resize2fs /dev/mapper/vgname-homelvname
marco26 wrote:If I would add another SSD is it possible with LVM extending my /home partition to it?
Yes. But if one drive fails, you lose all data in /home.

Create a partition using you favourite partition tool.
Then create an encrypted volume on top of it (adapt with the real partition name and add any desired options)

Code: Select all

cryptsetup luksCreate /dev/sdb2 lvm2_crypt
Add a line for the new encrypted volume in /etc/crypttab.
Rebuild the initramfs

Code: Select all

update-initramfs -u
Note that the passphrase of the second encrypted volume will be asked at start-up too.

Format the encrypted volume as a LVM physical volume

Code: Select all

pvcreate /dev/mapper/lvm2_crypt
Extend the volume group with the PV

Code: Select all

vgextend vgname /dev/sdb1
Extend the home LV and its filesystem in the same way as above.

Edit (wrote all the above before seeing your last post)
marco26 wrote:it doesn't allow me to reduce my swap space
You must disable the swap first (see above).
marco26 wrote:i forgot to encrypt the second ssd before adding it to the volume
You realize that some of the data in /home will not be encrypted, so the encryption is useless ?

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Running low on storage

#5 Post by stevepusser »

Swap space for hibernation does not have to be any bigger than the memory being used at the time of hibernation, and in fact can be considerably less if the hiber-file is compressed, which I believe is the default. I've always used a swap partition smaller than RAM. On a couple occasions where it was still too big to fit, the process went through it a second time and must have trimmed off some excess cache or something, because it then succeeded.
MX Linux packager and developer

User avatar
Gaius
Posts: 33
Joined: 2012-12-18 10:54
Location: Germany

Re: Running low on storage

#6 Post by Gaius »

stevepusser wrote:..... if the hiber-file is compressed, which I believe is the default.
Hibernation File Compression requires additional functionality ('user space software suspend').
The package uswsusp is available in the Stretch repositories.


@OP: While 64GB of memory surely are entertaining to look at when monitoring system performance, I very much doubt your machine will ever use more than 8GB, if that.
Even heavy-duty video rendering doesn't require more than 32GB of memory.

So you will be perfectly fine with 16GB of swap (probably 8GB would do as well).
The rule of thumb of having swap space equalling your system memory is a remnant of times when personal machines were equipped with memory sizes of 256MB or 512MB.
Modern laptops and PCs don't make use of swap at all, except in very rare circumstances ... and for hibernation, of course.

On another note:
Have you considered using a swap file? You can install that on /home (or any other partition), and it is considerably easier to resize, should you need to extend or wish to shrink your available swap.
Have a look at this contribution in the Debian Wiki.

Cheers,
Gaius
If you can’t explain it simply, you don’t understand it well enough.
Albert Einstein

marco26
Posts: 6
Joined: 2016-02-29 12:31

Re: Running low on storage

#7 Post by marco26 »

Sorry man, but you're really far off the mark with those assumptions.

User avatar
Gaius
Posts: 33
Joined: 2012-12-18 10:54
Location: Germany

Re: Running low on storage

#8 Post by Gaius »

marco26 wrote:Sorry man, but you're really far off the mark with those assumptions.
Okay, you've convinced me you really need those 64GB of RAM.

... in addition, four populated memory slots look way cooler in the Window-Kit case, especially in combination with multiple RGB fans and strips, right?
If you can’t explain it simply, you don’t understand it well enough.
Albert Einstein

Post Reply