increase hard disk of Linux OS when many customers work with website, stressful mission
when a customer increase in the website suddenly faces of limitation of hard disk, in this time increasing hard drive is very stressful. even you’re best in your work but increase hard disk when lot’s of customers working on the website is the biggest stressful in DevOps.
stay with me to increase your hard disk. Hamid Rohani is helping me to do my mission possible.
login with ssh to your server
ssh user@ip
hard disk usage of server
df -h
as you have seen /dev/sda2 is using 83 percent of my hard disk and i want to increase this value.
using Tmux if it’s possible
because of don’t lose my connection I using Tmux to save sate of my working
tmux new -s increasehard
don’t forget that if your hard is completed fully and you have 100 percent of usage you can’t using Tmux or even you can’t using ls command!
error creating /tmp//tmux-1000 (No space left on device)
turn off Swap
be careful it’s very important to turn off swap
sudo swapoff -a
using command htop to insure your swap not working.
what’s up going on our hard
using command lsblk — list block devices. this command show exactly what’s going on your hard disk
lsblk
looking at sda size . I have 1000G hard in my sda and I’m using 250 G in sda2.
be careful if sda size is not equal to sda2 size reboot your server at right time. and if still not equal after reboot, this method is not working on your server and try a different way.
and now make mission possible
using below command to change hard.
sudo fdisk /dev/sda
red lines say that your hard is using 250 G but all your hard disk is 1000G.
now we using a command to increase hard disk when customers using our website.
p
command p is showing us the status block of sda status. sda2 starts from 4096 and ends with 524287966. we want to increase the value of the end sector to 1000G.
GPT PMBR size mismatch (524287999 != 2097151999) will be corrected by write.
we understand from the red line hint that the end of our file is 2097151999.
d
now this part is very important. delete partition !!
partition 2 is /dev/sda2
it’s not actually deleted sda2 yet.
p
again see the status of blocks. sda2 is format virtually ( not happen yet).
n
increase value of blocks sda2.
question one is saying that you want using sda1 or sda2 and press Enter to choosing sda2.
question two asking about the start block of sdb2 and it’s 4096.
the third question is about the end block and I using default value so press Enter.
the fourth question I don’t know the answer and ask @hamid rohani so Press N :).
p
status of the block.
Saving
press w.
command w is saveing every changing. if you don’t want to save and write disk don’t press w and exit the command program.
check status
sudo fdisk -l /dev/sda
finish it
sudo partprobe
Without reboot, reboot partition.
now check out hard status
lsblk
df -h
resize hard using in sda2
sudo resize2fs /dev/sda2
increase number of the block sda2
check again hard
it’s work :))
turn on swap
sudo swapon -a