You are not logged in.

#1 2012-11-09 23:02:11

Draucia
Member
Registered: 2011-06-05
Posts: 128

Switch /Var partition and /home [Stupid mistake]

Hi, I'm a returning arch user. When I was installing arch linux, I don't know what I did, but I somehow switched my /var and /home partiton. So right now I have a /var partition that is 80GB and a /home partition that is 15GB. Is there some way to switch these two partitions? As in install /var on my current /home partition and /home on my current /var partition? I'd hate to reinstall arch, I just set up everything as I wanted it. sad

Disk /dev/sda: 500.1 GB, 500107862016 bytes, 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc34542a0

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048      206847      102400    7  HPFS/NTFS/exFAT
/dev/sda2   *      206848   745768457   372780805    7  HPFS/NTFS/exFAT
/dev/sda3       745768960   976773119   115502080    5  Extended
/dev/sda5       745771008   746180607      204800   83  Linux
/dev/sda6       746182656   797382655    25600000   83  Linux
/dev/sda7       828106752   976773119    74333184   83  Linux
/dev/sda8       797384704   828104703    15360000   83  Linux

Partition table entries are not in disk order

Offline

#2 2012-11-09 23:25:51

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,804

Re: Switch /Var partition and /home [Stupid mistake]

Will everything fit on the 80GB partition?
If so, login as root.
Unmount the home volume
Mount the home partition somewhere else on /  (like /mnt)
use 'cp -a /mnt/* /home' to copy the stuff that had been on the home volume to the home directory on /
Unmount the home volume.
Make certain all of the files from the home volume are safe on /home/.  Double check this.
Format the home volume.
mount the the newly mounted volume on /mnt
use 'cp -a' to copy everything from / except /home to /mnt
create an empty  /mnt/home directory  <--- edit: added this step
change the /etc/fstab to ensure that the newly formated volume mounts on /, and that what is now / mounts on /home in the future
Change your boot loader to point to the newly formated volume rather than where it now points (which, in the future will be /home)
Say a little Prayer.  Reboot.
Log in as root.
Verify that the new home partition is mounted at home.  If so, the entire old file system will be living under /home.
Clean up / home by removing everything from /home except home (the old /home) and lost+found.
Move everything from /home/home to /home.

YMMV.

Last edited by ewaller (2012-11-09 23:28:08)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2012-11-09 23:59:52

Draucia
Member
Registered: 2011-06-05
Posts: 128

Re: Switch /Var partition and /home [Stupid mistake]

ewaller wrote:

Will everything fit on the 80GB partition?
If so, login as root.
Unmount the home volume
Mount the home partition somewhere else on /  (like /mnt)
use 'cp -a /mnt/* /home' to copy the stuff that had been on the home volume to the home directory on /
Unmount the home volume.
Make certain all of the files from the home volume are safe on /home/.  Double check this.
Format the home volume.
mount the the newly mounted volume on /mnt
use 'cp -a' to copy everything from / except /home to /mnt
create an empty  /mnt/home directory  <--- edit: added this step
change the /etc/fstab to ensure that the newly formated volume mounts on /, and that what is now / mounts on /home in the future
Change your boot loader to point to the newly formated volume rather than where it now points (which, in the future will be /home)
Say a little Prayer.  Reboot.
Log in as root.
Verify that the new home partition is mounted at home.  If so, the entire old file system will be living under /home.
Clean up / home by removing everything from /home except home (the old /home) and lost+found.
Move everything from /home/home to /home.

YMMV.

Thank you so much for the instructions. I just want to make sure we have my partition scheme clear:

/dev/sda1 and /dev/sda2 are for windows

/dev/sda3 is an extended partiton for my arch linux install
        /dev/sda5 is mounted at /boot with 200MB
        /dev/sda6 is mounted at / with 25GB
        /dev/sda8 is mounted at /home with 15GB
        /dev/sda7 is mounted at /var with 70GB

I should of included this, I have nothing on my current /home partition (/dev/sda8) that I care about (besides a few files I while move to my windows partition temporarily). So could I skip up to the "Format the home volume" step? Can you tell me if this is right from there?

mkfs.ext4 /dev/sda8 -- this is my current /home partition, which is 15GB
vi /etc/fstab: and make /dev/sda8 (15GB, which was previously mounted on /home) mount on /var    *Also, I think you mean /var, right? I have a seperate root partition (/dev/sda6) that is 25GB.
and make /dev/sda7 (70GB, previously mounted on /var) mount on /home.
and I don't have to change my boot loader since it was on it's own seperate /boot partition, right? Right now it just says: set root='hd0,msdos5'

But what about my /dev/sda7? It has my /var files. Would I first copy all the files /dev/sda7 (mounted at /var) to a temporary folder in /mnt, format /dev/sda7, then change the fstab file? Sorry if this is really confusing (it is even for me), but your help is greatly appreciated. Thanks.

Last edited by Draucia (2012-11-10 00:00:34)

Offline

#4 2012-11-10 00:20:06

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,804

Re: Switch /Var partition and /home [Stupid mistake]

Okay, sorry.  I misread your first post.  I thought you had swapped / and /home.

This is easier. 
From a running system, do a cp -a /var /home
Fix /etc/fstab to swap the var and home partitions
reboot
log in as root
look in /var.  There should be a directory in there for each of your users.  Move them to /home.  Remove everything else from /home


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB