?
Solved

Move /var to a new HDD.

Posted on 2009-02-10
13
Medium Priority
?
935 Views
Last Modified: 2012-05-06
Hi All,

Does anyone can help me moving my /var to a new HDD? -  a step by step please:

I have a Redhat AS4 installed, on a 30 GB HDD, there are /home/export (500 MB), swap, and / for the rest of the HDD.

Now I've added a new 70GB HDD, is it possible to move the /var to the new one? if yes, how can I do that?

Thank you

M.G
0
Comment
Question by:msghaleb
  • 6
  • 4
  • 2
  • +1
13 Comments
 
LVL 23

Expert Comment

by:Maciej S
ID: 23599178
Boot in single user mode. Mount your new drive/partition wherever you want. Move all files from current /var to that new partition. Change "/var" line in your /etc/fstab to point to new device (if this is your second drive, and it has one partition, it will be probably /dev/sdb1 or /dev/hdb1). Reboot server. That should be all.
0
 
LVL 6

Author Comment

by:msghaleb
ID: 23599201
Hello,

How can I boot in a single user's mode?

Thank you.
0
 
LVL 6

Expert Comment

by:dzamfir
ID: 23599296
Try this:

http://www.redhat.com/docs/manuals/linux/RHL-7.3-Manual/custom-guide/s1-rescuemode-booting-single.html

There are explanations for GRUB and LILO (depends what you are using).
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 40

Accepted Solution

by:
omarfarid earned 2000 total points
ID: 23599347
if you are in multi user mode, then

- run

init s

this should bring you to single user mde

- mount the new partition on /mnt , e.g.

mount /dev/sdb1 /mnt

- move your /var files and dirs to /mnt

cd /var
mv * /mnt
cd /

- unmount /mnt
umount /mnt

- modify your /etc/fstab by either adding a new entry line for mounting /var or by modifying exiting /var line

- try mounting the new filesystem with

mount /var

0
 
LVL 6

Author Comment

by:msghaleb
ID: 23599367
Hello Omarfarid,

Thanks a million for your answer, I have 1 small question regarding your steps, it is ok to do that on a live system? I'm not asking about risk (its a VM and I took a snapshot) but I'm asking if there are in services I need to stop?

Which lines I have to add after words in the /etc/fstab? (I don't have a current /var in there, I assume I'll need to add new lines, do you know which ones)?

Thank you.
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 23599413
when you take the system to single user mode then services are stopped but if you have databases running then make sure that they stop before going to single user mode. It it better to have backup of your system file systems. can you show your /etc/fstab file content? Also, can you give the device name for the new disk partition where you created the new file system?
0
 
LVL 23

Expert Comment

by:Maciej S
ID: 23599416
var line should be something like this (make sure device - here it is /dev/sdb1 - is correct):
/dev/sdb1       /var            ext3    defaults        1 2
you may also change ext3 to ext2 if you are using ext2 filesystem instead of ext3.

After booting into single user mode, you don't need to worry about your services.
0
 
LVL 6

Author Comment

by:msghaleb
ID: 23599467
/etc/fstab:
LABEL=/1                /                       ext3    defaults        1 1
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
LABEL=/export/home1     /export/home            ext3    defaults        1 2
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
LABEL=SWAP-sda3         swap                    swap    defaults        0 0
/dev/hda                /media/cdrom            auto    pamconsole,exec,noauto,managed 0 0
/dev/fd0                /media/floppy           auto    pamconsole,exec,noauto,managed 0 0


I just added the new HDD, didn't really create any partitions, I can see /dev/sdb, I think I'll have to partition it before doing anything - do you have a command for that?

Sorry about the stupid questions - new to the Linux world.

Thank you.

0
 
LVL 6

Author Comment

by:msghaleb
ID: 23599550
Hi Guys,

I've used fdisk /dev/sdb to create a partition and then mkfs -t ext3 /dev/sdb1 to format it ext3

So the Partition issue is now sorted.

Any comments on the extra line in /etc/fstab after having a look on my current one?

Thank you.
0
 
LVL 6

Author Comment

by:msghaleb
ID: 23599605
Do I have to reboot back in Multi user mode?
Regarding the /var line in the /etc/fstab, should it be anywhere in the file? should I add LABEL to it? do I have to unmount the old var ..etc?

Thank you.
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 23599608
add

/dev/sdb1     /var            ext3    defaults        1 2
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 23599632
I don't think that you had a separate file system for /var from what you showed.

you may go to multi-user mode by rebooting the system
0
 
LVL 6

Author Comment

by:msghaleb
ID: 23599681
omarfarid,

Thanks a million, I'll give it a try and get back to you max tommorrow - will do the changes during the night.

Thanks again for everyone.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question