3

Some background: I have installed Linux Mint 17 Cinnamon on my laptop SSD on a 10GB formatted partition and i have another HDD with 75GB, both ext4 formatted.

The question part: I have two partitions lets call them System(sda1) and Data(sdb1).

How do i move the folders: home, usr, var and tmp to the Data(sdb1) and make them accessible from the root system?

I tried symlinks and fstab with a lame logic that didn`t work.

What i appended in my /etc/fstab:

UUID=XXX-Data-drive-UUID-XXX /media/data ext4 default 0 1 
/media/data/tmp /tmp ext4 default 0 1
/media/data/home /home ext4 default 0 1
/media/data/usr /usr ext4 default 0 1
/media/data/var /var ext4 default 0 1

Can anyone at least point me in a right direction ?

-- Edited--

The answer worked, but just to help whoever is following this path:

First, i copied with the command cp -rp (-r for recursive and -p for keeping the same permissions, without -p everything will belong to root)

Them i changed the /etc/fstab as the answer, the bind clause really did the trick.

Them i rebooted with a liveUSB only to rename the old folders in the System(sda1) and avoid some kind of conflict.

And them i started normally, not a single error.

2 Answers 2

4

It sounds to me like you are trying to mount directories which are already mounted (or part of a mount) to a different location. The way to do is is to mount -o bind. So you would have something like this:

UUID=XXX-Data-drive-UUID-XXX /media/data ext4 defaults 0 1 
/media/data/tmp /tmp ext4 defaults,bind 0 0
/media/data/home /home ext4 defaults,bind 0 0
/media/data/usr /usr ext4 defaults,bind 0 0
/media/data/var /var ext4 defaults,bind 0 0

(also you may mean defaults, not default, which I have changed here)

PS: The bind mounts should not be checked, so I have edited the answer to "0 0"

0

You can try this:

  • copy all the files to a new partition, making sure that the contents of /usr do not change while you are doing this.
  • edit /etc/fstab so that /usr will be mounted on the next reboot
  • reboot
  • delete the old files

Copy files: I would use cp -a. -a is the archive option. From the man page:

-a, --archive

    same as -dR --preserve=all
-d
    same as --no-dereference --preserve=links
-P, --no-dereference
    never follow symbolic links in SOURCE
--preserve[=ATTR_LIST]
    preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links, xattr, all
-R, -r, --recursive
    copy directories recursively

Editing /etc/fstab:

You need to know the UUID of your new partition. You can see the mapping by doing:

$ ls -l /dev/disk/by-uuid/

And then add this line to /etc/fstab:

UUID=634c31a5-e27c-4e33-ac67-2e22491a30c2 /usr           ext4    defaults        0       2

Change the UUID to your UUID, and change ext4 to be the file system type you are using – you should know this if you have set up the partition. Delete the old files

After the reboot, the old files in /usr on the root partition will be hidden by the new partition mounted on /usr. But we can use some mount bind trickery to get to the old files and then delete them.

$ sudo mount --bind / /mnt
$ sudo rm -rf /mnt/usr
$ sudo umount /mnt

But some slight mistyping (say, hitting Enter when you'd only typed sudo rm -rf /mnt ) could cause disaster, so I would only use this method if you were very confident in what you were doing, really couldn't deal with any downtime, or had no physical access to the machine and hence were unable to boot off a live CD or live USB stick.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .