Find the answer to your Linux question:
Results 1 to 8 of 8
I have a full, running Gentoo Stage 3 system that's worked perfectly for about 8 months now. I have 2 hard drives...one is 40 gigs (where Gentoo is on) and ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Enthusiast
    Join Date
    Jun 2005
    Location
    Odessa, FL
    Posts
    586

    Able to create new partitions and move important folders after install?


    I have a full, running Gentoo Stage 3 system that's worked perfectly for about 8 months now. I have 2 hard drives...one is 40 gigs (where Gentoo is on) and one is 80 gigs (almost empty). It's partition is running out of space though, so I was wondering if it was at all possible to move major directories (say...where the programs are installed) to the second hard drive. I'm not even very sure which directories I would move.... /var/ , /home/ , /usr/ ??

    The way I was thinking of doing this was to create a partition on the second hard drive to accomodate one of these. Then, I'd copy and paste the folder over to that new partition and edit my /etc/fstab so that it sees this new mount point.
    I believe it would go something like this:
    i'd copy the directory to this new empty partition...let's call it "/mnt/temp" and /dir/ the directory to the programs (though i'm sure it's not)...then /mnt/temp would have ./dir/ in it
    i would delete the original /dir/
    then, rename the /mnt/temp/dir/ to /dir/
    i could go to /etc/fstab and add a line like this:
    Code:
    /dev/hdg1               /dir/            reiserfs        noatime,notail                          0 0
    ....it's a reiserfs filesystem on the first partition of this harddrive

    i did something similar with my /usr/portage/ directory already with the line looking like this:
    Code:
    /dev/hdg2               /usr/portage/            reiserfs        noatime,notail                          0 0
    ...and it works fine. the difference is that i can still start the computer even if portage has trouble, i wouldn't be able to start (atleast not everything) without the directory leading to the programs.

    my main point is, that i really don't want to reinstall gentoo. i have everything i need on it now and i don't have the time to reinstall it....but i do want to move this directory. as a last resort, if this has trouble, i can put in my dsl live cd and mess around with it from there. i'd just like to try and get this in the first try if possible.

    Thanks in advance for any and all help!!
    (I'm not looking for comments like...."it's not worth it" or "you might as well reinstall"...i really want to try this and see how it works, but i'm wondering if it looks like it makes sense)

  2. #2
    Linux Guru smolloy's Avatar
    Join Date
    Apr 2005
    Location
    CA, but from N.Ireland
    Posts
    2,414
    I've done this myself quite recently, and it's relatively easy. I moved /home to its own partition (and moved it back again later, but we won't go into that) so I'll show how I did that.
    Code:
    su -
    <root password>
    init 1
    mkdir /home_new
    mount -t ext3 /dev/hda6 /home_new
    cp -pR /home /home_new
    mv /home /home_old
    mv /home_new /home
    init 5
    Drop down to single user mode (this may or may not be necessary, but I thought it would be safer as then /home won't be being used during the following operations). Make a new folder (/home_new) to mount the new partition at, and then copy the contents of /home to here. Finally rename /home and /home_new to reflect the changes.

    Last but not least you'll have to edit /etc/fstab to let the system know where /home is or you'll have a lot of problems at reboot.

    Please, please, please don't just copy these instructions blindly. Check them to make sure I haven't made a mistake (I was doing this from how I remember moving the partition, but I could have screwed up). Searching googler for "moving /home to a new partition" or something similar will bring up a lot of hits, including some tutorials, so make sure that you are confident in what you're doing.

    Bottom line: I've done my best to honestly remember what I did, but I take no responsibility for your system!!!

    Good luck!
    Registered Linux user #388328 || Registered LFS user #15880
    AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
    Need instant help? Try us on IRC -- #linuxforums on freenode

  3. #3
    Linux Enthusiast
    Join Date
    Jun 2005
    Location
    Odessa, FL
    Posts
    586
    Quote Originally Posted by smolloy
    I've done this myself quite recently, and it's relatively easy. I moved /home to its own partition (and moved it back again later, but we won't go into that) so I'll show how I did that.
    Code:
    su -
    <root password>
    init 1
    mkdir /home_new
    mount -t ext3 /dev/hda6 /home_new
    cp -pR /home /home_new
    mv /home /home_old
    mv /home_new /home
    init 5
    Drop down to single user mode (this may or may not be necessary, but I thought it would be safer as then /home won't be being used during the following operations). Make a new folder (/home_new) to mount the new partition at, and then copy the contents of /home to here. Finally rename /home and /home_new to reflect the changes.

    Last but not least you'll have to edit /etc/fstab to let the system know where /home is or you'll have a lot of problems at reboot.

    Please, please, please don't just copy these instructions blindly. Check them to make sure I haven't made a mistake (I was doing this from how I remember moving the partition, but I could have screwed up). Searching googler for "moving /home to a new partition" or something similar will bring up a lot of hits, including some tutorials, so make sure that you are confident in what you're doing.

    Bottom line: I've done my best to honestly remember what I did, but I take no responsibility for your system!!!

    Good luck!
    thanks a lot for the help ...that's pretty much what i did when moving portage, so it looks ok to me.

    i liked your disclaimer a lot too . i'll be ok...i fully understand what may go wrong, and my important data is on a thumbdrive. the worst case scenario is i lose all the programs and end up reinstalling gentoo (ok, that's pretty bad...but i'll give it a shot anyways :P ).

    where would the programs be installed on a gentoo system? any ideas? /etc/ looks filled with things....can that be it? would it be a bad idea to try and make separate partitions for the following: /usr/ , /home/ , /etc/ , /lib/ , /var/ ?? the location (as far as the system is concerned) would be the same, but it'll physically be on a separate hard drive/partition. one last thing, can someone give me a link to what these various directories actually do or are used for? sorry for newb question, i'm just interested and i've always felt more comfortable with a few partitions rather than a large one

    once again, thanks a lot for the help



    EDIT: i think i'm starting to realize what the directories are...
    /etc/ is for config files
    /home/ is, well, for individual users' files
    /lib/ is where libraries are stored
    /usr/ is where programs are stored (???)
    /var is for temporary files (???)

  4. #4
    Linux Guru smolloy's Avatar
    Join Date
    Apr 2005
    Location
    CA, but from N.Ireland
    Posts
    2,414
    Quote Originally Posted by josolanes
    where would the programs be installed on a gentoo system? any ideas? /etc/ looks filled with things....can that be it? would it be a bad idea to try and make separate partitions for the following: /usr/ , /home/ , /etc/ , /lib/ ?? the location (as far as the system is concerned) would be the same, but it'll physically be on a separate hard drive/partition. one last thing, can someone give me a link to what these various directories actually do or are used for? sorry for newb question, i'm just interested and i've always felt more comfortable with a few partitions rather than a large one
    A good explanation of the various folders is the Filesystem Hierarchy Standard, which is the official standard for unix-style systems. From this you can see that the files stored in /etc are system configuration files, i.e. various configuration files used to tell your system how to behave (for example /etc/fstab which tells the system where to mount the various partitions, etc.). The FHS is considered to be the font of all knowledge with respect to the use of each folder in the tree, and can be considered to be official.

    It's not a bad idea to try to have a different partition for each folder -- especially /home and /usr since that will make updating the operating system much easier (although I see you're using a gentoo system, which is probably the easiest distro to update thanks to portage!). Most programs you install will probably be located somewhere in /usr (I tend to install everything in /usr/local) so this folder can become quite large. /home can also be quite large but this depends strongly on you (obviously), so you need to think carefully about how much space you allocate to each partition you make -- especially since it may become difficult to change this in the future.

    Presently I only have /home on a separate partition, but I have found myself wishing more than once that I'd put /usr on it's own partition as well. However, you should remember that this is an issue that everyone will have a different opinion on -- as usual with linux it's all a matter of personal taste.
    Registered Linux user #388328 || Registered LFS user #15880
    AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
    Need instant help? Try us on IRC -- #linuxforums on freenode

  5. #5
    Linux Enthusiast
    Join Date
    Jun 2005
    Location
    Odessa, FL
    Posts
    586
    thanks a lot for the great response

    i'm thinking about moving /usr/ (the programs), /home/ , and /var/ to the other hard drive (which is slightly faster than the one they're on now) and keeping the rest (/etc/ , /lib/ , and whatever else) on the hard drive they're on now but making separate partitions for each. i might have to boot into DSL to do this though (as you can't unmount / ).

    Wish me luck and thanks a lot for the help/advice

  6. #6
    Linux Enthusiast
    Join Date
    Jun 2005
    Location
    Odessa, FL
    Posts
    586
    ok, it worked great
    so far, i've moved /var/ , /usr/ , /home/ , and /usr/portage/ to there own partitions on the second harddrive.

    how i did it:
    partition drive so that you have enough partitions and plenty of room for each directory in each partition (i used gparted but you could use any parititioning tool)

    create new mount point for each of the directories:
    Code:
    mkdir /mnt/var/ && mkdir /mnt/usr/ && mkdir /mnt/home/ && mkdir /mnt/portage/
    make new entries in /etc/fstab for each of the new partitions.
    i used reiserfs, on the second hard drive, with the 5th through 8th partitions on this drive. mine looked like this:
    Code:
    /dev/hdg5              /mnt/usr                    reiserfs        noatime,notail                          0 0
    /dev/hdg6               /mnt/home                   reiserfs        noatime,notail                          0 0
    /dev/hdg7               /mnt/var                    reiserfs        noatime,notail                          0 0
    /dev/hdg8               /mnt/portage            reiserfs        noatime,notail                          0 0
    (Make sure you use the correct partition type...such as ext3, xfs, reiserfs, ext2, etc)

    mount the new directories:
    Code:
    mount /mnt/usr/ && mount /mnt/var/ && mount /mnt/home/ && mount /mnt/portage/
    move the files from within the original directories (not the directories themselves) to the new directories (ie: from /var/ to /mnt/var/). i did this with the file manager, as i found that, from the command line, "cp /var/* /mnt/var/" didn't work how i wanted it to

    edit /etc/fstab/ so that the original directories are now the mount points:
    Code:
    /dev/hdg5               /usr                    reiserfs        noatime,notail                          0 0
    /dev/hdg6               /home                   reiserfs        noatime,notail                          0 0
    /dev/hdg7               /var                    reiserfs        noatime,notail                          0 0
    /dev/hdg8               /usr/portage            reiserfs        noatime,notail                          0 0
    (i kept the portage example, partly to show that you can have a mount point within another mount point...as long as the one it's in is mounted first. in this case, /usr/ is mounted before /usr/portage/)

    now, restart your computer and see if these volumes are mounted by attempting to unmount each:
    Code:
    umount /usr/ && umount /var/ && umount /home/ && umount /portage/
    all of them should give the following message (with their respective mount points):
    Code:
    umount&#58; /usr&#58; device is busy
    umount&#58; /usr&#58; device is busy
    ...except for /usr/portage , as it's not always in use and most likely won't be when you're doing this (unless you're using emerge).

    if they do give you the above message, than it's safe to remove the contents of the original directories as the mount points have taken their places. do this by restarting the computer and booting into a live cd, such as DSL or Knoppix.

    once you've booted into your live cd, go to its /mnt/ directory within a terminal and view it's contents:
    Code:
    cd /mnt/ && ls
    this should give you something like this (assuming your linux distro is mounted on /dev/hda1):
    Code:
    hda1    hdg5    hdg6    hdg7    hdg8
    since we're now looking to remove the contents of the original directories, we would have to view the contents of your distro's partition:
    Code:
    mount /mnt/hda1 && cd /mnt/hda1 && ls
    you should now see all of the contents of your distro's partition. remove the contents of /var/ , /usr/ , and /home/:
    Code:
    rm -rf ./var/* && rm -rf ./usr/* && rm -rf ./home/*
    you will also need to create the mount point for /usr/portage/ now since that directory no longer exists and because you'll need it to mount the partition:
    Code:
    mkdir ./usr/portage
    if you attempt this, please look through the instructions and make sure they look ok before actually starting, and don't skip steps. i did my best to write them accurately (and i reviewed it and it looks ok). please inform me of any mistakes that i may have made when typing this. thank you very much

    Good luck!

  7. #7
    Linux Guru smolloy's Avatar
    Join Date
    Apr 2005
    Location
    CA, but from N.Ireland
    Posts
    2,414
    This is a very nice tutorial, well done!. I remember when I first tried to do this it would have been brilliant to have access to instructions as good as this -- perhaps you could suggest to the mods that they include it in the tutorial section??

    Just so you know,
    Code:
    cp -pR /usr/
    Using the p (preserve permissions) and R (recursive) flags should solve the problems you had with copying the files.

    Also, when you mount the newly copied folders you will then have the data located twice at each folder -- once in the original partition, and once when the mountpoint overlays this. I'm sure this will work, but it seems a little dangerous to me. Perhaps you should consider descending to runlevel 1, and renaming the original folders before you mount the new ones?? This would also allow you to erase the originals without the use of a livecd.

    Those were the only two (rather unimportant) comments I had.

    Well done
    Registered Linux user #388328 || Registered LFS user #15880
    AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
    Need instant help? Try us on IRC -- #linuxforums on freenode

  8. #8
    Linux Enthusiast
    Join Date
    Jun 2005
    Location
    Odessa, FL
    Posts
    586
    Quote Originally Posted by smolloy
    This is a very nice tutorial, well done!. I remember when I first tried to do this it would have been brilliant to have access to instructions as good as this -- perhaps you could suggest to the mods that they include it in the tutorial section??

    Just so you know,
    Code:
    cp -pR /usr/
    Using the p (preserve permissions) and R (recursive) flags should solve the problems you had with copying the files.

    Also, when you mount the newly copied folders you will then have the data located twice at each folder -- once in the original partition, and once when the mountpoint overlays this. I'm sure this will work, but it seems a little dangerous to me. Perhaps you should consider descending to runlevel 1, and renaming the original folders before you mount the new ones?? This would also allow you to erase the originals without the use of a livecd.

    Those were the only two (rather unimportant) comments I had.

    Well done
    thanks a lot for the kind remarks
    i'll bring it up to a mod....thanks for the suggestion

    it was fun to try and i'm very glad it worked lol (system still boots with no problems )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •