LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-21-2013, 06:56 AM   #1
blugg
LQ Newbie
 
Registered: Dec 2013
Posts: 2

Rep: Reputation: Disabled
How can I "merge" partitions?


I have a dedicated server that has a 500GB hard disk (a Kimsufi from OVH to be specific), and during OS installation I was given the option to resize partitions. I left it at the default (20GB for /, the rest for /home), which is a mistake I only just realized.

Here is my df -h output:

Code:
Filesystem      Size  Used Avail Use% Mounted on
rootfs           20G  8.3G  9.9G  46% /
/dev/root        20G  8.3G  9.9G  46% /
devtmpfs        987M     0  987M   0% /dev
tmpfs           198M  300K  198M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           498M     0  498M   0% /dev/shm
/dev/sda2       439G  160G  257G  39% /home
I'm running a database server which keeps its data in /var, and is quickly filling up. I want to "merge" all partitions so that all free space is shared, if that makes sense. My desired filesystem would look something like this:

Code:
Filesystem      Size  Used Avail Use% Mounted on
rootfs          459G  168G  267G  ??% /
/dev/root       459G  168G  267G  ??% /
devtmpfs        987M     0  987M   0% /dev
tmpfs           198M  300K  198M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           498M     0  498M   0% /dev/shm
Is it possible to do this without losing data? Using a rescue CD to manage the hard drive, what would I need to do in order to do what I want?

Edit: Here's fdisk -l if it matters:

Code:
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000121c8

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        4096    40962047    20478976   83  Linux
/dev/sda2        40962048   975718399   467378176   83  Linux
/dev/sda3       975718400   976764927      523264   82  Linux swap / Solaris

Last edited by blugg; 12-21-2013 at 07:15 AM. Reason: added fdisk output
 
Old 12-21-2013, 08:16 AM   #2
gdejonge
Member
 
Registered: Aug 2010
Location: Netherlands
Distribution: Kubuntu, Debian, Suse, Slackware
Posts: 317

Rep: Reputation: 73
Two simple options come to mind:
1. Backup your system (which you should do anyway), reinstall with the correct partitions. Restore the data.
2. Create a new directory at /home/<database>. Move all your data from the database directory to the newly created one. Replace the old directory with a symbolic link to the new one.

Cheers
 
Old 12-21-2013, 08:21 AM   #3
blugg
LQ Newbie
 
Registered: Dec 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by gdejonge View Post
Two simple options come to mind:
1. Backup your system (which you should do anyway), reinstall with the correct partitions. Restore the data.
2. Create a new directory at /home/<database>. Move all your data from the database directory to the newly created one. Replace the old directory with a symbolic link to the new one.

Cheers
The first option is not viable in my circumstances.

The second may work, though I'm not sure how nice MySQL will play with that.

I'd really prefer doing something with the partitions, but whether that's possible or not without losing data, I don't know.
 
Old 12-21-2013, 08:43 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,729

Rep: Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919Reputation: 5919
Merging would require you to boot from a live CD. You can use gparted to resize the partitions/filesystems. Copy /home to some backup or external drive, delete sda2 and then resize /. Copy /home data back.

Another option would be to shrink home (sda2) and then create a partition just for /var, format the new partition, copy var data to the new partition, update /etc/fstab to mount /var, delete the old var data from the / partition. It would be best to run from a live CD.

Make sure you have a good backup just in case some thing goes astray.
 
Old 12-21-2013, 11:08 AM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,780

Rep: Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213Reputation: 2213
A third option would be to combine /var and /home into one filesystem. I actually do that on my desktop. Within /var I have /var/home, and /var/home is then bind-mounted on /home.
Code:
/var/home       /home           none    bind           0 0
You might also consider moving your database to a separate filesystem. The FHS suggests /srv as a mount point for that ("Data for services provided by this system").

Last edited by rknichols; 12-21-2013 at 11:21 AM. Reason: Add /srv suggestion
 
Old 12-21-2013, 03:53 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,131

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
As suggested, gparted liveCD is the answer.
I'd simply shrink sda2, expand sda1 - that'll give you 250-odd Gig straight away. If you think /home is going to continually grow, remount it at some arbitrary mount-point, and copy it to the /home under the root on sda1. Delete the entry for /home in fstab and reboot just to make sure things are where they should be. Then you can reboot the gparted to delete sda2 and expand sda1.

Leave the sda3 - swap - alone; nothing to be gained by trying to incorporate that as a swap file.
 
  


Reply



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
[SOLVED] "\usr merge script failed" during preupgrade from f16 ro f17 gkasica Fedora 1 07-19-2012 02:18 PM
LXer: Linux 3.3 Kernel Has A Big, "Pretty Good" Staging Merge LXer Syndicated Linux News 0 01-10-2012 11:20 PM
I need the java toolkit and "tool.pdf.Merge" for Debian Lenny Cyberman Programming 0 07-04-2009 11:54 AM
javascript merge "if confirm" with "submit" rblampain Linux - Software 6 09-18-2005 10:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:52 AM.

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