How can I move extend space sda2 to sda3 with type ext4.

cropsoy

New Member
Joined
Aug 14, 2021
Messages
7
Reaction score
2
Credits
61
My Server: Oracle linux 8.

I only work on ssh root permission , can't control directly with virtual panel.

Currently my sda3 almost full, I want to move space from sda2 to sda3 as the image.

Please guide me how can I move space sda 2 to sda3.
 

Attachments

  • 1.jpg
    1.jpg
    62 KB · Views: 199
  • 2.jpg
    2.jpg
    25.7 KB · Views: 193


Everything I tell you here you perform at your own risk. Take a backup if this is an important system.

Two options are as follows, but could have some caveats if you're running SELinux or something similar.

If you want to continue to use /var and keep that space. You could create a new directory on / (say /var2) and migrate one or more directories inside var to this directory structure and then create a symbolic link in /var to the new directory structure. For instance. Say your /var/log/httpd directory is huge and you would like to move it.

You create the following directory on the root partition. (/)
/var2/log/

Then you shutdown Apache and move /var/log/httpd to /var2/log/httpd.
Then you would create a symbolic link from /var/log/httpd -> /var2/log/httpd

Ensure the ownership is the same so Apache doesn't have issues writing to this directory. THe other possibly issue is if you have SELinux running, SELinux might not like this change and you will need to configure your SELinux to allow Apache to log to /var2/log/httpd directory.

The other option copy the entire /var filesystem to the root filesystem as /var2. Unmount /var and remove it from the /etc/fstab. Then rename /var2 to /var.

You basically migrate /var to the root filesystem and get rid of the old partition. Again, SELinux might have an issue with this, but you could fix it. The other downside of this option is you lose the free space you currently have on /var.

Though you could repurposes it as another drive. Or if you had used volume groups (LVM) you could have added that space back to the root filesystem.

No matter what you do. You should backup things if possible just in case things go south. That is a cardinal rule in IT. Always have a backup before taking actions that has the potential to be distructive.

Good luck,
Dave
 
Hi @dcbrown73,

Thanks for your helps,

I was follow option copy the entire /var filesystem to the root filesystem as /var2. Unmount /var and remove it from the /etc/fstab. Then rename /var2 to /var. But ater I reset server, I can't continue ssh to server.
My step I took:
- disable httpd.
- copy /var to root filesystem as /var2
- umount -l /dev/sda3
- remove sda3 from the /etc/fstab as the image I was deleted line "UUID=c3671d78-f99b-46cd-beb8-cf1fdebc6405 /var "
- delete /var and rename /var2 to /var
- enable httpd and restart server, but I can't ssh to server and httpd problem as the image.

Can you guide me more detail @dcbrown73!

PS: I made it on test server the same with real server.
 

Attachments

  • 3.jpg
    3.jpg
    46.5 KB · Views: 190
  • 4.PNG
    4.PNG
    24.2 KB · Views: 187
Hi @dcbrown73,

With option 1:
My step I took:
- create /var2
- stop httpd and cp /var/www to /var2/www
- in "/var/www" I run comand ln -s /var2/www
- change etc/httpd/conf.d/myweb.conf (myweb.conf is file config directory my website) to /var2/www/myweb.
- chown -R apache:apache /var2/www/myweb
- chmod -R 755 /var2/www/myweb
- And restart httpd but it notworking.
How do I need to config SElinux allow apache log to /varw/www/myweb?

Please guide me more detail or can I get in touch directly with you?

Thank you very much!

PS: I made it on test server the same with real server
 

Attachments

  • 4.PNG
    4.PNG
    24.2 KB · Views: 178
I cannot see the entire error message, but it looks like it cannot read your Apache configuration within /etc which is not part of /var. Whatever is causing that either a) isn't part of the changes I suggested, b) was an existing issue, or c) the issue appears as a part of the cloning process or whatever you did to make a duplicate *test* server.

Either way, we need to see the entire log file to determine the actual nature of the error.

btw, I wouldn't physically *delete* the line in your fstab, I would only comment it out until you have everything working.

Lets check selinux status by running the command "getenforce". Can you tell me what it says when you run that command?
 
I cannot see the entire error message, but it looks like it cannot read your Apache configuration within /etc which is not part of /var. Whatever is causing that either a) isn't part of the changes I suggested, b) was an existing issue, or c) the issue appears as a part of the cloning process or whatever you did to make a duplicate *test* server.

Either way, we need to see the entire log file to determine the actual nature of the error.

btw, I wouldn't physically *delete* the line in your fstab, I would only comment it out until you have everything working.

Lets check selinux status by running the command "getenforce". Can you tell me what it says when you run that command?

Selinux status is Enforcing.
 

Attachments

  • 9.PNG
    9.PNG
    2.6 KB · Views: 163
Lets quickly test if selinux is in fact your issue. Run "setenforce 0" and try to restart Apache.
 
Lets quickly test if selinux is in fact your issue. Run "setenforce 0" and try to restart Apache.

Thanks for your helps,

My httpd was worked and I can ssh to server when I disable Selinux but it raises problem with my mariadb and my website announcements like the images attach.

My step I took:
- disable httpd.
- copy /var to root filesystem as /var2
- umount -l /dev/sda3
- remove sda3 from the /etc/fstab
- delete /var and rename /var2 to /var
- Disable SElinux (/etc/selinux/config)
- sudo chown -R apache:apache /var/www/myweb
- sudo chmod -R 755 /var/www/myweb
- enable httpd and restart server

I think I'm missing the permissions for the new /var folder, right? please guide me!

PS: I made it on test server the same with real server.
 

Attachments

  • 1.PNG
    1.PNG
    5.4 KB · Views: 166
  • 2.PNG
    2.PNG
    7.1 KB · Views: 170
Thanks for your helps,

My httpd was worked and I can ssh to server when I disable Selinux but it raises problem with my mariadb and my website announcements like the images attach.

My step I took:
- disable httpd.
- copy /var to root filesystem as /var2
- umount -l /dev/sda3
- remove sda3 from the /etc/fstab
- delete /var and rename /var2 to /var
- Disable SElinux (/etc/selinux/config)
- sudo chown -R apache:apache /var/www/myweb
- sudo chmod -R 755 /var/www/myweb
- enable httpd and restart server

I think I'm missing the permissions for the new /var folder, right? please guide me!

PS: I made it on test server the same with real server.

Thank you so much @dcbrown73

Finally everything working well (because I missing the permissions for the new /var folder), but my website warning security because Selinux was disabled.
How can I enable SElinux again but my system still work well?
Please guide me made that.
 

Attachments

  • 8.PNG
    8.PNG
    2.9 KB · Views: 170
What distribution are you using? Is it a Redhat derivative? Selinux is not my strong suit. I can normally get it done, but it takes some figuring out.

The reason I ask about your distribution is there are tools out there that can read your error messages and create policies for selinux that match the error selinux is going you.
 
If you want to correctly relabel your system you just have to do the following.
Code:
sudo touch /.autorelabel
Then reboot and your system would relabel all the selinux contexts automatically and then you should be able to set it to enforcing again. Keep in mind that selinux has to be in enforcing or permissive mode to do this, so not on disabled.
 
If you want to correctly relabel your system you just have to do the following.
Code:
sudo touch /.autorelabel
Then reboot and your system would relabel all the selinux contexts automatically and then you should be able to set it to enforcing again. Keep in mind that selinux has to be in enforcing or permissive mode to do this, so not on disabled.
Nice, that's good to know!
 
If you want to correctly relabel your system you just have to do the following.
Code:
sudo touch /.autorelabel
Then reboot and your system would relabel all the selinux contexts automatically and then you should be able to set it to enforcing again. Keep in mind that selinux has to be in enforcing or permissive mode to do this, so not on disabled.
Thanks for your support!
Everything was worked well.
 

Staff online

Members online


Top