Hard Drive question in Ubuntu
gamefreak
Veteran

Joined: 30 Dec 2006
Age: 35
Gender: Male
Posts: 1,119
Location: Citrus County, Florida
I have a Dell Dimension 2350 that I installed Ubuntu on. However I have 2 10GB Hard Drives. Both drives are already mounted and I use gParted to format and mount the second one. However I wonder how to put MY Documents directory on the slave drive. The 1st drive will my OS and programs and second will be for documents.
There's the "proper" way, and the improper (quick) way.
There is no "My Documents", for starters.
What there is is (usually) a /home directory, under which each user gets their own home directory, such as /home/gamefreak
Within your home directory, there will be everything you own, plus some "hidden" files (which are anything that starts with a period - and are not usually shown. These contain all personalised settings, etc.)
So... using a second drive (or indeed, any partition, anywhere), usually involves copying some stuff there, and telling Linux that it is now there.
===========
The classic way to go, is to make an entire partition be where /home is to be found. This is done by putting a line into the text file /etc/fstab saying that /home should be found on a specific mounted partition.
As you don't really want to be logged in, while copying your active files, I'd suggest that you use a "Ctrl/Alt/F1" and login as root (who you may need to give a password to, as these days, root tends not to have one. So, to be able to login as root, start with e.g. a "sudo passwd root".)
Assuming your new partition is an ext3 filesystem in /dev/sdb9 (I do like using lots of partitions)...
mv /home/* /home.old
echo UUID\=`vol_id --uuid /dev/sdb9` /home ext3 defaults 0 2 >> /etc/fstab
mount /home
cp -a /home.old/* /home
The lines are:
- mkdir /home.old
Make a new directory, just to hide away all the initial contents of the /home directory. - mv /home/* /home.old
Move all of /home to the save area. This line has a bug. There are normally NEVER any hidden files under /home (with the exception of . and ..). You can verify this with "ls -A /home". At this point, your user logins are broken. However, should disaster strike, you merely need to do the reverse: "mv /home.old/* /home". - echo UUID\=`vol_id --uuid /dev/sdb9` /home ext3 defaults 0 2 >> /etc/fstab
A bit of "shell magic". Enclosing a bit of a line in back-quotes (grave accents) asks the shell to execute that text as a command, and replace the text with the output of the command. The backslash preceding the equals sign makes that be just treated as text, and not interpreted. In fact, this whole "UUID..." lump could just left as the old style: "/dev/sdb9". The final ">>" tells the shell to send all the line to the tail end of your fstab. DO NOT make the mistake of using a single ">", or it will overwrite the file - which would be inconvenient. Maybe a "cp -a /etc/fstab{,.backup}" before doing his would be a good idea!! Also, do this line just the once, or you'll start collecting redundant extra lines at the end of the file. (Whew?) - mount /home
Now that fstab has an entry for your new partition, mount it. Maybe there already was an entry, after all this, and instead of all my messing about with the preceding line, above, introducing the new fstab line, you could have just edited the one already there? - cp -a /home.old/* /home
Finally. The bit that will take all the time. Actually copying all your users' home directories across to the new partition. Just don't bother to try logging in until this has completed.
As I've just typed all that off the top of my head, I'd advocate waiting for everyone else to proofread it, before you go typing it in!! !
Also, the whole method is somewhat suspect, as there could conceivably be cron scripts active, which may not like all the home directories being (temporarily) moved away.
It would all be more safely done by dropping to single user, or even better, running off a live CD.
The nasty part of the whole process is that I never am fully happy when I have a partition that start "one level down". I.e. seen on its own, the new partition has all the user names at the top level, with no clear indication that "/home" is where they all really start from. (Does that makes sense?)
===========
My favoured method, these days, is just to use symlinks to "bend" parts of my file system to other places.
I organise mounted partitions to look just like parts of my root filesystem.
If I wanted user "fred" to have all his files on the mounted partition "/media/hdb9", I would do this:
cp -a /home/fred /media/hdb9/home
mv /home/fred{,.old}
ln -s {/media/hdb9,}/home/fred
cp -a /home/fred{.old,}
More often, I use the same sort of thing to bend sub-directories of my home directory off onto other partitions. E.g. I might keep my images in /home/myself/images, but that will be symlinked to /media/sdc5/home/myself/images
I do the same trick when I find my root filesystem is getting a bit unwieldy. E.g.
lrwxrwxrwx 1 root root 25 2008-01-11 22:53 /usr/share/doc -> /media/hdb9/usr/share/doc
==========
Oh... and finally, once you are happy that everything is working in its new place, and reboots fine, etc, you could delete the backups - or you could just leave them all as backups!
_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer
Last edited by lau on 15 Nov 2009, 8:21 am, edited 1 time in total.
The best time to set this up is when you are installing. Gparted will let you name partitions things such as /home. /home could be the second disk. Then when the file system is installed, all will be transparent.
Likewise, you can divide up any portion of the operating system like this - though some divisions make no sense. I am currently storing /usr/local on its own partition.
_________________
davidred wrote...
I installed Ubuntu once and it completely destroyed my paying relationship with Microsoft.
This sounds a rather slow way of copying one directory - although that's not really a big deal.
However, it would leave /home splattered across some indeterminate bits of a 10 gig partition.
Also, the UUID of the partition on the second drive will be the same as the UUID of the original partition, which will cause (not insurmountable) problems.
PS. I got my code section wrong.... I left out the "UUID\=" in there. Although I corrected it in the explanation of the line, I hadn't corrected it in both places. Done now. (Where are my proofreaders?)
_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer
There is one difference that does crop up - after a "cp -a", you will usually find that some tiny amount of space has been saved. I believe that is just the effect of recovering slight fragmentation effects, within directory files. E.g. a directory with files "000" to "999" created, then "000" to "998" removed, will not automatically squash back down.
_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer
Similar Topics | |
---|---|
Everything is hard |
06 Jun 2025, 4:47 am |
Things That Are Hard To Do For an Autism Person |
07 Jul 2025, 1:12 pm |
Why are some Nintendo Switch games hard to find? |
04 Jun 2025, 9:11 pm |
Does your autism make it hard to relate to your generation? |
07 Jul 2025, 3:42 pm |