moving /var

I recently tried to move /var to a new partition. Booted from some
live cd, moved it and edited /etc/fstab to suit. Broke the machine
as it wouldn't boot afterwards (in fact I recollect it booted but with
no keyboard. Anyway it was unusable.) I thought it might be an initrd
problem, and had a half-baked memory that chrooting into the root
partition and running makeinitrd or somesuch would solve it. But as
usual I got errors from nonexistant /dev and /proc filesystems in the
chroot and so could not build a new initrd. So I copied /dev back
where it came from and reverted fstab and all was well.

I might have been more persistent but had a slow (and expensive) i'net
connection so it was easier to give up.

What should I have done?

TIA

--
richard

--

0

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

moving /var

On Wed, Dec 20, 2006 at 02:36:16PM -0000, wrote:
> I recently tried to move /var to a new partition. Booted from some
> live cd, moved it and edited /etc/fstab to suit. Broke the machine
> as it wouldn't boot afterwards (in fact I recollect it booted but with
> no keyboard. Anyway it was unusable.) I thought it might be an initrd
> problem, and had a half-baked memory that chrooting into the root
> partition and running makeinitrd or somesuch would solve it. But as
> usual I got errors from nonexistant /dev and /proc filesystems in the
> chroot and so could not build a new initrd. So I copied /dev back
> where it came from and reverted fstab and all was well.
>
> I might have been more persistent but had a slow (and expensive) i'net
> connection so it was easier to give up.
>
> What should I have done?
>
How did you move it. What sequence of commands did you use?

Regards,

-Roberto

--
Roberto C. Sanchez
http://people.connexer.com/~roberto
http://www.connexer.com

moving /var

richard@the-place.net wrote:
rtpn> I recently tried to move /var to a new partition. Booted from some
rtpn> What should I have done?

are you moving it because root is getting full? i've always moved
/usr without problem - it's larger, anyhow.

lish "i've got truth
in times of fiction." -hr

--

moving /var

On Wed, 2006-12-20 at 14:36 +0000, wrote:
> I recently tried to move /var to a new partition. Booted from some
> live cd, moved it and edited /etc/fstab to suit. Broke the machine
> as it wouldn't boot afterwards (in fact I recollect it booted but with
> no keyboard. Anyway it was unusable.) I thought it might be an initrd
> problem, and had a half-baked memory that chrooting into the root
> partition and running makeinitrd or somesuch would solve it. But as
> usual I got errors from nonexistant /dev and /proc filesystems in the
> chroot and so could not build a new initrd. So I copied /dev back
> where it came from and reverted fstab and all was well.
>
> I might have been more persistent but had a slow (and expensive) i'net
> connection so it was easier to give up.
>
> What should I have done?

I have done it many times from LiveCD, also from Single user mode. I had
to turn off some logging and other things even in single user mode.

Effectively you have to make sure you get everything. If you are running
Ubuntu there are additional items you need to make sure are taken care
of. (Make sure /var/run and /var/lock are on the root partition for
tmpfs filesystems)

But like I said, I have done it multiple times... heck even once
accidentally reformatted the /var filesystem AND deleted all backups
before the retore, having to recreate it from scratch on the new
filesystem.

So, what did you do to move it? (list of commands used, would be good)
--
greg,

The technology that is
Stronger, better, faster: Linux

moving /var

On Wed, Dec 20, 2006 at 01:41:11PM -0500, Greg Folkert wrote:

> On Wed, 2006-12-20 at 14:36 +0000, wrote:
> > I recently tried to move /var to a new partition. Booted from some
> > live cd, moved it and edited /etc/fstab to suit. Broke the machine
> > as it wouldn't boot afterwards (in fact I recollect it booted but with
> > no keyboard. Anyway it was unusable.) I thought it might be an initrd
> > problem, and had a half-baked memory that chrooting into the root
> > partition and running makeinitrd or somesuch would solve it. But as
> > usual I got errors from nonexistant /dev and /proc filesystems in the
> > chroot and so could not build a new initrd. So I copied /dev back
> > where it came from and reverted fstab and all was well.
> >
> > I might have been more persistent but had a slow (and expensive) i'net
> > connection so it was easier to give up.
> >
> > What should I have done?
>
> I have done it many times from LiveCD, also from Single user mode. I had
> to turn off some logging and other things even in single user mode.
>
> Effectively you have to make sure you get everything. If you are running
> Ubuntu there are additional items you need to make sure are taken care
> of. (Make sure /var/run and /var/lock are on the root partition for
> tmpfs filesystems)
>
> But like I said, I have done it multiple times... heck even once
> accidentally reformatted the /var filesystem AND deleted all backups
> before the retore, having to recreate it from scratch on the new
> filesystem.
>
> So, what did you do to move it? (list of commands used, would be good)

Hmm, it's a couple of weeks ago now. I usually use cp -a for things
like this and then rename the directory and make a new one to mount to,
but in this case I think I used mv. I don't think there are any critical
symlinks. The old /var directory was definitely empty after the move,
because I checked. Anyway cp -a back again put everything into place
and the system booted as normal afterwards.

The implication of your comments is that you don't think there was any
problem with initrd. In fact, I am sure I have done this before with no
problems. I was surprised when there was a problem. I did also move
/usr (to another partition) which was of course trouble-free. Perhaps I
shall try again when I get back to that box ( am in the wrong country at
the moment).

Really, I asked two questions mixed up together. The other is how to
run makeinitrd, or anything else such as lilo or grub-install (or
whatever the command is) in a chroot, when chrooting cuts you off from
the /dev and /proc filesystems so that none of these commands will run.

--
richard

--

moving /var

On Wed, Dec 20, 2006 at 10:01:35PM -0000, wrote:
> On Wed, Dec 20, 2006 at 01:41:11PM -0500, Greg Folkert wrote:
>
> > On Wed, 2006-12-20 at 14:36 +0000, wrote:
> > > I recently tried to move /var to a new partition. Booted from some
> > > live cd, moved it and edited /etc/fstab to suit. Broke the machine
> > > as it wouldn't boot afterwards (in fact I recollect it booted but with

[...]
> > >
> > > What should I have done?
> >
> > I have done it many times from LiveCD, also from Single user mode. I had
> > to turn off some logging and other things even in single user mode.
> >
> > Effectively you have to make sure you get everything. If you are running
> > Ubuntu there are additional items you need to make sure are taken care
> > of. (Make sure /var/run and /var/lock are on the root partition for
> > tmpfs filesystems)

[...]
> >
> > So, what did you do to move it? (list of commands used, would be good)
>
> Hmm, it's a couple of weeks ago now. I usually use cp -a for things
> like this and then rename the directory and make a new one to mount to,
> but in this case I think I used mv. I don't think there are any critical
> symlinks. The old /var directory was definitely empty after the move,
> because I checked. Anyway cp -a back again put everything into place
> and the system booted as normal afterwards.

when I've done it in the past, I have tar'd the whole directory, cp'd
and untar'd it in the new location, change fstab and reboot. done. I
don't see why cp -a wouldn't work too... hmmm... maybe you've got some
other problem and this is just a symptom.

>
> The implication of your comments is that you don't think there was any
> problem with initrd. In fact, I am sure I have done this before with no
> problems. I was surprised when there was a problem. I did also move
> /usr (to another partition) which was of course trouble-free. Perhaps I
> shall try again when I get back to that box ( am in the wrong country at
> the moment).
>
> Really, I asked two questions mixed up together. The other is how to
> run makeinitrd, or anything else such as lilo or grub-install (or
> whatever the command is) in a chroot, when chrooting cuts you off from
> the /dev and /proc filesystems so that none of these commands will run.

mount proc -t proc /mnt/chroot/proc

check the debian install manual, there is information on installing
from another unix system and included there is how to install kernels
from the chroot. should be applicable here.

A

moving /var

On Wed, Dec 20, 2006 at 03:20:33PM -0800, Andrew Sackville-West wrote:

> On Wed, Dec 20, 2006 at 10:01:35PM -0000, wrote:
> > On Wed, Dec 20, 2006 at 01:41:11PM -0500, Greg Folkert wrote:
> >
> > > On Wed, 2006-12-20 at 14:36 +0000, wrote:
> > > > I recently tried to move /var to a new partition. Booted from some
> > > > live cd, moved it and edited /etc/fstab to suit. Broke the machine
> > > > as it wouldn't boot afterwards (in fact I recollect it booted but
with
>
> [...]
> > > Effectively you have to make sure you get everything. I
> [...]
> > >
> > > So, what did you do to move it? (list of commands used, would be good)
> >
> > but in this case I think I used mv
[...]
> when I've done it in the past, I have tar'd the whole directory, cp'd
> and untar'd it in the new location, change fstab and reboot. done. I
> don't see why cp -a wouldn't work too... hmmm... maybe you've got some
> other problem and this is just a symptom.

Yes, I think you must be right. I'll try it again when I get back to
that machine, and see if I can learn more.

[...]
> >
> > Really, I asked two questions mixed up together. The other is how to
> > run makeinitrd, or anything else such as lilo or grub-install (or
> > whatever the command is) in a chroot, when chrooting cuts you off from
> > the /dev and /proc filesystems so that none of these commands will run.
>
> mount proc -t proc /mnt/chroot/proc
>
> check the debian install manual, there is information on installing
> from another unix system and included there is how to install kernels
> from the chroot. should be applicable here.

Thanks to all for the various comments and advice on these two
unconnected issues

--
richard

--

moving /var

Am 2006-12-20 15:20:33, schrieb Andrew Sackville-West:

> mount proc -t proc /mnt/chroot/proc

Ehm, --

mount -t none /proc /mnt/chroot/proc -o bind

would work a little bit better and is the right way to go.

Thanks, Greetings and nice Day
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant

--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSM LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)

moving /var

richard@the-place.net :
> On Wed, Dec 20, 2006 at 01:41:11PM -0500, Greg Folkert wrote:
>
> > On Wed, 2006-12-20 at 14:36 +0000, wrote:
> > > I recently tried to move /var to a new partition. Booted from some
> > > live cd, moved it and edited /etc/fstab to suit. Broke the machine
> >
> > So, what did you do to move it? (list of commands used, would be good)
>
> Hmm, it's a couple of weeks ago now. I usually use cp -a for things
> like this and then rename the directory and make a new one to mount to,
> but in this case I think I used mv. I don't think there are any critical

Note mv doesn't work between filesystems. cp -a or tar/untar (or any
other archiver) is the right way.

> symlinks. The old /var directory was definitely empty after the move,
> because I checked. Anyway cp -a back again put everything into place
> and the system booted as normal afterwards.

I don't understand how.

--
Any technology distinguishable from magic is insufficiently advanced.
(*) http://www.spots.ab.ca/~keeling Linux Counter #80292
- - http://www.faqs.org/rfcs/rfc1855.html Please, don't Cc: me.
Spammers! http://www.spots.ab.ca/~keeling/emails.html

--

moving /var

On 12/21/06, s. keeling wrote:

> Note mv doesn't work between filesystems. cp -a or tar/untar (or any
> other archiver) is the right way.

Are you sure this is true? I think I use mv to do that all the time.

Celejar

--

moving /var

celejar :
> On 12/21/06, s. keeling wrote:
>
> > Note mv doesn't work between filesystems. cp -a or tar/untar (or any
> > other archiver) is the right way.
>
> Are you sure this is true? I think I use mv to do that all the time.

I stand corrected. It was that way prior to v. 4.0 of coreutils. See
"info coreutils mv"

--
Any technology distinguishable from magic is insufficiently advanced.
(*) http://www.spots.ab.ca/~keeling Linux Counter #80292
- - http://www.faqs.org/rfcs/rfc1855.html Please, don't Cc: me.
Spammers! http://www.spots.ab.ca/~keeling/emails.html

--

moving /var

On Wed, Dec 20, 2006 at 10:01:35PM -0000, wrote:

> Really, I asked two questions mixed up together. The other is how to
> run makeinitrd, or anything else such as lilo or grub-install (or
> whatever the command is) in a chroot, when chrooting cuts you off from
> the /dev and /proc filesystems so that none of these commands will run.

I've done this several times over the years as needs change and I've
never had a problem. Here's how I do it:

from single-user mode
format the new partition
mount it on e.g. /newvar
use mc and copy /var to /newvar (keeping same attributes)
shutdown -Fr now
boot the install disk and:
rename /newvar to /oldvar
edit /etc/fstab to point /var to the new partition,
and mount the old var partition on /oldvar
for my friend Justin Case.
reboot to single user mode, and ensure all is well,
reboot to standard mode.
if all looks good, unmount /oldvar and delete the partition or
otherwise reclaim that space.

As far as running a command from within the partition (e.g. chroot) from
a rescue, I note that the Etch installer has this on the rescue-mode
menu (including installing grub or lilo), I would just do that if need
be.

YMMV, good luck.

Doug.

--

moving /var

Am 2006-12-20 13:41:11, schrieb Greg Folkert:
> Effectively you have to make sure you get everything. If you are running
> Ubuntu there are additional items you need to make sure are taken care
> of. (Make sure /var/run and /var/lock are on the root partition for
> tmpfs filesystems)

/var/run and var/lock must NOT be on the root partition.

I have:

----8<------------------------------------------------------------------
# /etc/fstab: static file system information.
#
#

proc /proc proc defaults 0 0
usbdevfs /proc/bus/usb usbdevfs defaults 0 0
/dev/hda2 none swap sw 0 0

/dev/hda1 / ext3 defaults,errors=remount-ro 0 1
/dev/hda3 /tmp ext3 defaults 0 2
/dev/hda5 /usr ext3 defaults 0 2
/dev/hda6 /var ext3 defaults 0 2
/dev/hda7 /var/log ext3 defaults 0 2
----8<------------------------------------------------------------------

and it works since Debian 2.1/Slink

Thanks, Greetings and nice Day
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant

--
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack Apt. 917 ICQ #328449886
50, rue de Soultz MSM LinuxMichi
0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)

moving /var

On Sat, Dec 23, 2006 at 04:55:00PM +0100, Michelle Konzack wrote:
> Am 2006-12-20 13:41:11, schrieb Greg Folkert:
> > Effectively you have to make sure you get everything. If you are running
> > Ubuntu there are additional items you need to make sure are taken care
> > of. (Make sure /var/run and /var/lock are on the root partition for
> > tmpfs filesystems)

while I don't think the above is true, as most of my /var's are not on /
partition, I also don't think that:

>
> /var/run and var/lock must NOT be on the root partition.
>

is true too. I have at least one /var that is not mounted on a
seperate partition making it definitely ON the / partitions.

A

moving /var

On Sat, 2006-12-23 at 09:04 -0800, Andrew Sackville-West wrote:
> On Sat, Dec 23, 2006 at 04:55:00PM +0100, Michelle Konzack wrote:
> > Am 2006-12-20 13:41:11, schrieb Greg Folkert:
> > > Effectively you have to make sure you get everything. If you are running
> > > Ubuntu there are additional items you need to make sure are taken care
> > > of. (Make sure /var/run and /var/lock are on the root partition for
> > > tmpfs filesystems)
>
> while I don't think the above is true, as most of my /var's are not on /
> partition, I also don't think that:
>
> >
> > /var/run and var/lock must NOT be on the root partition.
> >
>
> is true too. I have at least one /var that is not mounted on a
> seperate partition making it definitely ON the / partitions.

Please see my response to Michelle.
--
greg,

The technology that is
Stronger, better, faster: Linux

moving /var

On Sat, Dec 23, 2006 at 03:42:49PM -0500, Greg Folkert wrote:
> On Sat, 2006-12-23 at 09:04 -0800, Andrew Sackville-West wrote:
> > On Sat, Dec 23, 2006 at 04:55:00PM +0100, Michelle Konzack wrote:
> > > Am 2006-12-20 13:41:11, schrieb Greg Folkert:
> > > > Effectively you have to make sure you get everything. If you are running
> > > > Ubuntu there are additional items you need to make sure are taken care

------^^^^^^^^^^^

> > > > of. (Make sure /var/run and /var/lock are on the root partition for
> > > > tmpfs filesystems)
> >
> > while I don't think the above is true, as most of my /var's are not on /
> > partition, I also don't think that:
> >
> > >
> > > /var/run and var/lock must NOT be on the root partition.
> > >
> >
> > is true too. I have at least one /var that is not mounted on a
> > seperate partition making it definitely ON the / partitions.
>
> Please see my response to Michelle.

doh. there it is right there... sorry I missed that.

I was responding to Michelle and missed the context. happy holidays

A

moving /var

On Sat, 2006-12-23 at 16:55 +0100, Michelle Konzack wrote:
> Am 2006-12-20 13:41:11, schrieb Greg Folkert:
> > Effectively you have to make sure you get everything. If you are running
> > Ubuntu there are additional items you need to make sure are taken care
> > of. (Make sure /var/run and /var/lock are on the root partition for
> > tmpfs filesystems)
>
> /var/run and var/lock must NOT be on the root partition.
[...snip...]

As of right NOW, Ubuntu uses a "different" way of booting.

*IF* /var/run and /var/lock are NOT on the initial root (/) filesystem
before the other filesystems are mounted then it fails to boot properly.

In fact "/etc/init.d/mountvirtfs" executed early (S01) in the boot
process has the initial mounting of the tmpfs stuff in it here it is:

# Mount standard /proc filesystem
TYPE=
case "$KERNEL" in
Linux|GNU)
TYPE=proc
;;
*FreeBSD)
TYPE=linprocfs
;;
*)
TYPE=procfs
;;
esac

# Mount standard /proc and /sys.
domount $TYPE /proc
domount sysfs /sys

# Mount /var/run and /var/lock as tmpfs.
# /var may be on another drive so create /var/run if we need to
domount tmpfs /var/run "-o mode=0755"
domount tmpfs /var/lock "-o mode=1777"

# Mount /proc/bus/usb -- though all software should be modified to
# use /dev/bus/usb instead now
domount usbfs /proc/bus/usb

Then later in the boot process, it "remounts" the dirs to a "safe
location" for saving later... then once /var is properly mounted it
remounts them where they properly need to be. Done in mtab (S22) then in
mountall (S35)

I KNOW this is the way it is in Ubuntu, I had a server I setup for a
customer. After I did initial setup, I had to add a real Raid Array
(2.2TB) to various filesystems of which one was /var (before /var was on
root). During the re-deploy I missed making the /var/run and /var/lock
directories as *I* would NEVER have done that normally. This caused
failing to reboot properly, not bringing up the NICs and periodically
falling off the network as well.

I "got" to make a 2 hour each way and 3-5 hour troubleshooting "Gratis"
travel call each time this thing failed. (4 times)

It was tracked down to there NOT being /var/run and /var/lock on the
root(/) filesystem

So, please DO NOT tell me what NOT to do. I specified this was on Ubuntu
on the off chance the person was using Ubuntu.

I'll bet the Lenny (Etch+1) has this.
--
greg,

The technology that is
Stronger, better, faster: Linux

moving /var

On Sat, Dec 23, 2006 at 02:25:51PM -0500, Greg Folkert wrote:

> On Sat, 2006-12-23 at 16:55 +0100, Michelle Konzack wrote:
[..]
> > /var/run and var/lock must NOT be on the root partition.
> [...snip...]
>
> As of right NOW, Ubuntu uses a "different" way of booting.
>
> *IF* /var/run and /var/lock are NOT on the initial root (/) filesystem
> before the other filesystems are mounted then it fails to boot properly.

Aha! This may explain it. No, it wasn't ubuntu installed but the
original setup came from knoppix (just might have been mepis, which is
definitely ubuntuish, but I am pretty sure it was knoppix). Probably,
then a similar issue. I'll try to take the box to somewhere with adsl
and do a full dist-upgrade to etch, including a latest kernel and see if
things are more regular afterwards. There are still a stack of packages
lingering minor numbers behind etch as a result of the lack of available
bandwidth for upgrading.

Thanks again to everybody for the insights.
--
richard

--

moving var

I'd recommend using rsync for this kind of thing.

moving /var

On Wed, Dec 20, 2006 at 02:36:16PM +0000, wrote:
> I recently tried to move /var to a new partition. Booted from some
> live cd, moved it and edited /etc/fstab to suit. Broke the machine
> as it wouldn't boot afterwards (in fact I recollect it booted but with
> no keyboard. Anyway it was unusable.) I thought it might be an initrd
> problem, and had a half-baked memory that chrooting into the root
> partition and running makeinitrd or somesuch would solve it. But as
> usual I got errors from nonexistant /dev and /proc filesystems in the
> chroot and so could not build a new initrd. So I copied /dev back
> where it came from and reverted fstab and all was well.
>
> I might have been more persistent but had a slow (and expensive) i'net
> connection so it was easier to give up.
>
> What should I have done?
>
> TIA
Hi richard,
most of the time /var/cache/apt/archives gets filled as it is where your
debs are downloaded. About .5-1.5 GB should be ok to hold a few updates.
Use 'clean' or 'autoclean' with aptitude when needed.

This is an untested example of how to solve this:
a) create /dev/hdb1 (new partition) with cfdisk
b) mkfs.ext3 /dev/hdb1 # format new partition
c) mount -t /dev/hdb1 /mnt # mount the new partition on a temporary
# mount point
d) mv /var/cache/apt/archives/* /mnt # move the files to the
# temporary mount point
e) umount /mnt # unmount temporary mount point
f) add this to /etc/fstab: # add new partition to fstab
/dev/hdb1 /var/cache/apt/archives ext3 defaults 0 1
g) mount -a # make mount command add the new
# mount point
h) check if all is ok with 'mount' # check if /var/hdb1 and
# /var/cache/apt/archives are listed
done. Next reboot will do this automatically.
Cheers,
Kev
--
| .''`. == Debian GNU/Linux == | my web site: |
| : :' : The Universal | debian.home.pipeline.com |
| `. `' Operating System | go to counter.li.org and |
| `- http://www.debian.org/ | be counted! #238656 |
| my keysever: pgp.mit.edu | my NPO: cfsg.org |

Syndicate content