Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: How to move /usr to a new drive?

  1. #1
    Join Date
    Mar 2007
    Location
    Michigan
    Beans
    160
    Distro
    Ubuntu 12.04 Precise Pangolin

    How to move /usr to a new drive?

    I've run into a situation here.. I tried pulling the Intrepid upgrade from home here and have ran into a space issue. i.e. I dont have enough.

    So I'd like to move my /usr to my secondary drive which has over 160gigs free. I've goggled a little bit but most of the info I found pertained to either different distros.. or was outdated.

    So I tried searhing for "move /usr" to no avail either. So I'm asking the masters of ubuntu.. is there a reletively painless way to perform this move?

    Thanks!

    Here's my current fstab:

    # /etc/fstab: static file system information.
    #
    # <file system> <mount point> <type> <options> <dump> <pass>
    proc /proc proc defaults 0 0
    # /dev/sda3
    UUID=d27c5727-0319-46f4-b3f8-29e488992f04 / ext3 relatime,errors=remount-ro 0 1
    # /dev/sda1
    UUID=7a66d42d-3729-4b6b-a552-7efa25f6ab9b /home ext3 relatime 0 2
    # /dev/sda2
    UUID=6a2491d4-6629-454c-aad3-0db187063279 none swap sw 0 0
    # /dev/sdb2
    UUID=e6b14e94-3e4a-fca6-0a21-a8f8c42c3232 none swap sw 0 0
    /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
    /dev/scd1 /media/cdrom1 udf,iso9660 user,noauto,exec,utf8 0 0

    And df- h:

    Filesystem Size Used Avail Use% Mounted on
    /dev/sda3 4.9G 4.1G 584M 88% /
    varrun 1.7G 232K 1.7G 1% /var/run
    varlock 1.7G 0 1.7G 0% /var/lock
    udev 1.7G 72K 1.7G 1% /dev
    devshm 1.7G 24K 1.7G 1% /dev/shm
    lrm 1.7G 39M 1.6G 3% /lib/modules/2.6.24-23-generic/volatile
    /dev/sda1 225G 34G 180G 16% /home
    gvfs-fuse-daemon 4.9G 4.1G 584M 88% /home/allanon/.gvfs
    /dev/sdb1 231G 51G 169G 24% /media/disk
    allanon@sputnik:/etc$
    Linux User #447256

  2. #2
    Join Date
    Nov 2005
    Location
    Uppsala, Sweden
    Beans
    2,180
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How to move /usr to a new drive?

    I think it should be possible.
    What you would need to do is, in this order (make sure you have a functional live cd before you start, you will need it when you want to delete the old /usr folder and if you need to recover in case this fails):

    1. Make a new partition (ext3) on the target hard drive (use gparted).
    2. Mount the new partition (I'll use /media/usr in my example below, but any mount point will do).
    Code:
    sudo mkdir /media/usr/
    sudo mount /dev/sdb3 /media/usr #or whatever /dev/sdXY is your new partition
    3. Copy everything from your current /usr directory to the root of the new partition (but do NOT delete the original /usr folder yet).
    To copy from the terminal:
    Code:
    sudo cp -rv /usr/* /media/usr/
    4. Make a new entry in your /etc/fstab for the new partition. Duplicate the line for your "/" file system (sda3), but change the uuid to the correct one for your new partition and set the mount point to "/usr". the uuid can be found in the output of:
    Code:
    ls -l /dev/disk/by-uuid/
    5. Reboot and make absolutely sure everything works and that the new /usr partition is really used.
    6. When you are sure everything works the way it should, boot a live cd, mount the partition containing your ubuntu "/" file system. Delete the contents of the old /usr folder.

    If you need more details on some of the steps, just post a question in this thread and I or someone else will try to help.
    And: any problems that arise before step 6 are easily fixed by simply commenting out or deleting the new line in fstab, but after step 6 there is no easy way back.
    Last edited by jocko; January 24th, 2009 at 10:42 PM.

  3. #3
    Join Date
    Mar 2007
    Location
    Michigan
    Beans
    160
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to move /usr to a new drive?

    Ok cool.. following your instructions jocko..

    Shrunk /media/disk and created new ext3 part /media/disk-1. Coppied entire contents of /usr to /media/disk-1/usr/, compared property panes of both, total number of files the same and total size the same.

    allanon@sputnik:/$ ls -l /dev/disk/by-uuid/
    total 0
    lrwxrwxrwx 1 root root 10 2009-01-24 13:26 2947f429-8da2-4c68-acbe-a838ffd4162c -> ../../sdb2
    lrwxrwxrwx 1 root root 10 2009-01-19 20:26 6a2491d4-6629-454c-aad3-0db187063279 -> ../../sda2
    lrwxrwxrwx 1 root root 10 2009-01-19 20:26 7a66d42d-3729-4b6b-a552-7efa25f6ab9b -> ../../sda1
    lrwxrwxrwx 1 root root 10 2009-01-19 20:26 d27c5727-0319-46f4-b3f8-29e488992f04 -> ../../sda3
    lrwxrwxrwx 1 root root 10 2009-01-24 13:09 f9ad24bc-db09-48d2-9316-95e50ca7c9e2 -> ../../sdb1
    allanon@sputnik:/$ df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda3 4.9G 4.1G 563M 89% /
    varrun 1.7G 232K 1.7G 1% /var/run
    varlock 1.7G 0 1.7G 0% /var/lock
    udev 1.7G 76K 1.7G 1% /dev
    devshm 1.7G 24K 1.7G 1% /dev/shm
    lrm 1.7G 39M 1.6G 3% /lib/modules/2.6.24-23-generic/volatile
    /dev/sda1 225G 34G 180G 16% /home
    gvfs-fuse-daemon 4.9G 4.1G 563M 89% /home/allanon/.gvfs
    /dev/sdb1 214G 53G 152G 26% /media/disk
    /dev/sdb2 18G 3.1G 14G 19% /media/disk-1
    allanon@sputnik:/$


    Modified fstab to:

    # /etc/fstab: static file system information.
    #
    # <file system> <mount point> <type> <options> <dump> <pass>
    proc /proc proc defaults 0 0
    # /dev/sda3
    UUID=d27c5727-0319-46f4-b3f8-29e488992f04 / ext3 relatime,errors=remount-ro 0 1
    # /dev/sda1
    UUID=7a66d42d-3729-4b6b-a552-7efa25f6ab9b /home ext3 relatime 0 2
    # /dev/sda2
    UUID=6a2491d4-6629-454c-aad3-0db187063279 none swap sw 0 0
    # /dev/sdb2
    UUID=e6b14e94-3e4a-fca6-0a21-a8f8c42c3232 none swap sw 0 0
    /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
    /dev/scd1 /media/cdrom1 udf,iso9660 user,noauto,exec,utf8 0 0
    # /dev/sdb2
    UUID=2947f429-8da2-4c68-acbe-a838ffd4162c /usr ext3 relatime,errors=remount-ro 0 1

    So I need to reboot... how do I make sure it works? Thats the step that's confusing me.
    Linux User #447256

  4. #4
    Join Date
    Nov 2005
    Location
    Uppsala, Sweden
    Beans
    2,180
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How to move /usr to a new drive?

    Quote Originally Posted by silverbullet007 View Post
    Coppied entire contents of /usr to /media/disk-1/usr/, compared property panes of both, total number of files the same and total size the same.
    That's wrong. As I said, everything that was in /usr have to be directly in the root of the new partition (/media/disk-1/, NOT /media/disk-1/usr/, as that would result in everything ending up in /usr/usr/ instead of just /usr/ after rebooting with the new fstab)... so move everything from /media/disk-1/usr to /media/disk-1/ before you reboot. Otherwise things will probably go bad... If you have already rebooted you should probably have failed to boot up properly, so boot up a live cd...

    Quote Originally Posted by silverbullet007 View Post
    allanon@sputnik:/$ ls -l /dev/disk/by-uuid/
    total 0
    lrwxrwxrwx 1 root root 10 2009-01-24 13:26 2947f429-8da2-4c68-acbe-a838ffd4162c -> ../../sdb2
    lrwxrwxrwx 1 root root 10 2009-01-19 20:26 6a2491d4-6629-454c-aad3-0db187063279 -> ../../sda2
    lrwxrwxrwx 1 root root 10 2009-01-19 20:26 7a66d42d-3729-4b6b-a552-7efa25f6ab9b -> ../../sda1
    lrwxrwxrwx 1 root root 10 2009-01-19 20:26 d27c5727-0319-46f4-b3f8-29e488992f04 -> ../../sda3
    lrwxrwxrwx 1 root root 10 2009-01-24 13:09 f9ad24bc-db09-48d2-9316-95e50ca7c9e2 -> ../../sdb1
    allanon@sputnik:/$ df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda3 4.9G 4.1G 563M 89% /
    varrun 1.7G 232K 1.7G 1% /var/run
    varlock 1.7G 0 1.7G 0% /var/lock
    udev 1.7G 76K 1.7G 1% /dev
    devshm 1.7G 24K 1.7G 1% /dev/shm
    lrm 1.7G 39M 1.6G 3% /lib/modules/2.6.24-23-generic/volatile
    /dev/sda1 225G 34G 180G 16% /home
    gvfs-fuse-daemon 4.9G 4.1G 563M 89% /home/allanon/.gvfs
    /dev/sdb1 214G 53G 152G 26% /media/disk
    /dev/sdb2 18G 3.1G 14G 19% /media/disk-1
    allanon@sputnik:/$


    Modified fstab to:

    # /etc/fstab: static file system information.
    #
    # <file system> <mount point> <type> <options> <dump> <pass>
    proc /proc proc defaults 0 0
    # /dev/sda3
    UUID=d27c5727-0319-46f4-b3f8-29e488992f04 / ext3 relatime,errors=remount-ro 0 1
    # /dev/sda1
    UUID=7a66d42d-3729-4b6b-a552-7efa25f6ab9b /home ext3 relatime 0 2
    # /dev/sda2
    UUID=6a2491d4-6629-454c-aad3-0db187063279 none swap sw 0 0
    # /dev/sdb2
    UUID=e6b14e94-3e4a-fca6-0a21-a8f8c42c3232 none swap sw 0 0
    /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
    /dev/scd1 /media/cdrom1 udf,iso9660 user,noauto,exec,utf8 0 0
    # /dev/sdb2
    UUID=2947f429-8da2-4c68-acbe-a838ffd4162c /usr ext3 relatime,errors=remount-ro 0 1

    So I need to reboot... how do I make sure it works? Thats the step that's confusing me.
    As far as I can see the fstab entry should work. Once you have fixed the problem above, you should be able to reboot and see from the output of "mount" or "df -h" that your /dev/sdb2 is mounted as /usr. As long as the directory tree and all file and folder permissions on the /usr partition are exactly the same as in your original /usr folder, everything will work exactly as before. Then you should be able to empty the original /usr folder in your /dev/sda3 partition (but you will only access it from a live cd).
    Last edited by jocko; January 24th, 2009 at 10:42 PM.

  5. #5
    Join Date
    Mar 2007
    Location
    Michigan
    Beans
    160
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to move /usr to a new drive?

    Sorry I was in a hurry (had the UPS for my blade chassis at work die). There is no /usr/usr/... the full path to the usr files is /media/disk-1/usr/ thats it. I verified before posting cause I know that a dbl-usr path would be wrong.

    Cool on the rest, I'm going to d/l and burn a new live cd while Im here and give it a whirl tonight.

    Thanks for your expert help bro!

    allanon@sputnik:/media/disk-1$ ls
    lost+found usr
    allanon@sputnik:/media/disk-1$ cd usr
    allanon@sputnik:/media/disk-1/usr$ ls
    bin games include java lib lib32 local NX sbin share src X11R6
    Linux User #447256

  6. #6
    Join Date
    Nov 2005
    Location
    Uppsala, Sweden
    Beans
    2,180
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: How to move /usr to a new drive?

    Quote Originally Posted by silverbullet007 View Post
    Sorry I was in a hurry (had the UPS for my blade chassis at work die). There is no /usr/usr/... the full path to the usr files is /media/disk-1/usr/ thats it. I verified before posting cause I know that a dbl-usr path would be wrong.

    Cool on the rest, I'm going to d/l and burn a new live cd while Im here and give it a whirl tonight.

    Thanks for your expert help bro!

    allanon@sputnik:/media/disk-1$ ls
    lost+found usr
    allanon@sputnik:/media/disk-1$ cd usr
    allanon@sputnik:/media/disk-1/usr$ ls
    bin games include java lib lib32 local NX sbin share src X11R6
    That's what's wrong. There should be no /media/disk-1/usr. As the partition will be mounted as /usr, the files and folders from your original /usr directory MUST be DIRECTLY on /media/disk-1, not in a subfolder called /usr. If you have it in /media/disk-1/usr, it will become /usr/usr after rebooting with your new fstab, and that will very likely leave you with an unbootable system.
    You should see this:
    Code:
    allanon@sputnik:/media/disk-1$ ls
    bin  games  include  java  lib  lib32  local  NX  sbin  share  src  X11R6
    NOT this:
    Code:
    allanon@sputnik:/media/disk-1$ ls
    lost+found  usr
    Again: The partition which you now have temporarily mounted as /media/disk-1 should not contain the new /usr folder it should be the new /usr folder...
    And to avoid one more problem:
    When you boot with a live cd and want to remove the old /usr folder, just remove the contents of the folder but leave it there (or remove it and create a new, empty, /usr folder). It needs to be there as mount point for your new /usr partition.
    Last edited by jocko; January 24th, 2009 at 10:52 PM.

  7. #7
    Join Date
    Mar 2007
    Location
    Michigan
    Beans
    160
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to move /usr to a new drive?

    Oh crap ok I get you now

    so it'd prolly be easier to just del what I've got in /media/disk-1 and recopy. OK I guess I was just misunderstanding what you were typing. I'll make that change now.

    Silly question here.. can I rm the /media/disk-1/usr folder? It seems only root has access to anything other than viewing the contents.
    Last edited by silverbullet007; January 25th, 2009 at 02:52 AM.
    Linux User #447256

  8. #8
    Join Date
    Mar 2007
    Location
    Michigan
    Beans
    160
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to move /usr to a new drive?

    Ok just rebooted after copying the contents of /usr to the correct location of /media/disk-1/ however now the other partition of /media/disk is nt mountable. I get "Error org.freedesktop.DBus.Error.AccessDenied"

    Now df -h shows:

    allanon@sputnik:~$ df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda3 4.9G 4.1G 567M 88% /
    varrun 1.7G 220K 1.7G 1% /var/run
    varlock 1.7G 0 1.7G 0% /var/lock
    udev 1.7G 76K 1.7G 1% /dev
    devshm 1.7G 24K 1.7G 1% /dev/shm
    lrm 1.7G 39M 1.6G 3% /lib/modules/2.6.24-23-generic/volatile
    /dev/sda1 225G 34G 180G 16% /home
    /dev/sdb2 18G 5.8G 11G 35% /usr
    gvfs-fuse-daemon 4.9G 4.1G 567M 88% /home/allanon/.gvfs
    allanon@sputnik:~$


    So for some reason that entire drive is not mountable.. and it doesnt show up under the above command.

    Did I do something wrong? There were two partitions on that drive with only the one supposed to be mounted as /usr
    Linux User #447256

  9. #9
    Join Date
    Mar 2007
    Location
    Michigan
    Beans
    160
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to move /usr to a new drive?

    very strange.. now I can't sudo commands..

    allanon@sputnik:~$ sudo gparted
    sudo: must be setuid root
    Last edited by silverbullet007; January 25th, 2009 at 03:51 AM.
    Linux User #447256

  10. #10
    Join Date
    Mar 2007
    Location
    Michigan
    Beans
    160
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How to move /usr to a new drive?

    Ok resolved the non-sudo issue by:

    Reboot into recovery mode
    dropped to a root shell
    chown root:root /usr/bin/sudo
    chmod 4755 /use/bin/sudo
    reboot


    Works now. I still need to figure out what caused the first partition on my /media/disk to become un-mountable and disappear from df -h
    Linux User #447256

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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