||<>|| It is sometimes necessary to move mount points, for any number of reasons. Perhaps you keep separate partitions for each folder in the root of the filesystem, or maybe you need to store a large database, or perhaps you just want to change where your second hard disk or data partition mounts. = Who is this Guide For? = {{attachment:IconsPage/hdd.png}} This guide is for basic changing of mount points. It will help you edit you file systems table configuration file, {{{/etc/fstab}}}, to achieve this. Please refer to this link about [[Fstab| fstab]]; we will not be covering details from that page here, so it is recommended reading to accompany this guide. {{attachment:IconsPage/dont.png}} If you are using external disks, you do not usually want to create mount points in fstab, but rather let them mount automatically based on their partition label. In this case you can relabel the partitions instead - see [[RenameUSBDrive]]. {{attachment:IconsPage/stop.png}} If you are looking to create a separate /home partition, see [[Partitioning/Home/Moving]]. = Getting Started = {{attachment:IconsPage/terminal.png}} To change mount points, we must edit the fstab file (see link above), so let's open it and have it fork to the background with the & symbol. For Ubuntu, open a terminal and run: {{{ gksudo gedit /etc/fstab & }}} {{attachment:IconsPage/important.png}} '''Remember, the following are examples. Do not copy and paste them to your system; they will not work for you.''' = Basic Example = {{attachment:IconsPage/example.png}} Let's say we want to change a mount point from {{{/media/disk2}}} to {{{/mnt/backup}}}. First, unmount the partition, delete the old mount point, and make the new mount point. {{{ sudo umount /media/disk2 sudo rmdir /media/disk2 sudo mkdir /mnt/backup }}} You must know which partition you want to change, so find what you are looking for by cross referencing the contents of fstab with the output of this command: {{{ sudo fdisk -l }}} The output may look something like this: {{{ Disk /dev/sda: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x41ab2316 Device Boot Start End Blocks Id System /dev/sda1 * 1 5476 43985938+ 7 HPFS/NTFS /dev/sda2 5477 9548 32708340 83 Linux /dev/sda3 9549 9729 1453882+ 5 Extended /dev/sda5 9549 9729 1453851 82 Linux swap / Solaris Disk /dev/sdb: 300.0 GB, 300069051904 bytes 255 heads, 63 sectors/track, 36481 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x3d9c576e Device Boot Start End Blocks Id System /dev/sdb1 1 36481 293033601 7 Linux }}} Locate the entry you want to change. Let's say you discover that the device is {{{/dev/sdb1}}}. Then you will change the line in fstab from something like {{{ /dev/sdb1 /media/disk2 ext3 defaults,errors=remount-ro 0 2 }}} to {{{ /dev/sdb1 /mnt/backup ext3 defaults,errors=remount-ro 0 2 }}} {{attachment:IconsPage/tip.png}} What's that? It has {{{UUID=}}} instead of a /dev location? [[UsingUUID| UUIDs]] are just newer way of identifying partitions - to view correspending /dev locations, you can run one of these commands: {{{ sudo blkid ls -l /dev/disk/by-uuid}}} It is recommended that you keep the UUID instead of changing that column of fstab to a /dev location, but either will typically work. Now that you have changed fstab, save and close the file. You can now remount everything in fstab, including the partition you changed, by running {{{ sudo mount -a }}} = Advanced Example = {{attachment:IconsPage/example.png}} Some users have each directory in the root of the filesystem mounted on different partitions. While this isn't generally recommended to beginners, this method has its purposes, which will not be covered here. Let's say your fstab file looks like this: {{{ # /etc/fstab: static file system information. # # proc /proc proc defaults 0 0 /dev/hda10 / ext3 defaults,errors=remount-ro 0 1 /dev/hda1 /boot ext3 defaults 0 2 /dev/hda5 /ftp ext3 noexec,user_xattr 0 2 /dev/hda7 /home ext3 defaults 0 2 /dev/hda9 /tmp ext3 defaults 0 2 /dev/hda12 /usr ext3 defaults 0 2 ##### /dev/hda6 /usr/local/mysql ext3 defaults 0 2 /dev/hda13 /var ext3 defaults 0 2 /dev/hda11 /var/www ext3 defaults 0 2 ##### /dev/hda2 /share ext3 defaults 0 2 /dev/hda8 none swap sw 0 0 /dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0 }}} I have isolated 3 mount points that will be important and surrounded them with "#####". So now, you want to change {{{/dev/hda6}}} from {{{/usr/local/mysql}}} to {{{/var/lib/mysql}}}. First, unmount the partition, delete the old mount point, and make the new mount point. {{{ sudo umount /usr/local/mysql sudo rmdir /usr/local/mysql sudo mkdir -p /var/lib/mysql }}} Your first idea would be to simply change the mount point so that the relevant portion of fstab looks as follows: {{{ /dev/hda6 /var/lib/mysql ext3 defaults 0 2 /dev/hda13 /var ext3 defaults 0 2 /dev/hda11 /var/www ext3 defaults 0 2 }}} However, you have a problem. If you reboot the computer, you will get an error like {{{ Mounting Local File System Failed }}} Why? The main problem is that you are mounting {{{/var/lib/mysql}}} before {{{/var}}}. As the original documenter of this page put it, the mount order must be like ''trunk first then limbs''. You should mount the filesystem in alphabetical order, with subdirectories being mounted ''after'' their parent directories. You must move {{{/dev/hda6}}} down in the file, so that the relevant portion of the file now reads: {{{ /dev/hda13 /var ext3 defaults 0 2 /dev/hda6 /var/lib/mysql ext3 defaults 0 2 /dev/hda11 /var/www ext3 defaults 0 2 }}} = Having Problems? = {{attachment:IconsPage/question.png}} 1. If your partition won't initially unmount, make sure all programs using data on that device are closed, including nautilus (the file browser), and try a lazy unmount: {{{ sudo umount -l }}} In this case, is either the mount point or the /dev location. 1. If you get the error {{{rmdir: failed to remove `test': Directory not empty}}}, the partition is not unmounted correctly, see #1. 1. Getting errors when you try to mount? Be sure that you have created the new mount point and have spelled it correctly in the directory structure and in fstab. Do not use mount points with spaces in the name - while this is possible, it is a pain to deal with and is not worth the trouble. If you have this problem, it is creating issues in your fstab file because the parser thinks that whatever is coming after the space is the next column in fstab. 1. Getting {{{Mounting Local File System Failed}}} at boot time? Refer to the Advanced Example. = Other Resources = {{attachment:IconsPage/resources.png}} * [[Fstab]] * [[http://ubuntuforums.org/showthread.php?t=283131|How to fstab]] - from the Ubuntu Forums * [[MountingWindowsPartitions]] * [[HowtoPartition]] * [[InstallingANewHardDrive]] ----