Skip to main content
Welcome guest. | Register | Login | Post

Creating user-files specific partition

10 replies [Last post]
ariadacapo's picture
Offline
Joined: 2006-07-13

Hello all,

I'd like to have my files in /home/myusername/ written on a distinct partition.

This way I could install/re-install distributions without touching it and risk losing files (this happened already).
I have some very basic understanding of the command-line, of the mount/umount process, and of the fstab file, but I don't really know where to start. I currently use Ubuntu 6.10 (which isn't running too well) and the disk manager program from Dapper is not here anymore.

Could anyone set me on the right track?

Thanks very much!

Olivier.

dylunio's picture
Offline
Joined: 2005-12-20
It's a case of just

It's a case of just mounting the partition on /home/username.

For example: mount /dev/hda3 /home/username (replace hda3 and username which partition and username)

This would mean that all the files in /home username are written to /dev/hda3.

Since you'll want to do this on each boot you should have an fstab line somewhat like this:

Quote:

/dev/hda3 /home/username ext3 defaults 1 1

(replace partition, username and filesystem as needed). I'm not entirly sure of the options you should use, here I've set the options as 'default', but I'm not entirly sure if this would work for your needs. Maybe others could help with this point.

Of course, before mounting you should copy your data to the new partition (it'll remain on the old partition if you don't delete it, but it will not be viewable when you mount the new partition iirc).

I hope this helps a bit.

dylunio

libervisco's picture
Offline
Joined: 2006-05-04
This is usually set up

This is usually set up during installation where you can select to put /home or any other subdirectory on a separate partition that you also can make in the install process (or beforehand). However, if you've installed it all on one partition and now want to separate things get a bit more complicated I think because you have to basically copy everything in your current /home directory to a new partition and then change Ubuntu fstab to reflect the new /home location.

Of course, the first step is to create this new empty partition. You can use gparted (GUI) or cfdisk (a nice command line tool) to do it (I personally prefer cfdisk as it is cleaner, simpler and not too very hard to use). The new partition will have a device designation like /dev/hda4 (4 can be any other number depending on how many partitions you already have, the number should be automatically put there).

Suppose that your new partition is at /dev/hda4. Now you have to mount it somewhere to move all your stuff in /home there. Before mounting you need to create a directory in which you will mount it. If you want it in /mnt/newhome do sudo mkdir /mnt/newhome. To mount it there do this: sudo mount /dev/hda4 /mnt/newhome

Now your new partition is temporarily mounted at /mnt/newhome and you can start moving files. This command should do it: sudo cp -R /home/* /mnt/newhome. This is a copy command with an -R switch which means that it will copy all directories and subdirectories and their files recursively. Once this is done you should have everything you had in /home in your new partition currently at /mnt/newhome.

Now you just need to change your fstab settings so that Ubuntu knows where to find your new home. Edit your /etc/fstab so that it includes a line like this:

/dev/hda4 /home           reiserfs defaults        0       2

/dev/hda4 is your partition. /home is the mount point on which it has to be mounted by Ubuntu and reiserfs is your filesystem (assuming you will use reiserfs for your new partition).

Note that by default Ubuntu uses some UUID in fstab by default rather than the device name (/dev/hda4). I am not sure why is that, but I assume putting a normal device name should still work.

Before booting you should delete or at least move your current /home to somewhere else, or just rename the directory to something like /old_home so that what is in it doesn't get in the way anyhow (since the new partition must be on that mountpoint).

If I didn't miss anything here (please other experienced users say if I did), this should roughly be it. After you reboot your /home will be on the new separate partition.

All this said, though, because of some differences between various distributions I think it might happen that some program settings (usually stored in home) wont work exactly right, though it may probably be a minor issue. You also have to make sure that when you install, for example, Fedora, you will have to tell Fedora install program (when it asks) that your home partition is at /dev/hda4 and that it *should not* reformat it (otherwise you loose everything there).

Anyway, hopefully this helps somewhat. If you have questions about specifics feel free to ask. Smiling

ariadacapo's picture
Offline
Joined: 2006-07-13
Thanks for the very

Thanks for the very detailed response!
Unfortunately since my hard drive is too small, I will have to use an external one and so cannot do this immediately. But I will do it this week and of course let you know how it goes Smiling
Thanks again
O

libervisco's picture
Offline
Joined: 2006-05-04
There is no problem with

There is no problem with using an external drive, of course. It would just be named a bit differently. So if the first hard drive is /dev/hda the second might be /dev/hdb where the first partition of the /dev/hdb could be /dev/hdb1

The process of doing it doesn't change. Smiling

tbuitenh's picture
Offline
Joined: 2005-12-21
An external USB drive

An external USB drive (non-USB external drives are quite uncommon nowadays) will not be named /dev/hdb but /dev/sda .

libervisco's picture
Offline
Joined: 2006-05-04
Oh my bad. Still, naming

Oh my bad. Still, naming doesn't affect the process.

free-zombie's picture
Offline
Joined: 2006-03-08
tbuitenh wrote: An
tbuitenh wrote:

An external USB drive (non-USB external drives are quite uncommon nowadays) will not be named /dev/hdb but /dev/sda .

where "sd" stands for "SCSI disk", "hd" stands for hard disk and is only used for IDE disks. The Linux SCSI driver, however, forms the basis of other drivers such as the one for USB mass storage (there is a slower independant replacement now) and SATA. So If you have an IDE disk, an SATA disk and a USB thumb drive connected to your computer (as I have now), they'll be named hda, sda and sdb.

libervisco's picture
Offline
Joined: 2006-05-04
Thanks for a nice overview

Thanks for a nice overview free-zombie. Smiling

klhrevolutionist
of course...

Of course you could always do this using a cd-r or other media. Be sure to burn this disc as a multi-session type. This will allow you to keep writing back to the dvd-r or cd-r

ariadacapo's picture
Offline
Joined: 2006-07-13
Thanks

I did it yesterday and it worked perfectly. You people rock, thanks a lot! Smiling

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.