SIMULATION -
Create a 2G swap partition which take effect automatically at boot-start, and it should not affect the original swap partition.
SIMULATION -
Create a 2G swap partition which take effect automatically at boot-start, and it should not affect the original swap partition.
To create a 2G swap partition that takes effect automatically at boot and does not affect the original swap partition, follow these steps: 1. Use 'fdisk /dev/sdX' to create the new partition, where /dev/sdX is your disk identifier. 2. Create a new partition by typing 'n', select 'p' for primary, and specify '+2G' for the size. 3. Change the partition type to Linux swap by typing 't' and then '82'. 4. Write the changes using 'w' and refresh the partition table with 'partprobe' or 'partx -a /dev/sdX'. 5. Create the swap space using 'mkswap /dev/sdXn', where 'n' is the partition number. 6. Copy the UUID of the new swap partition using 'blkid /dev/sdXn'. 7. Edit the /etc/fstab file and add the new swap partition with its UUID in the format: 'UUID=xxxxxxxxxxxx swap swap defaults 0 0'. 8. Activate the swap space using 'swapon -a'. To check if the swap space has increased, use 'free -h' command.
create a partition for given size(2G) #fdisk /dev/sdb #n #+2G #w #partprobe check the present free memory #free -h #mkswap /dev/sdb5 #swapon /dev/sdb5 check the swap space and compai with privious value #free -h exit /etc/fstab and add below line /dev/sdb5 swap swap defaults 0 0 wright and exit /etc fstab # swapon -a
lsblk #to check partition fdisk /dev/sdb #to sda or sdb depending on the disk n # for new p #primary 1 #default partition number enter #first sector +2G #last sector t #to change type and select 82 for swap 82 #code for hex w #save changes partprobe #to update partition table lsblk #to confirm mkswap /dev/sbd1 #to generate UUID, we need UUID to make it permanent lsblk -f #to see file system, should be swap vi /etc/fstab #to make it permanent UUID=xxxxxxxxxxxx swap swap defaults 0 0 free -h swapon -a free -h #swap value must be increased by 2G
man fstab says that the second field should be none, not swap. UUID=234wfd none swap defaults 0 0
first check available swap #free -m second partions available #lsblk #parted -s /dev/vdb mklabel msdos #parted -s /dev/vdb mkpart primary 2048S 2200MB #mkswap /dev/vdb1 #vim /etc/fstab /dev/vdb1 swap swap defaults 0 0 #swapon -a
#lsblk #free -h #mkswap /dev/sdb #swapon /dev/sdb #free -h #vim /etc/fstab #/dev/sdb swap defaults 0 0
if sdb it's more than 2G you have to use fstab
if it is a swap partition the appropriate partition type (Linux swap) must be set -> t (use l to get a list of known partition types) -> 82
echo $(blkid /dev/sdb5) >> /etc/fstab use this command to copy uid to fstab.
blkid is a good comand to know partition UUID but with your command literally the swap partition dont start at boot time