Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


Search this Thread
Old 12-05-2005, 01:14 AM   #1
Registered: Aug 2005
Location: India
Posts: 33

Rep: Reputation: 15
Smile 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. :=)
Old 12-05-2005, 02:21 AM   #2
Registered: Dec 2004
Location: Espoo, Finland
Distribution: Gentoo, 2.6.16-gentoo-r11
Posts: 108

Rep: Reputation: 15

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
# ps -ax /usr /mnt/new/usr
should do the trick.

read man cp for more information.

Old 12-05-2005, 02:36 AM   #3
Registered: Jan 2005
Posts: 178

Rep: Reputation: 31
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.

## 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

Last edited by T.Hsu; 12-05-2005 at 02:38 AM.
Old 12-05-2005, 02:54 AM   #4
Registered: Jan 2005
Posts: 178

Rep: Reputation: 31
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.
Old 12-05-2005, 10:03 AM   #5
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,632

Rep: Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260

(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). Make damn sure that you specify the correct drive! 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.

Last edited by sundialsvcs; 12-05-2005 at 10:05 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a system call to SuSE Linux khcm8jw Linux - Newbie 3 10-23-2005 04:36 AM
Adding system call in linux guam Programming 2 12-04-2004 01:38 PM
"which files to copy to hardisk for Hardisk installation " Rehan1 Linux - Newbie 9 08-21-2004 03:11 PM
Dual boot (adding windows to a Linux system) at.walton Linux - Newbie 7 10-27-2003 07:19 AM
adding system call in linux udayan Programming 1 05-02-2002 03:26 AM

All times are GMT -5. The time now is 03:34 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration