Monday, 6 June 2011

Add new partitions, logical volumes and swap to a system non-destructively

This objective is really more of the same as this and this. The only new part is the adding of swap space.
Again, this can be done with fdisk and parted. Let's have a look at fdisk first.

Assuming that you have device available on /dev/sdc and you want to use it all
  1.  fdisk /dev/sdc
  2. Type p
  3. Type 1
  4.  Hit enter twice
  5. Type t
  6. Type 82
  7. Type w
We now need to make it a swap partition

mkswap /dev/sdc1

and now we can activate with

swapon /dev/sdc1

You can check it with

swapon -s
Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       2047992 0       -1
/dev/sdc1                               partition       1044184 0       -2
Now we need to add it to the /etc/fstab file, which can be done with the following command:

echo "/dev/sdc1 swap swap defaults 0 0" >> /etc/fstab

No comments:

Post a Comment