LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   migrating /usr/share to another hd (https://www.linuxquestions.org/questions/linux-general-1/migrating-usr-share-to-another-hd-85443/)

comatosebuddha 08-25-2003 07:01 AM

migrating /usr/share to another hd
 
I have a RH 8.0 on a 80 GB dualboot with WinXP. My 2.0GB root drive has run out of space and I need to move files to another hd partition with 15 GB space. The only alternative to imaging my linux installation and moving it in entirity to the other hd seems to me to be to move certain directories to the other drive and symlink to it in the root. Is it possible? How should I go about it? My /home dir is already on the other hd partition.
Also, is there some util for converting existing FAT32 partitions to ext2/3 without data loss?:scratch:

MacKtheHacK 08-25-2003 09:50 AM

Do you have an unused partition on your drive, or are you wanting to just move the contents of your /usr into an existing filesystem that has more free space?

If you have an unused partition, you need to create a new filesystem within that empty partition. Use the mkfs command to do this. Do you know the pathname for your partition? If it's an IDE disk, it's /dev/hda6 if it's the second extended partition on your first drive, for example.

Once you've created the filesystem, mount it on top of some existing, empty directory. I usually make a new one like /usr.new and mount it there. Then copy all the files in /usr to your new filesystem with "cp -a /usr /usr.new". The -a option (for "archive") means to copy recusively and preserve all permissions, owners, etc.

Now you need to turn your copy into the real /usr. You probably can't unmount /usr because processes are using it, so bring your system down to single-user mode with "telinit 1". That tells the init program to change to run-level one, which will kill off most of the processes running on your system. You can then replace your /usr with your /usr.new by doing this:
umount /usr
mv /usr /usr.old
mv /usr.new /usr
mount /usr

Then do "telinit 5" to bring your system back up to it's usual run-level. Check to make sure everything works right with the new /usr filesystem. Once you're happy with it, you can remove the old /usr with "rm -rf /usr.old", and you'll at last have more space on your root filesystem.

If you have already made filesystems in all your partitions, then you can't do the above. You need to copy the contents of /usr into an existing filesystem with more space. Let's say your partition with 15GB of free space contains your /home filesystem. What you want to do is put all of /usr under /home somewhere, and make /usr be a symlink to the new place. There are some similarities to the above, so I'll just list the commands:
mkdir /home/usr
cp -a /usr /home/usr
telinit 1
umount /usr
mv /usr /usr.old
ln -s /home/usr /usr
telinit 5
Make sure everything works, then remove /usr.old.

Gee, I guess I didn't read your entire post, because you answered my first question. Well, use the second method.

I don't know if any FAT32 converters exist. I'd Google for "Linux FAT32 to ext convert" and see what shows up.

fancypiper 08-25-2003 10:05 AM

Here are some general instructions I wrote up when I decided to re-partition my drives.

# Clone a distro to another drive or move directories around
Install drive in box (assuming IDE1 slave for examples) and ensure BIOS can detect it. Boot into Linux and login to your user's account. Open an x terminal and partition and format the new drive as you wish
Code:

[fancy@tinwhistle fancy]$ su -
Password:
[root@tinwhistle root]# fdisk /dev/hdb

Exit with w to write the partition table.

Format the partitions with the chosen filesystems:
mke2fs /dev/hdbX -> ext2
mke2fs -j /dev/hdbX -> ext3
mkswap -> swap
mkreiserfs -> reiserfs
mkfs.xfs -> xfs

Make directories for source and destination mount points. You need these to keep out of an endless loop of copying itsself over and over.
Code:

[root@tinwhistle root]# mkdir /mnt/source
[root@tinwhistle root]# mkdir /mnt/destination

Mount your os partitions that you want to clone on /mnt/source
Mount your partitions on the new drive, making directory entries for your separate partitions (/boot, /home, /var etc.). If you are just copying a directory such as var, just cd to the directory you wish to copy instead of mounting partitions on /mnt/source.

Now, cd to /mnt/source and pipe it over with tar
Code:

[root@tinwhistle root]# cd /mnt/source
[root@tinwhistle source]# tar cf - . | (cd /mnt/destination && tar xBfp -)

Edit /etc/fstab as needed, install the boot loader if you moved a whole distro, and it should work when it is installed in it's final position.

I don't know of any program that will allow Microsoft filesystems to be converted into Linux native ones. Copy the stuff you need to where you have room, then format the Microsoft partition in the format you want and move the stuff back.

comatosebuddha 08-26-2003 03:10 PM

Thanx for the help.
I could not preserve the data in situ in the other drive but as most of it was dvd video i compressed it (that's what i was doing the last 48 hrs!), burnt it on cd and spaced myself out a bit. Fdisked the fs type to ext3, and copied /usr to /usr.new.
As of now my installation is not giving any problems, but is it too early? I'll know for sure by tomorrow i guess.
In the meanwhile, thanx once again for the help - really appreciated.


All times are GMT -5. The time now is 05:25 AM.