http://i.imgur.com/DXzjOrF.png
I want to resize /home to make a swap partition. What additional steps must I take to ensure that I don't lose any data? Is it possible to reduce the distance in sectors between files and defragment (to the extent that you would need it on Linux) so all my files are towards the beginning of the hard drive, and then reduce the size of the partition at the end? Would the modified address space corrupt files?
Also what is the best location for a swap partition on a hdd (NOT a solid state drive)? The first few sectors, the last few, or somewhere in the middle? It's probably so slow that it doesn't matter, but I'm curious nonetheless. Where should swap space be located to reduce read/write times and increase the life of a hdd?
[solved] How do I make my home partition smaller to accomodate a swap partition?
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
[solved] How do I make my home partition smaller to accomodate a swap partition?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: How do I make my home partition smaller to accomodate a swap partition?
The best thing you can do to ensure that you don't lose any data is to back everything up to another drive. That said, I have resized drives many times without making a backup first, and I have never had any problems. (One of those "do as I say, not as I do" things.) There is no reason to defrag your home partition or to move anything on it. Boot from your install disc, and run gparted from there. Right click the partition you want to reduce, then click Resize/Move and fill in the details of what you want to do. After you have reduced the partition size, then format the space you have cleared up as swap.
“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan
Re: How do I make my home partition smaller to accomodate a swap partition?
Thanks for the quick reply! I already backed my data up, I'll give it a try. That said, do you know where I should start searching for answers to my more esoteric questions?
Re: How do I make my home partition smaller to accomodate a swap partition?
No, Linux file systems don't require defragging. If moving files is required, gparted will do that automatically. I have never worried about it, and never had any problems with it. I tell it to resize, and it does it. No, there will be no file corruption in the process.0x2620 wrote:Is it possible to reduce the distance in sectors between files and defragment (to the extent that you would need it on Linux) so all my files are towards the beginning of the hard drive, and then reduce the size of the partition at the end? Would the modified address space corrupt files?
I don't think it would matter much. Maybe it would reduce the long term average access time if you put swap in the middle of the drive, but I doubt it would make any noticeable difference.0x2620 wrote:Also what is the best location for a swap partition on a hdd (NOT a solid state drive)? The first few sectors, the last few, or somewhere in the middle? It's probably so slow that it doesn't matter, but I'm curious nonetheless. Where should swap space be located to reduce read/write times and increase the life of a hdd?
“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan
Re: How do I make my home partition smaller to accomodate a swap partition?
Thanks for taking the time to answer my questions!
Re: [solved] How do I make my home partition smaller to accomodate a swap partition?
My newly created swap partition won't stay on between reboots - I have to manually swapon in gparted every time (sudo swapon -a doesn't work for some reason).
After googling it I found this:
https://askubuntu.com/questions/194775/ ... ery-reboot
My /etc/fstab is
The swap isn't there, so I should do as one of the replies suggest:
After googling it I found this:
https://askubuntu.com/questions/194775/ ... ery-reboot
My /etc/fstab is
Code: Select all
# UNCONFIGURED FSTAB FOR BASE SYSTEM
proc /proc proc defaults 0 0
# /dev/sda1
UUID=53121269-bb63-4e50-98c4-f0e4f7c76ef0 / ext4 rw,errors=remount-ro 0 1
# /dev/sda2
UUID=e7068188-f24e-4a8d-ba97-f1b31ef088d8 /home ext4 rw,errors=remount-ro 0 0
Is this correct?You have no configuration for swap in /etc/fstab. Add following line to that file:
UUID=<uuid> none swap sw 0 0
You have to replace <uuid> with the uuid of your swap partition. To do that, run sudo blkid
$ sudo blkid
/dev/sda1: LABEL="System Reserved" UUID="88A0D0A1A0D09752" TYPE="ntfs"
/dev/sda2: UUID="0620D9F920D9EFA3" TYPE="ntfs"
/dev/sda5: UUID="c282b418-2045-4852-8789-88a44360a0bb" TYPE="ext4"
/dev/sda6: UUID="f99c6a0c-790a-45ca-a1a9-8874f5a2999b" TYPE="ext4"
/dev/sda7: UUID="4cc2e909-ebd1-4c72-abee-aa32035bf330" TYPE="swap"
This is a list of my partitions, and as you see, /dev/sda7 is my swap partition. So you can copy the value of UUID corresponding to your swap, omitting the quotes, and use it for your fstab file.
Re: [solved] How do I make my home partition smaller to accomodate a swap partition?
Well, that was going to be my guess, that your swap wasn't in the fstab file, since you hadn't specified a swap partition during install. I'm no fstab expert, but I have added drives/partitions to fstab several times in the past and it always worked when I was done! I have usually just entered the data called out in the line before the actual partitions start, and have probably used
You will of course want to enter the UUID that the blkid command gives you. You have to edit the file as root, save it, then reboot, and you should be good to go.
man fstab
in terminal a couple of times, too. Here's how swap appears in my fstab:Code: Select all
# swap was on /dev/sda5 during installation
UUID=xxxxxxxxxxxxxxxxxxxxxx none swap sw 0 0
“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan
Re: [solved] How do I make my home partition smaller to accomodate a swap partition?
For future reference, you used the complicated solution. The simple solution was to create a swap file:
https://help.ubuntu.com/community/SwapFaq
https://help.ubuntu.com/community/SwapFaq