How to re-size root partition without loosing any data if the root partition is immediately followed by swap partition
Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to re-size root partition without loosing any data if the root partition is immediately followed by swap partition
I have been getting the root partition low on space alert frequently, and I want to resize my root partition.Now the root partition is immediately followed by swap partition, is there a way I could resize the root partition without losing any of my data.
A partition manager like gparted should be able to remove swap, resize root then optionally recreate a smaller swap space or swap space elsewhere. When dealing with root and swap, I guess it's best to run it from live media, e.g. gparted live cd.
Distribution: openSUSE(Leap and Tumbleweed) and a (not so) regularly changing third and fourth
Posts: 629
Rep:
Quote:
Originally Posted by thebiggiantmouse
Would deleting the swap partition will not destroy any data or leave the system unbootable?
I haven't had a swap partition for years. It was never used so I scrapped it. As far as I'm aware the only use for swap is if you hibernate your system or if you don't have enough ram, which is unlikely these days.
Would deleting the swap partition will not destroy any data or leave the system unbootable?
Nope, you can run perfectly fine without a swap partition as long as you have sufficient RAM. And to see if you do, simply try running swapoff (as root, which would probably translate to sudo swapoff for most distributions).
BTW, you can do all of this from within a running system. You won't even have to reboot, as long as your root filesystem supports online resizing (most do).
Would deleting the swap partition will not destroy any data or leave the system unbootable?
The swap partition contains copies of RAM pages during operation.
Ser Olmy suggests swapoff to disable swap. This command will fail if the swap partition is in use. If it succeeds, you have nothing on swap that needs to be kept. If it fails, you can't disable swap. Thus my suggestion to use live media for resizing.
... swapoff to disable swap. This command will fail if the swap partition is in use.
Not true. Swapoff writes pages back into RAM - if they can't be accommodated, the command fails.
Moving the swap somewhere else is my preferred position - disk is cheap these days. A mis-configured system will certainly cause boot problems - this applies equally to swap.
is there a way I could resize the root partition without losing any of my data.
The other answers could only go so far, as you don't seem to have fully reported what you have to start with. What else is on that disk? Other partitions? Freespace? Is your /home/ a separate partition? Output from df and fdisk -l or parted -l would help potential helpers help you better.
The other answers could only go so far, as you don't seem to have fully reported what you have to start with. What else is on that disk? Other partitions? Freespace? Is your /home/ a separate partition? Output from df and fdisk -l or parted -l would help potential helpers help you better.
The output of fdisk you posted above does not show any swap partiiion. You also did not post the complete output so do/did you actually have a swap partition and which device was it, sda3? Had you turned swap off or deleted it before running fdisk? Which Linux distribution are you using? You do seem to have a cery large boot partition but that is no immediate help as it is not contiguous with the / partition.
That's only df output. We still need fdisk -l or parted -l. And, as indicated by Firerat, the command itself and the output that follows needs to be enclosed in code tags to preserve the formatting you see when you run a command.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.