Welcome to Centmin Mod Community
Become a Member

Sysadmin Partitions - how should be created?

Discussion in 'System Administration' started by adamus007p, Apr 25, 2020.

  1. adamus007p

    adamus007p Member

    238
    14
    18
    Feb 8, 2019
    Ratings:
    +24
    Local Time:
    9:41 AM
    Hello @eva2000

    I read in Centmin Mod LEMP Stack Install Nginx on CentOS

    What about swap partition or boot partition?


    Should I create any swap?

    1. VPS which has 3GB RAM
    2. VPS which has 16GB RAM


    Where and why or not it should be used?
     
  2. eva2000

    eva2000 Administrator Staff Member

    44,424
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,693
    Local Time:
    5:41 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Centmin Mod 123.09beta01 installer will detect if there is no swap file and create one depending on the size of memory available/disk available. Or you can create one yourself. You should always have a swap file just in case you do run out of memory for whatever reason, I usually have a swap file same size as memory installed up to 4-8GB if disk space is available.
     
  3. adamus007p

    adamus007p Member

    238
    14
    18
    Feb 8, 2019
    Ratings:
    +24
    Local Time:
    9:41 AM
    Swap file or partition? is there any difference?


    Is it worth to create a boot partition?
     
    Last edited: Apr 25, 2020
  4. eva2000

    eva2000 Administrator Staff Member

    44,424
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,693
    Local Time:
    5:41 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    swap file is a bit more flexible to change the size while partitions wouldn't be if you want to change sizes. If you are sure on your swap disk space usage requirements, then partition/bootable would fine. Though it wouldn't matter much if you adequately and accurately choose the right amount of memory installed on server so you never need to hit swap disk space.
     
  5. adamus007p

    adamus007p Member

    238
    14
    18
    Feb 8, 2019
    Ratings:
    +24
    Local Time:
    9:41 AM
    Thank you so much your your answer.
    I did not think about flexibility.

    PS. I was thinking why mostly OS template look like one big partition.
    Now I know :)


    What about to choose standard partition or lvm?
     
  6. eva2000

    eva2000 Administrator Staff Member

    44,424
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,693
    Local Time:
    5:41 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    For most VPS wouldn't matter much as to whether LVM is used as you don't get to customise what you're given to that degree and well would you know how to manage LVM partitions https://www.howtogeek.com/howto/40702/how-to-manage-and-use-lvm-logical-volume-management-in-ubuntu/ ? For dedicated servers maybe a different matter.

    If you want a bit more control over VPS partitioning then Linode.com VPS servers would when you reload the VPS and customise your disk partitioning. See Disks and Configuration Profiles
     
  7. adamus007p

    adamus007p Member

    238
    14
    18
    Feb 8, 2019
    Ratings:
    +24
    Local Time:
    9:41 AM
    How to create a swap file ?

    By default 1GB swap file. How to create a 4GB swap file?


    My new installation stuck on

    Set cache size limit to 2.5 GB

    Download nginx-1.17.10.tar.gz ...
     
  8. adamus007p

    adamus007p Member

    238
    14
    18
    Feb 8, 2019
    Ratings:
    +24
    Local Time:
    9:41 AM
    Code (Text):
    dd if=/dev/zero of=/swapfile bs=4096 count=1024k
    ls -lah /swapfile
    mkswap /swapfile
    swapon /swapfile
    chown root:root /swapfile
    chmod 0600 /swapfile
    swapon -s
    echo "/swapfile          swap            swap    defaults        0 0" >> /etc/fstab
    mount -a


    is it correct?


    how should look for 4GB file?
    bs=4096 count=1024k

    or
    Code (Text):
    sudo dd if=/dev/zero of=/swapfile count=4096 bs=1MiB




    2. How to resize created file?
     
    Last edited: May 5, 2020
  9. eva2000

    eva2000 Administrator Staff Member

    44,424
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,693
    Local Time:
    5:41 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Then it might not be swap but network connection to nginx download server

    But yes for resizing swap similar to Vultr - is swap file important?. IF you do not have existing swap file. But if you already have swap file some steps can be skipped and you need to disable swap first.

    Check if you have enough disk free space at / partition first otherwise 4GB swap file might not be advisable - here there's 40GB disk free space available at / so 4GB swap file will reduce / disk free space to 40-4=36GB
    Code (Text):
    df -hT
    Filesystem     Type      Size  Used Avail Use% Mounted on
    devtmpfs       devtmpfs  1.9G     0  1.9G   0% /dev
    tmpfs          tmpfs     1.9G     0  1.9G   0% /dev/shm
    tmpfs          tmpfs     1.9G  193M  1.7G  11% /run
    tmpfs          tmpfs     1.9G     0  1.9G   0% /sys/fs/cgroup
    /dev/vda1      ext4       60G   17G   40G  30% /
    /dev/loop0     ext4      5.8G   25M  5.5G   1% /tmp
    tmpfs          tmpfs     379M     0  379M   0% /run/user/0
    


    Resize existing swap created by Centmin Mod LEMP stack
    Code (Text):
    # disable swap
    swapoff /swapfile
    dd if=/dev/zero of=/swapfile bs=1024 count=4096k
    ls -lah /swapfile
    mkswap /swapfile
    swapon /swapfile
    chown root:root /swapfile
    chmod 0600 /swapfile
    swapon -s
    # skip /etc/fstab setup as already exists
    #echo "/swapfile          swap            swap    defaults        0 0" >> /etc/fstab
    mount -a
    free -mlt
    

    check if /swapfile exists in /etc/fstab
    Code (Text):
    grep swapfile /etc/fstab
    

    if already exists grep will return output if not exist will return to prompt empty
    Code (Text):
    grep swapfile /etc/fstab
    /swapfile swap swap defaults 0 0
    

    Code (Text):
    free -mlt
                  total        used        free      shared  buff/cache   available
    Mem:           3789        1003         166         192        2619        2318
    Low:           3789        3623         166
    High:             0           0           0
    Swap:          4095           0        4095
    Total:         7885        1003        4262