Announcement

Collapse
No announcement yet.

Reducing swap partition

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED] Reducing swap partition

    Hello,
    i'd like to reduce the space of my swap partition, in order to create a partition for windows 10. I`d like to get 20/25gb. I don't have much space in my ssd, but i don't download movies nor i need much space cause i just use my laptop for programming and watch movies.This is my current situation:



    Can you guide me step by step how to safely do it?

    #2
    Ditch the swap partition altogether, and go to a swap file instead. This is the default option on new installs these days.

    https://linuxize.com/post/how-to-add...ng-a-swap-file

    You will want to remove any existing entry in your fstab for the old swap partition while adding the new swap file to it as described above.

    You don't need 15gb of swap, even with gobs of ram, unless you hibernate (suspend to disk) so 2gb to 4Gb is usually plenty.

    Comment


      #3
      And is 25 gb even enough for W10? My seldom booted setup with almost zero extra software, and all crud and shareware and Mcaffee removed sits at 33Gb

      Comment


        #4
        Originally posted by claydoh View Post
        And is 25 gb even enough for W10? My seldom booted setup with almost zero extra software, and all crud and shareware and Mcaffee removed sits at 33Gb
        That seems like a lot. A have a stripped down Windows 10 VM at 14GB and a "fresh" one at 25GB. But that brings up a good question: why install W10 to bare metal at all?

        Unless you're going to run game that requires a very high resource load, why not just install it to a VM? MS even lets you do that legally provided you only use it in one location at a time. If you use QEMU/KVM instead of Vbox you can even pass through to the video card if needed. I haven't done that because I have no need, but I read it's doable. VBox is a bit easier for a new user than QEMU but QEMU is a lot faster and more native to Linux.

        Also, I totally agree with Claydoh about the swap - just convert to a file and put it on your home partition. I wouldn't go below 20GB if you're shrinking the install partition. It gets harder to update with much less than that.

        Please Read Me

        Comment


          #5
          Mine, after thinking about it, is probably restore points and the like. I only have Windows still partly for warranty and partly Just In Case I pick up some sort of work at home gig that requires it. Those usually expressly forbid using Windows in a VM.

          As it us currently in a separate drive it probably is a good time to upgrade that SSD to a bigger one. I still have room for another sata drive if I need to *shudder* actually use Windows for any length of time.

          Sent from my LM-V600 using Tapatalk

          Comment


            #6
            Originally posted by claydoh View Post
            ...Just In Case I pick up some sort of work at home gig that requires it. Those usually expressly forbid using Windows in a VM...
            On my previous job (remote and travel - almost zero office time), my employer sent me a crappy Dell laptop with Windows and MS Office 365 on it. Which meant I had to travel with two laptops because I work in a Linux environment.

            I convinced my IT department to provide me with a reg. key for Windows instead and they could have their laptop back. Then I used it on my much higher end personal laptop or on my powerful desktop PC when at my home office. Saved me some travel weight and Windows ran much better as a VM on Linux than natively.

            Please Read Me

            Comment


              #7
              The type of work I would be doing would be along the lines of call center work so im not sure i could do that sort of thing.

              I have not had to sink that low, but right now I have to entertain the distasteful possibility.

              I would do Facebook/Instagram rating work before I do call center work.

              Now i'm off to see what SSD prices are like at the moment lololol.

              Sent from my LM-V600 using Tapatalk

              Comment


                #8
                Originally posted by claydoh View Post
                Ditch the swap partition altogether, and go to a swap file instead. This is the default option on new installs these days.

                https://linuxize.com/post/how-to-add...ng-a-swap-file

                You will want to remove any existing entry in your fstab for the old swap partition while adding the new swap file to it as described above.

                You don't need 15gb of swap, even with gobs of ram, unless you hibernate (suspend to disk) so 2gb to 4Gb is usually plenty.
                I created the swap file following the guide you linked me and removed the swap partition.
                Now i have as follow:
                ~ sudo parted --l
                Model: ATA SAMSUNG MZ7LN128 (scsi)
                Disk /dev/sda: 128GB
                Sector size (logical/physical): 512B/512B
                Partition Table: gpt
                Disk Flags:

                Number Start End Size File system Name Flags
                1 1049kB 256MB 255MB fat32 boot, esp
                2 256MB 25.3GB 25.0GB ext4
                4 41.3GB 128GB 86.8GB ext4

                my goal is to use all the unallocated space left by the previous swap partition, around 16gb and part of the partition n4 and to create a new partition were i'm going to install windows 7 or 10, it depends. So if i take 15 or 10 gb from /home i should be fine i guess. Can you please assist me with the procedure? Thank You
                Last edited by Kaido; Nov 02, 2020, 03:30 PM.

                Comment


                  #9
                  You can use Gparted, or the KDE Partition Manager, but you will have to do it from a live session, like the Kubuntu install disk you used. This has the KDE partition manager included already.
                  You can install gparted to the live session if you prefer this tool - it will be installed to ram, so won't be permanent.


                  Both tools work pretty much the same

                  Here is a how-to:
                  https://www.howtogeek.com/114503/how...tu-partitions/

                  Basically, you right click on the partition you want to resize, and select 'resize/move' and drag the bar representing the partition to reduce or increase the size.
                  Make a note of which partition name (sda1, etc) goes with which partition (/home etc) before you boot to the live disk.

                  Comment


                    #10
                    Originally posted by claydoh View Post
                    You can use Gparted, or the KDE Partition Manager, but you will have to do it from a live session, like the Kubuntu install disk you used. This has the KDE partition manager included already.
                    You can install gparted to the live session if you prefer this tool - it will be installed to ram, so won't be permanent.

                    Both tools work pretty much the same

                    Here is a how-to:
                    https://www.howtogeek.com/114503/how...tu-partitions/

                    Basically, you right click on the partition you want to resize, and select 'resize/move' and drag the bar representing the partition to reduce or increase the size.
                    Make a note of which partition name (sda1, etc) goes with which partition (/home etc) before you boot to the live disk.
                    I managed to create a a new partition 30gb for windows, after i shrunk a bit the /home partition and deleted the 16 gb swap partition as you suggested. I also installed windows and it works perfectly and it's super fast to boot. Now i have a problem with Kubunto that is very slow to boot. This happened since i deleted the swap partion, even before the shrunk and the creation of the windows partition. At the moment i created a swap file of 1gb only. How can i make it fast as before?

                    at the moment this is the current situation:
                    # /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/sda2 during installation
                    UUID=8fcf9eb4-8ef6-4730-997c-7560dbc5e226 / ext4 errors=remount-ro 0 1
                    # /boot/efi was on /dev/sda1 during installation
                    UUID=84EB-B207 /boot/efi vfat umask=0077 0 1
                    # /home was on /dev/sda4 during installation
                    UUID=2aac7201-7a77-4363-9c7c-79232e383028 /home ext4 defaults 0 2
                    # swap was on /dev/sda3 during installation
                    # UUID=dd23fed0-da77-42a2-89f4-b008eac18e30 none swap sw 0 0
                    /swapfile swap swap defaults 0 0

                    As you can see i commented the UUID of the swap since i`m using the file. Maybe 1gb file swap makes the boot of kubunto slow? I also tried to use fsck from recovery as in the photo but i get an error.



                    Thank You

                    Last edited by Kaido; Nov 05, 2020, 08:40 AM.

                    Comment


                      #11
                      Don't know if is makes a difference, but the option for the mount should be "sw" not "defaults"

                      You can test to see if the swap file is your problem by commenting it out and rebooting.

                      You didn't really say HOW you made the swap file, but AFAIK this is the proper procedure:

                      sudo dd if=/dev/zero of=/swapfile bs=1M count=1024

                      t doesn't really matter WHERE you put it, but /var/cache is sort of a normal place I think. Nothing wrong with having in your root directory if that's where you want it though.

                      Please Read Me

                      Comment


                        #12
                        Originally posted by oshunluvr View Post
                        Don't know if is makes a difference, but the option for the mount should be "sw" not "defaults"

                        You can test to see if the swap file is your problem by commenting it out and rebooting.

                        You didn't really say HOW you made the swap file, but AFAIK this is the proper procedure:

                        sudo dd if=/dev/zero of=/swapfile bs=1M count=1024

                        t doesn't really matter WHERE you put it, but /var/cache is sort of a normal place I think. Nothing wrong with having in your root directory if that's where you want it though.
                        I've deleted the previous 1G swap file and created a new one of 3G following this guide https://itsfoss.com/create-swap-file-linux/

                        fstab now looks like this:

                        # /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/sda2 during installation
                        UUID=8fcf9eb4-8ef6-4730-997c-7560dbc5e226 / ext4 errors=remount-ro 0 1
                        # /boot/efi was on /dev/sda1 during installation
                        UUID=84EB-B207 /boot/efi vfat umask=0077 0 1
                        # /home was on /dev/sda4 during installation
                        UUID=2aac7201-7a77-4363-9c7c-79232e383028 /home ext4 defaults 0 2
                        # swap was on /dev/sda3 during installation
                        # UUID=dd23fed0-da77-42a2-89f4-b008eac18e30 none swap sw 0 0
                        /swapfile none swap sw 0 0

                        I tried to check with the fsck the integrity of the filesystems, but still from the recovery it always says i have to unmount a filesystem to proceed and i don't know how to do it from there. So now it take 40/45 sec to boot to the login page. I have an ssd disk.

                        Comment


                          #13
                          We'll need to see some boot logging info

                          Code:
                          systemd-analyze 
                          
                          systemd-analyze blame
                          
                          systemd-analyze critical-chain

                          Comment


                            #14
                            I found the solution in this thread https://forums.linuxmint.com/viewtopic.php?t=309732
                            by just running sudo update-initramfs -u
                            and rebooting now after the Kubunto logo it takes 5 seconds to get me to the login screen.
                            You may want to update the title of the thread since i also had to fix the slow boot issue.
                            Last edited by Kaido; Nov 05, 2020, 10:30 AM.

                            Comment


                              #15
                              Good catch and makes sense. *buntu uses the swap a a restore point and initramfs updates include it. What happens is if you change your swap in almost any way, it delays boot like that until initramfs is updated. I had run into that before and forgotten about it.I don't like it myself - I don't need a restore point, just swap when RAM is full.

                              Please Read Me

                              Comment

                              Working...
                              X