linux: changing partitions after install (and without losing data)?
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: linux: changing partitions after install (and without losing data)?

  1. #1
    Senior Member
    Join Date
    Apr 2002
    Posts
    214

    Question linux: changing partitions after install (and without losing data)?

    I have linux installed on a server box, and it has 2 4.3 gig SCSI drives. When I installed linux, I put all the partitions (2 actually -- root and swap) on the one drive. I read in a book that it might improve a server's performance if the logs were written on another drive.

    So, is it possible to change the partitions without losing any/much data? I want to put all the logs (/var) to the second drive, and leave everything else on the first.

    Thanks
    -Mike
    Either get busy living or get busy dying.

    -The Sawshank Redemption

  2. #2
    Senior Member
    Join Date
    Sep 2001
    Posts
    201
    You should just be able to copy the /var directory over to your new drive/partition. You then need to edit your /etc/fstab to tell it where they now reside.

  3. #3
    Senior Member
    Join Date
    Apr 2002
    Posts
    214
    I'm a newbie to linux, can you give me a short walk-thru on how to edit the fstab to write all logs to the other hdd?
    Either get busy living or get busy dying.

    -The Sawshank Redemption

  4. #4
    Senior Member
    Join Date
    Sep 2001
    Posts
    201

    Disclaimer - I nor Antionline can be held responsable for lost data while following this small tutorial. I cannot garuntee its integrity. Make sure to back up ALL important data.



    Sure thing. Install your new harddrive first. Once that is installed turn on etc. (turn off web server and anything that writes files to /var) You then need to format the new drive. Dependant on the filesystem typoe you use it will be done with different commands. Lets say its reiserfs and you have the new drive on the primary slave so youd type the command ' mkreiserfs /dev/hdb ' This will format it. You then need to mount this to a temporary place such as ' /tmp/dest ' To do this while su'd to root type
    ' mount -t reiserfs /dev/hdb /tmp/dest ' reiserfs should be changed to the filesystem type you formated it to. This now means you can write to the disk as if it was a directory. Staying as root you now need to copy the files over. to do this type ' cp -R /var/* /tmp/dest' This 'should' copy all files and directories to the new disk. The next job is to make sure it has. so look at /tmp/dest to make sure the file heirachy looks the same as your existing /var. also check file permissions (You may find using konqueror easier) If that is the case you can delete all files on the existing /var dir. ONLY do this if you are 100% sure everything is as it should. The next job is to edit the /etc/fstab file to say to mount the new drive at the point /var. Again this varies on your filesystem but is mostly the same. Mine looks like:

    LABEL=/ / ext3 defaults 1 1
    LABEL=/boot /boot ext3 defaults 1 2
    none /dev/pts devpts gid=5,mode=620 0 0
    none /proc proc defaults 0 0
    none /dev/shm tmpfs defaults 0 0
    /dev/hda6 swap swap defaults 0 0
    /dev/hda3 swap swap defaults 0 0
    /dev/cdrom /mnt/cdrom iso9660 noauto,owner,kudzu,ro 0$/dev/cdrom1 /mnt/cdrom1 iso9660 noauto,owner,kudzu,ro 0$/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
    /dev/hda1 /mnt/windows vfat defaults 0 0


    You will need to add the following line to yours after the line that makes refernce to just /.
    The line you add should should look like:

    /dev/hdb /var reiserfs (change to filesystem type) defaults 1 1

    Make sure you change reiserfs to the filesystem you use. The next step is to reboot.
    This will now make /var to be written to the new disk.

    Be careful doing this as if you do it wrong you WILL loose your data.

  5. #5
    Senior Member
    Join Date
    Apr 2002
    Posts
    214
    I hate to sound so stupid, but how do I find out my filesystem type?
    Either get busy living or get busy dying.

    -The Sawshank Redemption

  6. #6
    Senior Member
    Join Date
    Sep 2001
    Posts
    201
    Best way is to look at your fstab

  7. #7
    Senior Member
    Join Date
    Apr 2002
    Posts
    214
    ok, let's see, if i'm understanding this right, there's five different filesystems in my fstab: ext2 (/), iso96600 (/mnt/cdrom) swap (swap) ext2 (/mnt/floppy) proc (/proc) devpts (/dev/pts).

    Which one is the one I should use?
    Either get busy living or get busy dying.

    -The Sawshank Redemption

  8. #8
    Senior Member
    Join Date
    Sep 2001
    Posts
    201
    ext2 would be the good one to use. Swap is for swap partitions proc is s special type iso9660 is a CD/DVD devpts another special one

  9. #9
    Senior Member
    Join Date
    Apr 2002
    Posts
    214
    ok, so in your walk-thru, I just substutite "reiserfs" for ext2?

    also, when I'm representing my 2nd hdd, which /dev thing do I use?
    Either get busy living or get busy dying.

    -The Sawshank Redemption

  10. #10
    Senior Member
    Join Date
    Sep 2001
    Posts
    201
    replace all instances of reiserfs with ext2. The second hard drive varies. If it is on the Master Slave it will be /dev/hdb if the Secondary Master it will be /dev/hdc or the Secondary Slave it would be /dev/hdd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •