LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   adding new hardisk to my linux system (https://www.linuxquestions.org/questions/linux-software-2/adding-new-hardisk-to-my-linux-system-389345/)

vikrambhimbar 12-05-2005 01:14 AM

adding new hardisk to my linux system
 
My /usr is almost 80% and i'm planning to add new hard drive and make it as my new /usr. My problem is how can i transfer those files in my old /usr to my new /usr and how can i mount the new hard drive.

Just need your opinion and much better if there are direct instructions. :=)

Razze 12-05-2005 02:21 AM

Hello!

You can add the new harddrive to your system and create a mount point for the new /usr-directory, for instance /mnt/new/usr.

Then you just copy everything from your old /usr to the new directory. The command
Code:

# ps -ax /usr /mnt/new/usr
should do the trick.

read man cp for more information.

Razze

T.Hsu 12-05-2005 02:36 AM

You'd better do the job outside the running system, eg, from livecd. First mount the destination partition (provided you already partioned the new hd) and current /usr partition, then mv everything under current /usr to the new partition's mount point, most importantly don't forget to add a corresbonding entry to the fstab.

Code:

## Provided your new hd is hdb, and only have one partion on it
## Your current /usr is on /dev/hda1 not independent from /
## Now boot from a rescue CD

mkdir /mnt/new
mkdir /mnt/old

mount -t <fs type> /dev/hda1 /mnt/old
mount -t <fs type> /dev/hdb1 /mnt/new

cp -a /mnt/old/usr/* /mnt/new
rm -rf /mnt/old/usr/*

vim /mnt/old/etc/fstab
## add the following entry
/dev/hdb1 /usr <fs type> defaults 0 2


T.Hsu 12-05-2005 02:54 AM

Oh, I think I misunderstood your meaning, your current /usr is on a separate partion from /. You can move them to a new partition within running system as Razze said, but still don't forget to add a entry to /etc/fstab.

sundialsvcs 12-05-2005 10:03 AM

Lessee...

(1) Install the new drive, as master or slave as appropriate, in a vacant slot on an available IDE-chain in the motherboard. Bring up Linux.

(2) If you're using a current Linux (2.6, with udev), then the device should magically appear in the /dev directory as /dev/hd[a-d] depending on the position where you put the drive. (Chain-1 master=hda, slav=hdb; Chain-2 hdc, hdd.)

(3) Use smartctl to run on-board diagnostics on the drive.

(4) Make a filesystem on the device. I suggest aggressive testing at this point for read-write errors, e.g. #mkfs.ext3 -j -c -c /dev/hd_ (where "_" is the appropriate drive-letter). :eek: Make damn sure that you specify the correct drive! :eek: With aggressive testing options, this could easily take all night. Time to get some sleep...

(5) Now use parted to partition the drive. You might wish to consider putting swap-space here, or an emergency /boot partition, and so on.

(6) After the process completes, make a temporary mount-point and mount the drive: #mkdir /mnt/newdrive && mount /dev/hd_ /mnt/newdrive.

(7) Copy files to the new drive: #rsync --links /usr /mnt/newdrive. (Use man rsync to review the many options here!)

(8) Now update /etc/fstab to mount /usr as this new drive. Meanwhile, add another entry to point to the old partition; make a mount-point for it in /mnt as we did earlier (with "newdrive").

(9) Now you can test your changes by unmounting and remounting .. you may need to drop into single-user mode to do this .. or by restarting the system. Have a LiveCD handy and know how to use it in case you "tpyo" something in the fstab-file and have to edit it.

All of these steps can be done in the background while you do other things, although they will monopolize the disk I/O channels and so the system will be sluggish. The nice command is useful, especially when you are using rsync.

Please read the man pages carefully for all commands mentioned here, before using them! I suggest that you write down a checklist .. with pencil on a nice legal pad .. before you do anything, and that you carefully check off each step.


All times are GMT -5. The time now is 01:31 AM.