LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Fedora (http://www.linuxquestions.org/questions/fedora-35/)
-   -   move folder to new partition (http://www.linuxquestions.org/questions/fedora-35/move-folder-to-new-partition-371566/)

blizunt7 10-10-2005 11:48 AM

move folder to new partition
 
Hey all,
I have a folder full of pictures. I am looking to attach an external hard drive via USB2.
The pictures are located in /home/special and im looking to leave this folder in this directory tree, but move its location to the external partition.

I would image in need to mount the new hard drive on /home/special??
and then edit /etc/fstab to auto mount the external hd at each boot.

Can someone help me to outline how i can accomplish this without loosing data? Thank you very much


Josh

MensaWater 10-10-2005 12:04 PM

1) Rename existing folder:
mv /home/special /home/special.old (assuming existing /home/special is not a mount itself but rather a home directory of /home - if its a mount you need to umount it then do the rename.)

2) Do mkdir /home/special to recreate an empty directory to use as mount point.

3) Do your fdisk/newfs stuff on the external to make it a filesystem.

4) Rather than mounting the filesystem then adding it to /etc/fstab I'd suggest you add it to fstab first then just type "mount /home/special". The benefit here being that the mount command would then get all its options from what you'd put in /etc/fstab and thereby verify it was correct. (You don't want to find out on boot that its wrong.)

5) Type df -k /home/special to verify it is mounted as you expect rather than just being a subdirectoy of another mount.

6) Copy all the files from /home/special.old to the newly mounted /home/special
cp -pR /home/special.old/* /home/special (don't foreget to check afterwards for .* files in /home/special.old to make sure you didn't leave any hidden files there.)

7) Wait a week or so before blowing away the /home/special.old to make sure you didn't miss anything. When ready to blow it away:
rm -rf /home/special.old

Tuttle 10-10-2005 12:10 PM

Try putting this in your /etc/fstab:
Code:

/dev/usb_device_name      /home/special            auto    defaults        0  0
To find out the "usb_device_name", plug in your usb drive and (if it automatically mounts) you can type "mount" into a terminal to see a list of all mounted partitions, their mountpoints (like /home/special will be) and their /dev name. Also _if_ your usb drive automounts at the moment, you should see a temporary entry for it in /etc/fstab to give you a hint.

edit: double-post!

blizunt7 10-10-2005 12:13 PM

Wow,
thanks great, thanks so much, im going to try this.

I already have however data on my external hard drive, and i believe it is already in NTFS
format, This may be an issue huh??
I have already been able to mount my winxp partition (ntfs) with no problem, so i should
be ok.

What is the best way to find out which hda the external is? other than just knowing what is
there now, and seeing it when i attached it? If there is one at all.

Thanks so much

blizunt7 10-10-2005 12:14 PM

Ha, ok, thats great tuttle, too quick for me. thanks

blizunt7 10-11-2005 03:49 PM

Hey,
Ive just realized that I should resize my external hard drive, as to not disturb my data currently on it.
out put of fdisk -l /dev/sda
Code:


Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1              1      30401  244196001    7  HPFS/NTFS

i would like to use, lets say 70G for a new NTFS partition.

I have never created a new partition on a live drive, and would jus tlike anyone else prefer not to loose my other data on it already.
Can someone lead me in the right direction?

THanks

Tuttle 10-11-2005 06:00 PM

You will need to use partition magic or something to resize a NTFS partition (or copy it to a temporary location while making new partitions).
Re-size (using partition magic) then make a new active partition (using fdisk) and create an ext3 (for example) filesystem on it like this:
Code:

mke2fs -c -j -v /dev/sda2
where /dev/sda2 is the second partition on sda and /dev/sda1 is the resized NTFS (first) partition. Double, nay triple check the /dev name before you try anything;)

also, see "man mke2fs" and for more options.

blizunt7 10-11-2005 06:24 PM

Is there a way that i can just resize via linux without partition magic?? and then create the new partition.

The reason for this is This server and HD are offsite from me. I would like to do all this and just leave the data in /dev/sda1 and create /dev/sda2.

Is this possible?

blizunt7 10-12-2005 11:30 AM

So, after i resized my NTFS partition, and was still viewable, so i believe it resized correctly.
When i use fdisk, to create the second partition, is this an extended or primary? I believe extended, so i did so.

results of fdisk table print:
Code:

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1              1      18254  146625223+  7  HPFS/NTFS
/dev/sda2          18255      30401    97570777+  5  Extended

i then went to use mke2fs to create the ext3 filesystem, and ran into an error:
Code:

mke2fs 1.37 (21-Mar-2005)
/dev/sda2: Invalid argument passed to ext2 library while setting up superblock

Did i do something wrong here??

Tuttle 10-12-2005 12:23 PM

Quote:

Originally posted by blizunt7
So, after i resized my NTFS partition, and was still viewable, so i believe it resized correctly.
When i use fdisk, to create the second partition, is this an extended or primary? I believe extended, so i did so.

results of fdisk table print:
Code:

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1              1      18254  146625223+  7  HPFS/NTFS
/dev/sda2          18255      30401    97570777+  5  Extended

i then went to use mke2fs to create the ext3 filesystem, and ran into an error:
Code:

mke2fs 1.37 (21-Mar-2005)
/dev/sda2: Invalid argument passed to ext2 library while setting up superblock

Did i do something wrong here??

Primary would have been the one you wanted, an extended partition is a placeholder in which to put more partitions. Just do fdisk again, delete what you created and redo it with a primary partition.
Standard dos style layouts forbid more than 4 primary partitions, that is why the "extended" partition was made, for when you need more than 4 slices.
Everything else is good, n1.

edit: a little more info: the extended partition can occupy one of the first four primary slots ie. sda1,2,3 or 4
All the partitions within the extended partition become sda5,6,7... onwards.

blizunt7 10-12-2005 12:35 PM

WOW, worked like a champion. THanks.
WHen i created it, fdisk automatically created it as a linux filesystem (type 83).

Is this ext3??? i went to mount it as ext3, and did not work, said wrong fstype, bad option, bad superblock on /dev/sda2.

Should i specify the filesystem type ? becuse it wouldnt let me.

THanks again

Tuttle 10-13-2005 07:16 AM

Probably ext2, ext3 is a jounalised version of ext2, a little more robust during a system lockup. Just use the "auto" option in your fstab, then type "mount" to see what type it chose.

Or you could just try "mke2fs", experiment ;)


All times are GMT -5. The time now is 01:10 PM.