Move /home to it’s own partition January 29, 2006
Posted by Carthik in administration, guides, ubuntu.trackback
Having the “/home” directory tree on it’s own partition has several advantages, the biggest perhaps being that you can reinstall the OS (or even a different distro of Linux) without losing all your data. You can do this by keeping the /home partition unchanged and reinstalling the OS which goes in the “/” (root) directory, which can be on a seperate partition.
But you, like me, did not know this when you first installed Ubuntu, and have not created a new partition for “/home” when you first installed Ubuntu. Despair not, it is really simple to move “/home” to its own partition.
First, create a partition of sufficient size for your “/home” directory. You may have to use that new hard drive, or adjust/resize the existing partition on your current hard-drive to do this. Let me skip those details.
Next, mount the new partition:
$mkdir /mnt/newhome
$sudo mount -t ext3 /dev/hda5 /mnt/newhome
(You have to change the “hda5″ in the above to the correct partition label for the new partition. Also, the above assumes that the new partition you created is formatted as an ext3 partition. Change the “ext3″ to whatever filesystem the drive is formatted to.)
Now, Copy files over:
Since the “/home” directory will have hardlinks, softlinks, files and nested directories, a regular copy (cp) may not do the job completely. Therefore, we use something we learn from the Debian archiving guide:
$cd /home/
$find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome/
Make sure everything copied over correctly. You might have to do some tweaking and honing to make sure you get it all right, just in case.
Next, unmount the new partition:
$sudo umount /mnt/newhome
Make way for the new “home”
$sudo mv /home /old_home
Since we moved /home to /old_home, there is no longer a /home directory. So first we should recreate a new /home by:
sudo mkdir /home
Mount the new home:
$sudo mount /dev/hda5 /home
(Again, you have to change “hda5″ to whatever the new partition’s label is.)
Cursorily verify that everything works right.
Now, you have to tell Ubuntu to mount your new home when you boot. Add a line to the “/etc/fstab” file that looks like the following:
/dev/hda5 /home ext3 nodev,nosuid 0 2
(Here, change the partition label “hda5″ to the label of the new partition, and you may have to change “ext3″ to whatever filesystem you chose for your new “home”)
Once all this is done, and everything works fine, you can delete the “/old_home” directory by using:
$sudo rm -r /old_home
Michael, Russ and Magnus posted this solution on the ubuntu-users mailing list a few months ago.
Digg This!






Move the home directory to a separate partition
If you want to move your home directory to a separate partition check out the Ubuntu Blog » Move /home to it’s own partition. It’s no big deal to do the move if you still have your home directory on the same partition as your system.
Keep in mind, this is somewhat risky… messing with fstab can be dangerous, so double check for typos
I eventually figured out that /opt is a great directory to make a separate partition also. Most of the stuff that gets installed in /opt (Adobe Acrobat, Crossover Office, Cedega, etc) is statically compiled and should work with any version of any distro, so when you upgrade or decide to try another distro, these packages (that oh-by-the-way probably aren’t shipped with your distro) will still be intact. Since I have /opt handy for that purpose, I also move the fake-windows directories created by cxoffice and Cedega there, and make symlinks in my home directory. That way I don’t have to reinstall my Windows software when I upgrade either.
Two items: first a typo in the line:
$sudo mount /dev/hda5 /ment/newhome
“ment” should read “mnt”
Second, as I recall, you can use the Ubuntu install disk (with caution!) to manage partitions, including resizing, copying, etc. Duplicating a partition this way would guarantee an exact bit-for-bit copy
Nice blog here man i’m ubuntu user and find your stuff quite effective
Yes, great blog, thanks. My comment is that it would be helpful if you would expand, “You might have to do some tweaking and honing to make sure you get it all right, just in case.” to at least explain the essence of what we’d be tweaking and honing.
Chuck,
What I meant by that was that you might want to manually check for the presence of important files, make sure that all the files that matter to you got copied without errors etc.
Links, if any that point to things in /home/* will not work until you are done entirely with the moving-over process.
When copying things, it is always good to be careful, and check, and double-check to see if anything is missing, and there is no tool which will do this.
You can, however use tools like du (to measure the diskspace used) on the copy and the original to compare the sizes to see if everything copied over fine.
Nothing to worry - all I meant was that you may want to come up with more imaginative ways to copy a directory tree and verify it - but the method I mentioned would work just fine. Just that I can’t vouch for it on all the computers, for all users, since I don’t know the past history of those systems — maybe the users have done some wierd customization that they need to account for. You know - the super-geeks and so on
i just installed gentoo alongwith ubuntu(a triple boot system with windows)…and i would like to be working with the same /home in both linux-es..is it possible to mount /home from ubuntu partition into my gentoo partition?
[...] Ubuntu Blog » Move /home to it’s own partition (tags: linux ubuntu) [...]
I’m quite glad I found this guide, I followed it and everything works except for the fstab….
Here’s what I get when I connect with putty:
“Could not chdir to home directory /home/simon: No such file or directory”
the /home directory is then empty, it should have a folder called “simon”
I had to tweak the fstab just to get it to boot into console, it use to complain about the directory not existing/being ext2 when I set it as ext3.
Here’s my fstab:
/dev/hdf1 /home auto defaults 0 2
replacing auto with ext3 doesn’t chage the result.
Any help to get /home to automount upon a reset would be appreiated
Great blog and very useful.
I am a complete newbie to Linux/Ubuntu, so please excuse any ignorance. I followed the instructions above exactly and all went well until I got to the ‘Mount the new home’ section, when it said that it could not mount /home as it did not exist.
After a little research, I found that the ‘mv’ command had, in effect, changed the name of /home to /old_home and there was no /home folder in the file system.
I then just ran the following instruction-
mkdir /home
and after that the mount new home command worked fine.
One query though- I appended the line to /etc/fstab as above and all works OK, but now I have two lines in that file referring to /dev/hda5 - is that correct, or should I delete the original line?
teaman, you only need one entry in fstab. So if the partition number for the new home hasn’t changed, then use only one line, not two.
[...] Having the “/home? directory tree on it’s own partition has several advantages, the biggest perhaps being that you can reinstall the OS (or even a different distro of Linux) without losing all your data. You can do this by keeping the /home partition unchanged and reinstalling the OS which goes in the “/? (root) directory, which can be on a seperate partition. [...]
Perhaps someone can help me….I installed Ubunto on a 40GB (in a mobile rack)but the jumper was set to ’slave’ and it booted fine until my mobo went south. Replaced mobo and now can’t boot Ubunto. Got a bunch of X server errors the last of which states: “The X server is now disabled. Restart GDM when it is configured correctly.” It then asks me to login but won’t accept my password (I’m the only user). I’d reinstall with the HD set as ‘master’ but hate to lose all my settings; mail, pics, etc. I also have Mepis 3.4.3 in another rack and it had no problems booting as did WinXP Pro also in another rack except had to do a repair/reinstall but booted up fine. So my question is: how do I go about installing Ubunto w/o losing my precious settings? I’m still pretty new at this but getting better all the time. TIA
It worked fine for me, followed the tutorial exactly. Thanks.
[...] I set up my home folder so it’s on a seperate partition. This saved me a little stress when I attempted to upgrade Ubuntu to the Dapper beta to try out XGL accoring to some HOW-TO. I lost my internet connection, and I decided I’d rather this one to be stable and usable so I reinstalled Breezy. My preferences and files were back again. [...]
so, if i have /home on its own partition, does this mean i could more than one flavour of linux on my computer, all sharing the same /home?
Groggyboy,
Yes you could do that.
I found that after the step:
$mv /home /oldhome
There was no longer a “home” directory
I had to:
$sudo mkdir /home
I created another tutorial based on this one (which actually links to this one as being for intermediate to advanced users). My tutorial includes screenshots on the resizing process and doesn’t contain any typos (I hope).
I also ran into the /home directory (mount point) not existing when I followed these instructions, so I tried to correct that in my tutorial:
http://www.psychocats.net/ubuntu/separatehome.html
I’ve been trying to copy the home to the newhome, but, although I’m using sudo, it won’t give me permission. This is the error it constantly outputs:
cpio: cannot make directory `/mnt/newhome//./soyuz’: Permission denied
cpio: /mnt/newhome//./soyuz/.gnome/apps/Aplicaciones/Sonido/.directory: No such f ile or directory
[I also tried leaving the last slash (newhome/) out]
I cannot write on the new partition, nor even create a file, but writing is enabled.
This is the mount line of the new partition:
/dev/hda4 on /mnt/newhome type ext3 (rw)
I have a 80GiB hard disk.
hda2 is fat32, windows
hda3 is an extended partirtion which includes:
hda5 fat32, shared data with windows
hda6 ext3, /
hda7 swap
hda4 was created from hda2, so it is a primary partition, as Gparted won’t let me choose anything else.
Some ideas?
Thanks
Just solved it…
I had to mount the new partition like this:
sudo mount -t ext3 /dev/hda4 /mnt/newhome
Thanks precinto, I added that to the command in the hope that it will help someone. I also fixed a typo, and added the instruction to create a new /home after moving the old to /old_home.
Thanks everyone
[...] Move /home to it’s own partition (tags: linux ubuntu sysadmin) [...]
[...] Mount /home on new drive [...]
i had to add “sudo” after the pipeline to try to get the copying to work right, and then it looked like it did. but something else must not be working right, because when i try to mount my vfat (gparted says it’s fat32) partition as home (the one i copied the files over using your method) everything stops working, i can’t open a text editor to complete the last step.
so is this supposed to work with a vfat partition? i wanted my shared data partition to also be my home partition. is this possible?
let me just be clear: i’m a total noob, so u dont have to insult me. that being said, i believe my problem was that my fat32 was not being mounted properly. after mounting it like ths (mine is sdb3)
$sudo mount /dev/sdb3 /media/windows -t vfat -o umask=000
or the equivalent in my /etc/fstab
backup 1st:
$sudo cp /etc/fstab /etc/fstab_backup
edit:
$sudo gedit /etc/fstab
i put (remember mine is sdb3 fat32 not yours)
/dev/sdb3 /media/windows vfat umask=000 0 0
it seems like it copied over (using your instructions, with sudo added (remember i have it mounted as /media/windows right now):
$cd /media/windows
$sudo find . -depth -print0 | sudo cpio –null –sparse -pvd /mnt/newhome/
anyways i think this will work but i’m downloading knoppix iso to the fat32 disc right now so i’ll have to wait before testing the rest (umounting it and then mounting it as /home, after renaming my home, like u said). if that works i’ll set that up in my fstab.
sorry for the trouble.
well, scratch that. it seems like it just isn’t all being copied over. is there some way to really copy everything? or is there some reason ubuntu would not use a fat32 partition for a /home partition very well?
feuerbach, using FAT32 for /home is not good if for nothing else, then for one important reason - FAT does not suport hardlinks, and many other things, including journalling that would pose solid problems later. If it is essential for you to be share files with windows, create a seperate fat32 partition and use that as the go-between. I realised that fat32 is not good enough first when I tried to rsync-backup some files to a fat32 partition, which is when I came across the issue with links not being possible.
an easy-to-use application for comparing the old and new home partitions is “unison.” just search for it in synaptic.
Hmm interesting to see that this acctually worked for most everyone. I’m a complete linux n00b so I had spent 6 hours searching on how to do this and it took that whole time to find that this one was simple and what I needed.
My system was a fresh (default) install of xubuntu (dapper). everything was installed on the main hdd. I had already had a 2nd hdd installed and wanted to put /home on another partition to protect myself from data loss while learning linux. Before finding this tutorial I already formated the 1st partition of the 2nd drive in ext3.
Unfortunatly the 2nd step of this tutorial failed for me. I had copied and pasted the contents into terminal 1 line at a time (leaving out the “$” of course). when I put in find . -depth -print0 | cpio –null –sparse -pvd i got an error too many arguments. Then I noticed that the 2nd line and the 3rd line of that code went together, so I tried it again and terminal spit out a bunch of lines consisting of canont do this and canot do that. The only thing it did do was it put a copy of “lost+found” in /mnt/newhome, and using file manager showed the little x on the icon for it which I think means its broken.
so anyway someone in the linux yahoo chat ended up walking me through getting this task done but unfortunatly I’ve learnt nothing. I’ve been trying to compare the commands he gave me with these commands and I just can’t figure it out.
I was hoping someone could tell me why the 2nd step of this tutorial had failed for me and how a complete n00b can find out just what all these command acctually mean. I’m really trying hard to learn how to use linux with the limited time I have on my hands. Moving /home was important to me because when I try to do something I end up doing so much damage that I end up constantly having to reinstall the OS itself and I just dont have time to learn if I’m reinstalling and then reconfiguring 10 times a day. I’ve read that there are other directories that I should move to different partitions so my configs in different programs can be kept through a reinstall of the OS. so I really need someone to help me here in learning how this is done, So I can do it myself and learn, instead of just typing in what a person is telling me and not knowing just what it is that I’m doing.
Really nice tutorial: very easy to follow and works perfectly. Many thanks.
Because it stimulated my curiosity, and because it seemed like a useful thing to know more about, I wrote this short explanation of the command line used to copy the /home directory to the new partition. I am rather new to linux, so there may be errors; if you find them, I’d love to know.
find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome/
A word of explanation about the above line. ‘find’ is one of the most useful commands in linux; if you don’t know about it, get familiar with it soon. One of its most useful features is, as above, that it can execute programs based on the files it finds. So here ‘find’:
* walks through the current directory (denoted by ‘.’
* uses the -depth option to check file permissions. [From the 'find' manpage: -depth can be useful when find is used with cpio(1) to process files that are contained in directories with unusual permissions. It ensures that you have write permission while you are placing files in a directory, then sets the directory's permissions as the last thing.]
* -print0 prints the pathname of the found file to standard output, with an ASCII null character at the end (which is used to terminate segments of text, and is important for the next stage)
* the | character redirects the output of ‘find’ to the ‘cpio’ command. ‘cpio’ is used to create archives, but here is used in pass-through mode (specified by the use of the -p option) to copy files to a new location, bypassing the creation of an intermediate archive.
* –null enables ‘cpio’ to read a list of filenames separated by an ASCII null character option (which is here generated by ‘find’s -print0 option)
* –sparse is used to write files with large blocks of zeros as sparse files. A sparse file is a file that may contain considerably less actual data than its size might suggest: i.e. a file with a single byte of data written at its millionth byte will be a 1MB sparse file, full of zeroes except for the last byte. Archive commands such as ‘cpio’ will usually, for efficiency, ignore the zeroes. Since we are aiming to copy exactly, –sparse here forces their recognition.
* -pvd specifies three individual options for ‘cpio’: p (to make cpio run in pass-through mode); v (verbose: list the files processed); and d (to create leading directories where needed)
* /mnt/newhome/ is simply (in this case) the starting directory to which the files will be copied.
Great it all worked a treat, I used the method described at
http://www.psychocats.net/ubuntu/separatehome.html, but it was educational to compare them.
I would like to have several directories on my hda5, say /tophome, /archive and the like. What do I put in fstab to tell it that system /home is actually “/media/NewHomePart/tophome” or “/dev/hda5/tophome”, if you like. See current fstab lines below.
Just to be clear the /tophome directory would have the home directories for me, myfriend, thedog as well within it.
/tophome [will contain directories:]
/tophome/me /tophome/myfriend /tophome/mydog
/dev/hda5 /media/NewHomePart ext3 nodev,nosuid 0 2
/dev/hda5 /home ext3 nodev,nosuid 0 2
Just started using Ubuntu, it is a treat compared to WinXP. I run that under Win4LinPro to use Dreamweaver, etc. Thanks for all your help.
@ubuntonista on #7
du is not a reliable check. I was moving my 30GB
capi:/$ du -sh /home
25G /home
capi:/$ du -sh /home~
29G /home~
Yet, upon futher inspection there was no corruption. A lot of the size changes seemed to be in binary files. For example on one picture there was a size change of 4 bytes, yet both pictures showed the exact same image(there were other files with bigger differences but they tended to be compiled projects).
I know there are some problems with linux storage in that if you edit a file it will take up as much previous space as before(or something like that). My guess is that in moving the files you allow for compression through reorganization. There may be some optimization by cpio, but I really didn’t see any binary change between files(there may be some, but the files I diffed didn’t come up with anything)
Nice write-up and follow-through. I used the procedure with one modification to the archiving step. Note that the cpio command given updates the file modification timestamp. So all your /home files now appear to have been modified at roughly the same time. This can foul things that depend on those timestamps (like developer tools). With GNU cpio, you can use the –preserve-modification-time flag for this, like so:
find . -depth -print0 | cpio –null –sparse –preserve-modification-time -pvd /mnt/newhome
Also, this procedure works for most PCs OK, but on a multi-user or server system you should go into single-user mode to do this kind of stuff.
Forgot the code tags in the last post, the command should be:
find . -depth -print0 | cpio -–null -–sparse –-preserve-modification-time -pvd /mnt/newhome
worked like a charm.. i had a separate partition which i needed to convert to /home and had to modify them a bit.
Thanks for giving the detailed steps
TO MYSTERY - you have to run console as root: $gksudo konsole
i’m also a newbie and had the same problem. sudo also didn’t help me. so i did this and everything went on smoothly.
i followed psychocat’s tutorial but when i rebooted i lost all my custom settings…desktop wallpaper, themes and bookmarks in mozilla, etc. my /home_backup is almost 1 gig but my new /home is less than 100 meg. /home_backup is on hda1 and /home is on hda4. does anyone know how i can get my old /home back on the new partition? thanks.
So, if you have /home on a separate partition, then you will use the same dotfiles (the hidden files/folders in the user folder that start with ‘.’
even if you install a new linux distro. Wouldn’t there be some incompatibilities between distros? Which ones would be safe to use on any linux? Are Firefox and Thunderbird ok?
[...] One of the main reason for starting afresh was to separate my personal files onto another partition so that I easily could reinstall the system another time without risking all of my settings which I find to be such a sane idea that it might be considered for the default. [...]
[...] Here’s a tutorial online that looks good: http://ubuntu.wordpress.com/2006/01/29/move-home-to-its-own-partition/ [...]
I used the psychocats tutorial and made a mess. My home files copied to the new directory okay, but when I booted it wouldn’t find home on the new partition. I got into fstab and it was okay (as copied it from the tutorial but with my partition details. I desperation I re-installed the distro (it is a new computer so nothing much to lose). The reininstalled distro now sees the partition and puts it on the desktop along with my XP one.
My question: How do I get my Edgy to recognize my home partition as ‘home’ (if you know what I mean)?
Regards
John
I did this and it all worked a treat. No problems at all.
Now I would like to know what affect this has on re-installing Ubuntu. I know that I want to keep the home areas and just install Ubuntu. I also want to install Ubuntu in a different area of the disk. Right now Ubuntu is located in my logical area and I want to put it in the primary area. To do that I have to clear out a couple of files now in primary that I am not using and then install over them.
My guess is that what I would need to do is use a Live CD version of GPARTED and delete and then initialize the files I want to overlay first and then install Ubuntu in this initialized file. My question then is how to link my home file to this new Ubuntu file.
fstab of current setup is:
# /etc/fstab: static file system information.
#
#
proc /proc proc defaults 0 0
# /dev/sda10 — converted during upgrade to edgy
UUID=936a68ea-70b3-4084-89f1-a258994c0da0 / ext3 defaults,errors=remount-ro 0 1
# /dev/sda13 — converted during upgrade to edgy
UUID=f7a4da97-bc8e-44aa-ad7e-2c52f6f48d8b none swap sw 0 0
/dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
/dev/sda11 /home ext3 nodev,nosuid 0 2
I already have Windows XP on the disk. What I want to do is eliminate sda3 and put Ubuntu there and then eliminate sda4 and copy /home there. Once I have done that I can then get rid of all the rest of the stuff on the disk except for a swap file, I think. Am I right or am I totally out of it. Any help would be sincerely appreciated. I want to get this cleaned up and fixed so that I can try some other distros I have floating around as well. I want them high enough in the logical region that I can delete them once I have tried them out if I want.
Thanks.
this is somewhat risky…
@dick in NYC:
copy ur home to sda4 first. double check it.
when installing ubuntu u can use gparted to delete sda3 and make that root /
during the installer u can also set /dev/sda4 to /home instead of /media/sda4 or whatever, this will fill in ur fstab for u and set ur new home directory.
hello,
I have a problem like that with cpio,
output from dapper,
>find . -depth -print0 | cpio –null –sparse -pvd /media/hdb3
>cpio: You must specify one of -oipt options.
>Try `cpio –help’ or `cpio –usage’ for more information.
what happened here, after try cpio–help, I am also not know how to use -oipt options
Hi.
How about moving your home directory to an USB HDD? As I work with a company owned laptop and the machine has to stay at the office, I don’t want to have my files sitting on the laptop’s HDD.
I tried this - copying my ~home to the USB HDD and making a soft link to the USB ~home, and this didn’t work: when I logged in, the systems complained about the missing home directory!
Any help?
Thanks
I did something similar recently, see my “super simple md recipe” on https://wiki.ubuntu.com/Raid. The most important thing you’ll see there is that cp and cpio and find were unnecessary for me: ext2 and ext3 (apparently) support the mv operation across partitions.
So, after setting up /dev/hdXX appropriately, my recipe for moving home would be:
$ cd /
$ su
# mv /home /home2
# mkdir /home
# cat >> /etc/fstab
/dev/hdXX /home ext3 defaults 0 0
^D
# mount -a
# mv /home2/* /home
# rmdir /home2
# exit
$ cd
Worked for me, everything appears solid.
Please add a warning about the vfat file system, as it doesn’t allow for change of owners or permissions and user’s applications will totally bug out on them.
I had the same problem as you, fw
>find . -depth -print0 | cpio –null –sparse -pvd /media/hdb3
>cpio: You must specify one of -oipt options.
>Try `cpio –help’ or `cpio –usage’ for more information.
Basically, the above line is incorrect in the fact that the long lines before “null” and “sparse” actually have to be double lines, like this:
find . -depth -print0 | cpio –null –sparse -pvd /media/hdb3
Ok, this system seems to interpret double lines as long lines and you cannot see them in the above example…
In any case, there should be two consecutive “-”’s before those two terms.
Thanks for this great tutorial. After following all the instructions everything seems to work just fine, except for one thing: After logging in I always get this “Run as root - KDE su” request (which opens in a new window) with a message like this:
nautilus ‘–sm-config-prefix’ ‘/nautilus-gJbymW (it cuts off this line then)
‘–sm-client-id’ ‘101ca16910a13e000117130 (it cuts off here again)
‘–screen’ ‘0′ ‘–load-session’ ‘/root/.nautilus/s (it cuts off)
This didn’t happen before. I’m using Kubuntu (and Ubuntu) 6.10, with all the latest updates installed.
Any ideas would be appreciated.
Best regards…Cliowa
find . -depth -print0 | cpio -–null -–sparse –-preserve-modification-time -pvd /mnt/newhome
the — is needed for the cpio command to work.
followed your ‘how to’ and something went seriosly wrong…i lost my homefolder and terminal and firefox and everything and had to do a complete reinstall from fresh, cheers!!!
On Edgy i lost most desktop configuration files, firefox addons, and the like. *And* partitions fail to mount automatically at boot so I have to do run fstab manually. New install, there I go…
followed this tutorial (i tried another one before that seriously messed me up for a full nerve-wrecking day), and everything went smoothly. This guide is correct, simple, and to the point. No unnecessary moves here, and it doesn’t create tons of baggage (i.e. multiple unnecessary copies of your home that only eat up the memory you need to make this work).
Thank you.
I plan on doing a clean install when Ubuntu’s Feisty Fawn 7.04 is distributed. I’d like to use gparted to assign /dev/hdb to /home. That is, I want the entire drive to be my /home directory. Will that get the job done or must I partition a part of hda to use as the /home directory?
Thanks for the terrific advice!
… JJ
Note: I meant that I’d use gparted to MOUNT hdb at /home. Is that the same thing? Will Ubuntu treat that as my /home directory?
… JJ
“I’ve been trying to copy the home to the newhome, but, although I’m using sudo, it won’t give me permission. This is the error it constantly outputs:
cpio: cannot make directory `/mnt/newhome//./soyuz’: Permission denied
cpio: /mnt/newhome//./soyuz/.gnome/apps/Aplicaciones/Sonido/.directory: No such f ile or directory” - precinto - June 6, 2006
I have self same problem
$ sudo mkdir /mnt/newhome
$ sudo mount /dev/md0 /mnt/newhome
$ cd /home
$ sudo find . -depth -print0 | cpio –null –sparse –preserve-modification-time -pvd /mnt/newhome/
and the Permission Denied message appears. Can’t undestand it as I’m executing cpio with Sudo.
Hi,
Great article, by the way. Thanks , I was looking for something like this, however I do have a small problem.
The partition that I used to act as “/home” is a NTFS partition, and this partition is also used by my windows xp on the same system.
So when i log into ubuntu, after I enter my password, I get the following message:
“User’s $HOME/.dmrc” file is being ignored. This prevents the default session and language from being saved. File should be owned by user and have 644 permission. User $HOME directory must be owned by user and not writable by other users”
I know this might be something to do with windows being able to write to it. I might be completely wrong on this.
So, I think this means that “other” users could modify the files?
I am really not sure, what this means.
I just installed ubuntu for the first time this weekend, so I am definitely a newbie, so please, help would be appreciated.
Also please suggest me, whether what I did is dangerous, or any other comments would be appreciated
thanks it work with me,
and about the error of permission it appear, to me but with the test user i add to ubuntu ,and not with the one created by default “mine”,hope this give other a hint. because i dont care about this user “test” am just ignore it..
I’m afraid I couldn’t get this to work at all. First I had to chown /newhome to user:user rather than root:root. That sorted the problem I report above, which seems to be a Bash issue. But then the cpio command threw up errors. A study of the man syntax lead me to:
cpio -p0dv –preserve-modification-time –sparse /mnt/newhome
(the second flag is a zero by the way) which did the trick. But problems didn’t finish there. When running X, /home is well and truly nailed down by umpteen processes, so you can’t copy it to /oldhome or overwrite it. This needs to be done in single user mode to get round this.
Daniel Robbins at IBM has a very easy step-by-step called “Partitioning in Action: Moving /home” at http://www-128.ibm.com/developerworks/linux/library/l-partplan.html.
He uses the simpler cp -ax command to copy the file structure of /home to /newhome (or newpart as he names it). It all works a treat.
[...] from the wonderful ShipIt, which send them out for free….gotta love it. I also have my home directory on a separate partition for easy installation (yes!!!! no need to worry about redoing everything). Can’t wait to [...]
I also had problems w/ cpio command and couldn’t figure it out, so went to aysiu’s psychocats page and tried that method. It worked fine but’cept now I have two home directories and anything saved is duplicated.
[...] nog wel wat puzzelwerk en opzoekingswerk hebben om dit in orde te krijgen. Ik volg momenteel deze tutorial, maar die blijkt voor mij niet voldoende te werken. Ik zoek nog een beetje verder zodat ik weet [...]
find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome/
should be run like this
sudo find . -depth -print0 | sudo cpio –null –sparse -pvd /mnt/newhome/
it worked for me
I’ve got the same error as P Morton. The link to that IBM-page he gave for an alternative method doesn’t seem to work anymore.
I’ve managed to copy the datas with this line:
$find . -depth -print0 | cpio –-null –-sparse -pvd
Whoops, sorry, i’ve made a mistake: sudo the cpio:
$find . -depth -print0 | sudo cpio -–null -–sparse -pvd
[...] /home directory to a newly created /home partition as recommended by Pelo in #ubuntu. I found a guide to moving /home on the Ubuntu Blog. I’ll then be able to just reinstall an OS and point it to /home during [...]
I’ve had problems with the find … | cpio combination, so I got bored and tried the other suggestion on the Debian Archive Guide. This works for me:
cp -ax -sparse=auto . /mnt/newhome
Any idea if this tutorial will work if I try to move /root?
[...] Move /home to its own partition [...]
[...] my home directory to it. For those of you following along at home, the command I used is from this page: $cd /home/ $find . -depth -print0 | cpio –null –sparse -pvd [...]
I need help. This -> “find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome/” doesn’t work. It says “you must specify one of the -oipt options”. I thought the options were specified correctly!!! Help!
[...] I wanted to make /home its own partition to ease backups, synchronization, and future upgrades. This is how I did it. I’m no expert so beware of taking these as instructions. I got most of this from this post. [...]
Awesome, this totally worked. Remember when you copy the cpio command to replace the long dashes with double dashes in the terminal.
worked for me. yay! had to sudo the cpio though.
This process worked for me, thanks for the info!
One thing that caught me was the command:
find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome/
Several issues:
First, when I copied and pasted from Firefox into a gnome-terminal, the double-dashes before “null” and “sparse” became single long-dashes. It complained that “You must specify one of -oipt options.” and it took me a while to realise what the problem was.
Secondly, as mentioned by a previous person in this thread, I had to use sudo on it. Not just sudo at the front, but in front of the cpio command too.
So what I ended up with was:
sudo find . -depth -print0 | sudo cpio –null –sparse -pvd /mnt/newhome/
It seems it’s WordPress doing it, because what I typed in that previous message was two dashes, but looking at the html, it’s merged into one dash.
My (kubuntu) fstab is more complicated:
# /etc/fstab: static file system information.
#
#
proc /proc proc defaults 0 0
# /dev/sda5
UUID=7ff92d34-e70f-dd99-8da9-4c8c3a04acf1 / ext3 nouser,defaults,errors=remount-ro,atime,auto,rw,dev,exec,suid 0 1
# /dev/sda6
UUID=E9DD-41EE /fatshare vfat defaults,utf8,umask=007,uid=0,gid=46,auto,rw,nouser 0 1
# /dev/sda3
LABEL=Data /winxp/d ntfs defaults,nls=utf8,umask=007,uid=0,gid=46,auto,rw,nouser 0 1
# /dev/sda2
/dev/sda2 /winxp/c ntfs defaults,nls=utf8,umask=007,uid=0,gid=46,auto,rw,nouser 0 1
# /dev/sda7
UUID=1df708f2-5285-4741-841a-e23a091ea2a3 none swap sw 0 0
/dev/cdrom /media/cdrom0 udf,iso9660 user,atime,noauto,rw,dev,exec,suid 0 0
How do I modify it accordingly? Can I simple do what you said:
/dev/newhda5 /home ext3 nodev,nosuid 0 2
Will it work?
[...] impossible in Windows due to all the pointers in the registry. It took me 5 minutes following these directions. Share and Enjoy: These icons link to social bookmarking sites where readers can share and [...]
Thank you for this wonderful tutorial!
I’ve used this on Debian to mount a NTFS-3G drive to /home. It works like a charm with Windows XP, had no problem whatsoever yet.
Just one thing I had to change to make it work on Debian was changing the line:
find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome/
to
find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome/
so using double dashes, dunno why this is different, but it works for me
Thanks again for this wonderful tut!
First, I had to use command
sudo mkdir /mnt/newhome
to create the /mnt/newhome. I suppose you can delete it later (after unmounting it):
sudo rmdir /mnt/newhome
Roy, many GNU/Linux command options that have more than one character should be prefixed by two hyphens (to distinguish them from concatenated single character options). I suppose this blog replaces two hyphen by a (long) dash. Let me test; I type two hyphen here: –
One more thing. In Xubuntu Feisty device names begin with s, so instead of hda5 you would use sda5.
[...] Move /home to it’s own partition « Ubuntu Blog (tags: ubuntu linux partition howto /home tutorial home) [...]
great guide, thanks!
There’s only one thing to say, the code line:
find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome/
doesn’t work! i used instead:
find . -depth -print0 | sudo cpio –null –sparse -pvd /mnt/newhome/
that worked for me.
Bye!
…ok, sorry but that is wordpress fault.
there should be two “-” before the options “null” and “sparse”
instead of just one.
bye
[...] safest way is http://ubuntu.wordpress.com/2006/01/29/move-home-to-its-own-partition/ [...]
[...] login process was slightly problematic, because just before I’d reinstalled, I’d moved my /home directory to a new partition, and the GTK+ themes weren’t showing up properly. So, I just went and deleted some [...]
I was following this blog and I got stuck at
sudo mv /home /old_home
I get the following error message “mv: cannot move `/home’ to `/old_home’: Device or resource busy”
So far this is what I have done (hdb1 is the partition I want to use for my directory, this partition is on a different hard disk)
$ sudo mkdir /mnt/newhome
$ sudo mount -t ext3 /dev/hdb1 /mnt/newhome
$ cd /home/
$ sudo cp -a /home/* /mnt/newhome
I used cp since find didn’t work
I got this message when I tried to use find
$ find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome/cpio: You must specify one of -oipt options.
Try `cpio –help’ or `cpio –usage’ for more information.
The next commands are…
$ sudo umount /mnt/newhome
$ sudo mv /home /old_home
mv: cannot move `/home’ to `/old_home’: Device or resource busy
There you have it. Don’t know what to do know. I dont know if I have messed it up. Help
I did get the same message from cpio because when I copy pasted the command it copied -null and -sparse instead of –null and –sparse
(that is two times the - character like specified by the cpio help command)
thanks svdb
however i’m still stuck with the mv command
$ sudo mv /home /old_home
mv: cannot move `/home’ to `/old_home’: Device or resource busy
exit /home by typing
cd /
then retry the mv command.
Other than that, perhaps there’s a problem with the cp command you used? (I’m a linux newbie…
[...] Yeah, but you don’t want to do a straight copy, you’ve gotta get a little fancy: http://ubuntu.wordpress.com/2006/01/29/move-home-to-its-own-partition/ [...]
Ok, I went back and now I can do the “find” command I was unable to do. However, when I reach
$ sudo mv /home /old_home
I still get the error
mv: cannot move `/home’ to `/old_home’: Device or resource busy
I did cd / as suggested above, but still have the same problem.
Wouldn’t this work in other distros? - not just ubuntu?
This is a pretty good guide but got me into a bit scary moment. When I finished everything said in the guide and reboot the system, I could not start my KDE. I had to scramble to look for a solution for “Could not kstartupconfig. Check your installation”. I finally figured it out by doing,
sudo usermod -d /home/username username
sudo chown -R username:users /home/username
now the job is done. thanks for the tip!
Thanks for the walkthrough. I just followed it on Ubuntu 7.10 and it worked like a charm. Thanks!
hello, i did as you said, but i get an error when i logged in. it is related to a file ‘$HOME/.dmcr’ and mode access and i couldn’t start a session. Could it be that i’m trying to use a vfat partition in /home?
bodogs
conveyer inscription radiator.Amarillo Deirdres
heya
I’m new to ubuntu, and very glad for this tutorial. I think ubuntu should allow the user to move the location of the home directory as easy as it is in windows. There you can move the home-directory for the data as simply as by right-clicking the folder and assigning it a new location-address.
cheers
[...] Move /home to it’s own partition « Ubuntu Blog [...]
This is a bit easier if you do the following, first:
$ sudo -i
Password: ***********
… then execute the commands. You won’t have the issues with copying or mounting that others have had.
At the end, verify that your users’ home directories are, in fact, owned by them:
$ ls -l /home
You should get output like this:
drwxr-xr-x 57 rob root 4096 2007-11-14 00:01 rob
Make sure that first name after the number matches the one on the end. If it doesn’t, you can do the following (if you’re still in ’sudo -i’, you don’t need the sudo here)
$ sudo chown -R /home/
For me, this solved most of the problems I had doing this.
[...] Move /home to it’s own partition « Ubuntu Blog (tags: ubuntu linux partition /home) [...]
Chuck- I tried following your instructions to move the /home directory to a second HD I have installed but something happened & I can no longer boot into Ubuntu 7.10. It looks like I’ve created the new home but I was not able to edit the fstab file. The 2nd HD is ntfs. How can I fix this? Can I boot into Ubuntu 7.04 using the CD then edit that file? Or will I need to reload Ubuntu? I want to have the /home directory on my second HD which is where all my data resides. Please help as I am hating Windows with each day & am excited to migrate over to Ubuntu Linux!
Chuck-
I’ve used the CD to boot into the system & can see the fstab file but it is read only. How can I write to this using a live CD to make the necessary change.
[...] 18, 2007 A nice step-by-step guide on how to move your /home directory to a separate partition (there are several reasons why you might want to do [...]
[...] details [...]
[...] Move /home to it’s own partition « Ubuntu Blog (tags: linux ubuntu partition howto tutorial) [...]
Permissions error
If you’re using ’sudo’ remember to put a second sudo after the pipe to run cpio command
sudo find . -depth -print0 | sudo cpio –null –sparse -pvd /mnt/newhome/
[...] Tip: If you are planning on reinstalling Ubuntu multiple times, keep your home partition on a separate partition. [...]
[...] up a separate /home partition for all your personal porn I mean data, ideally at install time but it can certainly be done later, and then just do clean installs of later releases, being careful to only overwrite the root [...]
Thanks for the tips. It worked nice here.
Just wanted to add that I had to use
$find . -depth -print0 | cpio - –sparse -pvd0 /mnt/newhome/
and executing it as root (ie adding a sudo in front of both commands or executing sudo -i before doing the copy) to make it work
Hey i have some questions i made it but my root partition is only 4gb.Is this good;cause i have only 1gb left for (/) root.Will i face any problems in the future ??? I have to make a biiger root partition ??
I didn’t find a responde to alan maxwell’s problem After
following the psychocats’ tutorial everything is fine except
many (not all, e.g. printer) settings are gone and the new
home is alot smaller than the old home. The documents
and files are mostly there, but lots of dot files are empty,.
Any guidelines on how to fix that?
Hello,
I followed the tutorial, except I used an existing partition to copy the home folder to. Now all the data I had on that partition is lost. Apparently cpio copies over existing data. Is there a way to retrieve this data? It is very important for me, thank you in advance
I managed to do it after two or three false starts. In the end I went to the psychocats version, which was very straight forward afte I remembered to put in my own hda numbers and a bit of a panic over inputting the final script.
Up and running, but should have made the partition bigger. Doh
http://www.psychocats.net/ubuntu/separatehome
Hi,
My Desktop was a dual boot with XP and fedora 8. In Linux i had separate partitions for /home, /root and /boot. I have changed my LInux OS from fedora 8 to Red Hat Enterprise Linux ES 4, during which i have formatted the /root and made it as new /root. I wanted to use the previous /home partition as my current /home. After installation i am trying to mount this partition, but this is giving me the error:
mount: wrong fs type, bad option, bad superblock on /dev/hda7,
or too many mounted file systems
Note: /dev/hda7 was my /home during Fedora 8
Additional Info:
e2fsck 1.35 (28-Feb-2004)
/home: clean, 16269/2050272 files, 956656/2048279 blocks
tune2fs 1.35 (28-Feb-2004)
Filesystem volume name: /home
Last mounted on:
Filesystem UUID: cec60e6a-9e89-4701-9ee8-02582cca3035
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype sparse_super large_file
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 2050272
Block count: 2048279
Reserved block count: 102413
Free blocks: 1091623
Free inodes: 2034003
First block: 0
Block size: 4096
Fragment size: 4096
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 32544
Inode blocks per group: 1017
Filesystem created: Mon Sep 4 19:43:43 2006
Last mount time: Thu Feb 28 14:31:11 2008
Last write time: Thu Feb 28 14:31:11 2008
Mount count: 226
Maximum mount count: -1
Last checked: Mon Sep 4 19:43:43 2006
Check interval: 0 ()
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Default directory hash: tea
Directory Hash Seed: 22495fb1-0f00-4dd3-a6a3-ef344c9634af
Journal backup: inode blocks
Please help me get back my data on /home.
Thanks
Harish
Hi,
thanks for the tutorial. I run Gutsy, which uses UUID in /etc/fstab:
1) will adding “/dev/hda5 /home ext3 nodev,nosuid 0 2″ to /fstab do the job, or should I use the UUID?
2)in case I use the UUID, where do I put the “home” bit?
Any help greatly appreciated
Pablo
hi,
i have the same question as pablo. i made everything, and it seems ok, just that when i make a restart, it says that the added line in fstab is not ok, and nothing works.
i can boot in the root mode, delete the fstab line, change the backup directory to home, and it runs again… so…
i’m running ubuntu 7.10
any sugestions?
thanks
ok, i found it, in ubuntu 7.10 we have to use uuid in the fstab
to get the volume uuid, you must write in the console:
(my particular case /dev/sda6 with ext3 format)
$ vol_id /dev/sda6
and the answer is something like:
UUID=b6400497-fc51-4c37-b802-1e97aa18f844
then, add in the fstab:
#/dev/sda6
UUID=b6400497-fc51-4c37-b802-1e97aa18f844 /home ext3 defaults 0 0
and thats all
Is there any reason this method can’t be used to move /usr, /var, /tmp, /opt to their own partitions?
So far so good - almost…
Two other posters have noted this issue, but there is no reponse I can see.
Ubuntu 7.10.
The partition that I mounted as “/home” is a NTFS partition - a clue to the problem?
When I log in, immediatly after entering my password, the following message is displayed:
“User’s $HOME/.dmrc” file is being ignored. This prevents the default session and language from being saved. File should be owned by user and have 644 permission. User $HOME directory must be owned by user and not writable by other users”
Can anyone advise me how to resolve this please? In newbeespeak? I’d like to understand what is happening and what should be happening and why if you have the time to educate me.
Cheers,
Phil
I’ve done it, by following your suggestions combined with the psychocat helpsite…
What i have now though, is that my old /home folder is un findable and is taking up lots of space on my original drive, everything is working fine, but i just want to free up some space.
here’s exactly what i did, can you help…
——————————————————————————————–
Adding a new HD, and making it read/writable.
(assumes you’ve already formatted it using something like Gparted).
Start with a newly formatted @ /dev/sdb.
Open a shell
$ sudo mkdir /media/everything_else
$ sudo mount -t ext3 /dev/sdb1 /media/everything_else
add to /etc/fstab
$ sudo gedit /etc/fstab
# Entry for /dev/sdb1 :
/dev/sdb1 /media/everything_else ext3 defaults 0 0
$ sudo chmod -R 777 /media/everything_else/
Now to move everything over and set /home to your new disk
cd /old/home
$ find . -depth -print0 | sudo cpio –null –sparse -pvd /new/
sudo gedit /etc/fstab
# Entry for /home on /dev/sdb1 (everything_else)
/dev/sdb1 /home ext3 nodev,nosuid 0 2
save then reboot
Sorry, line
cd /old/home
$ find . -depth -print0 | sudo cpio –null –sparse -pvd /new/
should read
cd /old/home
$ find . -depth -print0 | sudo cpio –null –sparse -pvd /media/everything_else/
ok, i sussed it out.
i commented out the line in fstab as below, restarted, removed the original content, un commented the same line and restarted.
job’s a good ‘un
# /dev/sdb1 /home ext3 nodev,nosuid 0
Subsequent to my post of 28 Mar:
I’ve learned from Ubuntu forums that since NTFS doesn’t have linux file ownership details, the owner eveything on an NTFS volume is set to the user who mounted the volume - in this case ‘boot’. This is not changable after the fact. You can probably change this by mounting an NTFS volume after booting, but as this excercise is about /home you can’t boot and log in as a user unless there is already a /home directory. The fix? Take the plunge and format the partition as Ext3 in the first place.
Cheers,
Phil
Your article is very interesting!
But, i’ve some question!
Can i use a directory in a NTFS partition to make Home directory?
how can i do to copy beetween 2 directories without changing files’s owner?
misstake?: $ find . -depth -print0 | cpio –null –sparse -pvd new-dir
Thank you!
[...] If you weren’t lucky enough to know this before installing your system, then do not despair! Carthik from Ubuntu Blog takes you in a step-by-step guide titled “Move /home to it’s own partition“ [...]
[...] If you weren’t lucky enough to know this before installing your system, then do not despair! Carthik from Ubuntu Blog takes you in a step-by-step guide titled “Move /home to it’s own partition“ [...]
Cartella /home su partizione separata….
Oggi proverò a spiegarvi come tenere la cartella home su una partizione separata. Avere la cartella /home su una partizione separata ha diversi vantaggi. Ad esempio, si può installare una nuova versione di Linux ( addirittura una nuova distribuzione )…
I honestly don’t know why Ubuntu doesn’t do this by default. Since Ubuntu is about being ‘friendly to non-experts’ why not do what is best automatically, with the option for advanced users to change if they want? It’s what Ubuntu does with restricted drivers and various other things after all.
i think they do it to be safe
[...] ainda é uma boa prátiva mantê-lo em separado. Se necessário, consulte o Ubuntu Blog para ver como mover o /home para uma partição exclusiva. Esta idéia também pode se aplicar a outras diretórios como /Músicas ou [...]
in my case work everything except that line:
/dev/hda5 /home ext3 nodev,nosuid 0 2
so i change that and write startup.sh:
sudo echo “mount /dev/sda4 /home” > /etc/init.d/startup.sh | sudo update-rc.d startup.sh defaults
and now work great!
cd /home/yourname
become root:
sudo -i
then:
find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome
instead of:
$find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome
I started the process at this line:
$find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome/
and immediately received “cpio: invalid option –e”
I checked the Debian archiving guide and found your same command line, but at this point I’m stalled. Any suggestions?
[...] Move /home to it’s own partition « Ubuntu Blog [...]
bharkins: I have found that doing this is Debian works but you need to change that command a little bit
Use: $find . -depth -print0 | cpio –-null –-sparse -pvd /mnt/newhome/
Note the — on null and sparse… always works for me
Yeah it works ok.
[...] am currently in the process of migrating /home to its own partition so that I can go ahead and upgrade to Hardy Heron as soon as possible. Read [...]
directory…
Some hotels don’t conforms the descriptions, that is why real reviews of people who stayed there are very useful….
[...] Доколку ја ставите вашата home папка во посебна партиција му давате флексибилност на системот да вршите реинсталација или инсталација на друга дистрибуција лесно и едноставно. Само ставете ја вашата /home папка на посебна партиција и играјте си/менувајте ги подесувањата со Вашиот “/” . Сега можете да ги испробувате дистрибуциите на GNU/Linux без да направите штета или да ги изгубите фајловите во вашиот /home фолдер. Инструкции. [...]