how do i mount separate partitions and not loose data?

can anyone tell me how to mount separate partitions and not loose data?

i have a new debian installation with separate partitions (images) for:

/ /swap /home /usr /var and /tmp

/ and /swap are created automatically when you install a new linode image.

the problem occurs when i add the partitions i create to fstab and restart.

they mount, but there is no data.

so the question is:

how can i mount partitions without loosing the data?

pr

how can i have separate partitions in one setup?

(what is the correct procedure)

6 Replies

You'll need to mount them at a different location, first, copy data over, then overmount the real location. eg:

## assuming /dev/xvdc is your new /usr
mount /dev/xvdc /mnt
cp -a /usr/* /mnt/
umount /mnt
mount /usr

Note that in the case of /var and /tmp, rebooting afterward is recommended. Also, once you're sure things are working fine, you can remove the unneeded copies in the root fs like so:

mount --bind / /mnt
rm /mnt/usr/* -rf  ## don't remove /usr itself!
umount /mnt

Be sure to copy everything, and make sure it comes back on a reboot, first, of course :)

i was slowly thinking that this was the solution but had no idea how to go about it correctly. Will give it a try today and post the results here shortly. thanks a bunch.

that worked like a charm, thanks!!

when the old data was removed you kept the empty folders there, is this a requirement for the system to work or can i delete these empty folders?

The empty directories are needed - when you mount a partition, it must be attached to an already-existing directory.

So here are the results:

:~# quotaon -avug
/dev/xvda [/]: group quotas turned on
/dev/xvda [/]: user quotas turned on
/dev/xvdc [/usr]: group quotas turned on
/dev/xvdc [/usr]: user quotas turned on
/dev/xvde [/var]: group quotas turned on
/dev/xvde [/var]: user quotas turned on
alpha1:~#                                              #i hit tab to show available programs here
Display all 702 possibilities? (y or n)

If it didnt work my list of available programs would have been 152 instead of 702 or something like that.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct