LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-18-2024, 06:54 AM   #1
MST
LQ Newbie
 
Registered: Sep 2014
Posts: 20

Rep: Reputation: Disabled
LInux 8 extending partition root


Hello,

When I installed Oracle Linux 8 I was assigned 250GB and did not realize:

root partition 70GB
home partition 180GB

MYSQL runs on root partition and I wonder how can I expand. I know I can add extra storage and extend by merging: https://www.redhat.com/sysadmin/resize-lvm-simple

I wonder if there are:

- a way without adding extra storage
- a way to point MySQL database to pint to /home partition instead or /root partition.

Thank you
 
Old 03-18-2024, 06:58 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,855

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
yes, you need to move the database. I think it is just a directory, you can move it (first copy and remove the original if the new one is working). When you open a database you can specify the location. But anyway, would be nice to know more to give better help. (In general putting database onto the root filesystem is not a good idea).
 
Old 03-18-2024, 07:05 AM   #3
MST
LQ Newbie
 
Registered: Sep 2014
Posts: 20

Original Poster
Rep: Reputation: Disabled
Thank you for your quick reply.

I will fix that.

I will search for how to expand the root partition in a virtual machine.
 
Old 03-18-2024, 10:39 AM   #4
MST
LQ Newbie
 
Registered: Sep 2014
Posts: 20

Original Poster
Rep: Reputation: Disabled
Here are the steps for moving mysql data to another folder / partition:

yum install rsync

systemctl stop mysqld

rsync -av /var/lib/mysql /home/mysql

mv /var/lib/mysql /var/lib/mysql.bak

change data in /etc/my.cnf
datadir=/home/mysql
socket=/home/mysql/mysql.sock

ln -s /home/mysql/mysql.sock /var/lib/mysql/mysql.sock

service mysqld start

in mysql:
SELECT @@datadir;

show databases;

mysql -uroot -p -h 127.0.0.1 or:

mysql -uroot -p but create:

[client]

socket=/var/lib/mysql/mysql.sock

at final:
[root@whdnew mysql]# df /home/mysql
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/ol_whdnew-home 200303044 3813816 196489228 2% /home

mysql> select @@datadir;
+--------------+
| @@datadir |
+--------------+
| /home/mysql/ |
+--------------+
1 row in set (0.00 sec)
 
Old 03-18-2024, 10:49 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,855

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
yes, that looks almost perfect, just you can use the original socket /var/lib/mysql/mysql.sock, do not need to move it and/or link it. But you can use the new socket too.
 
Old 03-18-2024, 11:10 AM   #6
MST
LQ Newbie
 
Registered: Sep 2014
Posts: 20

Original Poster
Rep: Reputation: Disabled
yes with old socket I had:

mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)


and after I added:

[client]

socket=/new directory/mysql/mysql.sock

it fixed: mysql -u root -p and no more error poping out

I hope it helps others in need of moving MySQL from one partition to another
 
Old 03-18-2024, 12:26 PM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,662
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
And, if you need to expand space in a virtual machine ... I hope that you have LVM = Logical Volume Management installed, which is the usual default. [i](If not, you can install it.)

Then, you create a new virtual disk, add it to a "storage pool," then expand the "logical volume" using space from that pool. Finally, expand the filesystem to recognize the new space. (All of which you can do without downtime.) There are an abundance of online tutorials showing you exactly how the trick is done.
 
  


Reply

Tags
linux command, mysql, root partition



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Extending root partition on Fedora 26 hobz Fedora 6 05-01-2019 07:24 AM
extending volume group vs extending physical volume which is better ? Gil@LQ Linux - Server 2 08-19-2013 10:13 AM
Extending Red Hat Linux Partition (/root, /swap & /d01) without restarting (Urgent) umairnazim Red Hat 4 06-16-2011 03:00 PM
extending existing windows-partition and changing os on linux partition ungua General 8 05-05-2009 11:01 AM
Extending root partition sumit dash Linux - Hardware 1 12-05-2008 05:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration