LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Moving a folder to a different partition (https://www.linuxquestions.org/questions/linux-newbie-8/moving-a-folder-to-a-different-partition-582939/)

Arituay 09-07-2007 10:03 AM

Moving a folder to a different partition
 
Hello all,
I just installed Ubuntu last night so I am complete newb at this. I had a plan for which folders I wanted on which specific partitions. I didn't end up achieving those planned results somehow during the install process. My /tmp folder in the partition with / but I want it on a different partition. How do I go about moving it?

A second question is how can a view a file explorer that shows the partitions as the highest level that can then be drilled into to see which folders are on them. The default file explorer just shows the various folders as the highest level. The only way I was able to figure out which folders were on each partition was to look at the folder properties and note which folders had the same amount of available disk space.

Thanks,

Arituay

lugoteehalt 09-07-2007 12:13 PM

Go to /etc/fstab, 'file system table', and, as root, insert the appropriate line. It'll be easy to work out what this is by looking at your own or specimen fstab files. Perhaps something like:

/dev/hda7 ext3 /tmp blah, blah,....

Then $ mount /tmp, should do the job.

The partition hda7, say, must not have anything else mounted on it.

Incidentaly, try doing:
df -a
There may well be a temporary file system, don't know much about this, it'll perhaps be on RAM and not a disk.

You might also use a loop device to mount tmp. See info mount.

Hope helps.

daMask 09-07-2007 01:21 PM

how to mount drives on boot up?
 
I also starting using Ubuntu recently. I am dual booting with windows xp, and I would like Ubuntu to mount my hard drives automatically on boot up. Is that possible?

Freex 09-07-2007 01:32 PM

Quote:

Originally Posted by daMask (Post 2884699)
I also starting using Ubuntu recently. I am dual booting with windows xp, and I would like Ubuntu to mount my hard drives automatically on boot up. Is that possible?

Every file system mentioned in /etc/fstab is mounted automatically, so if you add the right line in there (as the root user) it should mount with the operating system.

Something like
/dev/sda1 /mnt/windows ntfs defaults 0 0

Replace '/dev/sda1' with whatever your windows partition is and '/mnt/windows' with your mountpoint

Larry Webb 09-07-2007 02:19 PM

daMask you should start your own post, that way more people will read it and try to answer. To answer your question you can have Ubuntu boot by default. You need to find the "grub menu list" and change the default from the windows to Ubuntu. You may also change the time for the wait. The Grub menu list is in your Ubuntu. There are multiple threads on this subject and a good tutorial on this site.

Arituay 09-08-2007 08:05 AM

Quote:

Originally Posted by lugoteehalt (Post 2884642)
Go to /etc/fstab, 'file system table', and, as root, insert the appropriate line. It'll be easy to work out what this is by looking at your own or specimen fstab files. Perhaps something like:

/dev/hda7 ext3 /tmp blah, blah,....

Then $ mount /tmp, should do the job.

The partition hda7, say, must not have anything else mounted on it.

Incidentaly, try doing:
df -a
There may well be a temporary file system, don't know much about this, it'll perhaps be on RAM and not a disk.

You might also use a loop device to mount tmp. See info mount.

Hope helps.

Thanks for the help on this. Here is my fstab:

Code:

# /etc/fstab: static file system information.
#
# <file system> <mount point>  <type>  <options>      <dump>  <pass>
proc            /proc          proc    defaults        0      0
# /dev/sda2
UUID=9c6486a3-d30d-4e1e-bd40-5713aee4a1ef /              ext3    defaults,errors=remount-ro 0      1
# /dev/sdb1
UUID=764aba8f-20d5-41aa-9278-d6c741409f5e /home          ext3    defaults        0      2
# /dev/sda1
UUID=9CE49922E498FFA6 /media/sda1    ntfs    defaults,nls=utf8,umask=007,gid=46 0      1
# /dev/sda4
UUID=241a63ea-2275-47c0-9cf5-3395a5ff2975 /var            ext3    defaults        0      2
# /dev/sda3
UUID=5a5cfb64-9614-491a-93b8-4442b9003b0e none            swap    sw              0      0
/dev/scd0      /media/cdrom0  udf,iso9660 user,noauto    0      0
/dev/scd1      /media/cdrom1  udf,iso9660 user,noauto    0      0
/dev/fd0        /media/floppy0  auto    rw,user,noauto  0      0

Is there any way to move the /tmp folder to the sda4 partition?

Thanks again,

Arituay

pixellany 09-08-2007 08:41 AM

Keep in mind that the data in a folder gets hidden if you mount a partition to that folder. Thus, you first have to copy the contents to some other temporary location.

Next, delete everything from /tmp (Presumably the reason for putting /tmp on a different partition was to save space)

Then setup the mounting in fstab (as already described), and mount sda4 to /tmp. Once this is done then anything written to /tmp goes into sda4

Finally copy the contents back into /tmp


NOTE: "moving a folder to a partition" does not give a good picture of what is happening..... Much better to say: "mount (connect) partitions to folders (AKA mountpoints)"

Arituay 09-08-2007 11:18 AM

Ok, I tried this and it moved the temp folder to the other partition. Unfortunately now my non-root user name was delete in the process.

I am stuck in root now. I create another user name via System->Administration->Users and Groups then close the Users and Groups window. Then I try to switch users and the new user name doesn't exist. I have created a new user, closed the user and group window, then reopen the user a group window and that user I just created is gone.

I have reverted back to the old fstab file and still newly created user names are still disappearing. What would be causing this?

Arituay 09-08-2007 12:31 PM

Resolved
 
Ok, I have resolved this by reinstalling Ubuntu, deleting all the partitions, then repartitioning the hds.

The moral of the story is that if you don't want a folder to end up on your / partition make sure to create a partition specifically for that folder in the installation process.

That is what I originally tried to do, but after I created four partitions on hda it said the remaining space was unusable. This time around I found out that there is a max of four primary partitions per disk. So I made the /var and /tmp partitions logical instead of primary in the new partition screen and that successfully allowed me to have 5 partitions on hda.

Thanks for the advice all.

Arituay

pixellany 09-08-2007 12:41 PM

we all win when someone has successes like this--glad to see you getting things working.

jay73 09-08-2007 01:02 PM

I don't know what went wrong but I have moved directories quite a few times in the past. There are a few precautions to take but other than that it should work fine. Fedora is a bit of a special case with its Selinux but Ubuntu shouldn't create any issues at all. I assume that the tmp directory wasn't properly copied over.

Arituay 09-08-2007 01:53 PM

Quote:

Originally Posted by jay73 (Post 2885713)
I don't know what went wrong but I have moved directories quite a few times in the past. There are a few precautions to take but other than that it should work fine. Fedora is a bit of a special case with its Selinux but Ubuntu shouldn't create any issues at all. I assume that the tmp directory wasn't properly copied over.

That is possible, though I don't know where I went wrong. These are the steps I took (as root):

1. copied the files in tmp into a separate folder in /home
2. deleted the files in tmp
3. saved a backup fstab file
4. edited the original fstab file by adding a line for /tmp (using the same UUID as the /var line because from what I could tell I had to do that to have the /var and /tmp folders on the same partition)
5. saved the changes to fstab
6. ran the terminal
7. entered command: mount /tmp
8. moved the copied tmp files from the temporary folder in /home into /tmp (strangely there were already folders in the newly mounted /tmp folder before I moved the old tmp files back even though I had deleted the files from /tmp before changing fstab).
8. logged out (at this point my screen just stayed black for a few minutes, at which point I shut off my PC)
9. tried to log in to my main user account and it was gone, could only log in as root, all attempts at creating a new user account appeared to succeed but then the accounts wouldn't work

Any pointers on what I did wrong?

Thanks again,

Arituay

cojo 09-08-2007 06:33 PM

Arituay,

what you should have done is create another partition for /tmp and leave /var alone. Because, /var mount point contain many other system files. So, when you mount /tmp on the same partition as /var you hide all the file in /var which cause your problem. Also, there shouldn't be anything need to be save on /tmp anyway. Unless, you save stuffs in the /tmp which is very bad thing to do. BTW, there is also a tmp directory in /var/tmp. As for why you can only log in as root is because root home directory is /root and not relate to any other mount point.

jay73 09-08-2007 06:59 PM

Exactly. The proper procedure is like this:
- prepare a new partition
- reboot into single user mode
- create a new directory for the new partition: mkdir /new
- copy the files from /tmp to the new partition: cd /tmp && cp -ax * /new
- rename your old /tmp to, say, /oldtmp: mv /tmp /oldtmp
- make a new tmp: mkdir /tmp
- create the proper permissions: chmod 1777 /tmp
- unmount the new partition: umount /new
- remount the new partition under /tmp: mount /dev/??? /tmp
- delete the /new directory
- edit /etc/fstab to include the new partition
- reboot


All times are GMT -5. The time now is 06:53 AM.