Virtual machine high performance compute cluster

@saoussen5765 @hydn @ivansalloum @Don11 there have many questions asked about the virtual machine setup and how to do that. I was configuring a new virtual machine on the system that i am working for the installation of the vagrant and setting up the corresponding, so i wrote this down quickly so that it will help all.

 # Installing the packages required for the setting up of the disk to the VM
$ sudo apt-get install lvm 
$ sudo apt-get install lvm

# Formatting the disk and enabling it for the attachment 
$ sudo fdisk /dev/sda
# After formatting the disk partition information can be retrieved by 
$ sudo partprobe

### creating a physical drive 
$ sudo pvcreate /dev/vdb
$ sudo pvcreate /dev/vdb
$ sudo pvs or pvsdisplay # checking the creating physical drive

### creating a volume group 
$ sudo vgcreate storage /dev/vdb /dev/vdc

### creating a lvm 
$ sudo lvcreate -n storage_lvm -l 100%FREE dba_storage #(-l defines the size of the volume to be created, you can define 10G to create a VM of 10G)
$ sudo lvcreate -n storage2_lvm --size 10G #(creating an lvm with a specific size)
$ sudo lvs or lvsdisplay # checking the created lvm

### formatting the file system: formatting using the ext3 or the xfs
mkfs.ext3 /dev/storage/dev/storage_lvm
mkfs.xfs /dev/storage/dev/storage_lvm

### creating a group
$ sudo groupadd system_users 

#### adding a user to the group 
$ sudo usermod -a -G system_users user

#### formatting and binding the partition to the mount point 
$ lsblk --fs dba_storage
create a mount point 
mkdir --parents mount-point
#creating an user in the linux environment after the disk installation and mounting 

$ sudo useradd gaurav # adding a user without the home directory 
$ sudo useradd -m gaurav # adding a user with the home directory 
$ sudo passwd gaurav # assigning a password to the user
$ sudo useradd -m gaurav -p passwd  # passing all the arguments in one line
$ sudo usermod -L gaurav # locking the user
$ sudo groupadd group # adding a group to the created lvm 
$ sudo usermod -a -G gaurav group # adding gaurav t

alles super,
Gaurav

1 Like

I think it depends from the size of the machine. The recommanded size could differ from one machine to another.
sudo lvcreate -n storage2_lvm --size auto
Will be better for the creation for lvm with a size and then machine will choose the adequate size depending on your gadget.
Also you could start your code with

sudo su

So no many sudo command line repetition over the code. This is my point of view only.

Although it’s practical to use sudo su, I would recommend against it in this case as there are plenty of commands that should not be run as superuser. For best practice, I would stick to just using sudo before the commands that have to be run as superuser.

1 Like

@saoussen5765 @andreas thank you for the comment. If you are doing the installation as a super user then you can use the

$ sudo su -

one time and that would be enough. The meaning of adding the same in each of the command that requires administrative privileges is to show that you need the system wide administrative privileges for the same.

Alles super,
Gaurav

1 Like

It is possible to run a terminal as sudo user. In the same time you run another terminal as a normal user. It could be even done with VSCode to run more than one terminal for example. So if you have commands that are for normal user you did not always quit sudo user and be back later to sudo user. This is one from the best user practice.

@saoussen5765 you dont do that and that is usually not recommended and what you have mentioned is not correct. If you are handling the clusters and the server instances on the cloud and the service provider then you add them to the

$ ~/.ssh/known_hosts 

by generating a key such as

$ssh-keygen -t 
ssh-add key.pub

you dont do that that run one sudo in one terminal and run the other terminal. You add the key to the known hosts as that prevents the ssh terminal log to the server route. Many instance providers consider this a bak injection method if they see that you are logging into the multiple terminals without providing a key.

Alles super,
Gaurav

1 Like