NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Is it possible to chroot and then install NetBSD to the boot drive

On 19 Mar 2013 at 8:51, Al Zick wrote:

> Hi,
> On Mar 17, 2013, at 6:57 PM, Greg Troxel wrote:
> >
> > Al <> writes:
> >
> >> What I would like to be able to do is do an install on either another
> >> drive or on an NFS partition. Then chroot to it and then delete the
> >> files that are on /, /var, and /usr and then do a clean install of
> >> NetBSD. Is this possible? If it is, could someone give me a how to on
> >> doing something like this?
> >
> > chrooting will be awkward, because once you chroot then you will be
> > running the binaries from the new install, which only works if your  
> > host
> > system is compatible (NetBSD, same or later, more or less).  And if  
> > you
> > remove files, you won't be able to run new commands.
> >
> > However, you don't need to chroot.  If you take a new drive, and
> > fdisk/disklabel it, and mount it, and then unpack the sets, and then
> > install bootblocks, it should work.  You didn't mention, but if you  
> > mean
> > i386, then bootblocks consists of installboot for bootxx_ffsv1
> > (probably) and also /boot, plus mbr boot records.  If the host is  
> > NetBSD
> > you can just use installboot and cp, pointing to /usr/mdec in the new
> > system.
> >
> > I have done something similar a number of times, basically moving a
> > system from old disks to new (bigger, less aged and in theory more
> > reliable) disks.  So instead of unpacking sets, I have done dump/ 
> > restore
> > or rsync from old to new (under /mnt) and then installed bootblocks.
> I have a system that I sent new drives out to the data center not  
> that long ago. I did a new install of NetBSD on them, but then I  
> decided to update to NetBSD 6.0. In the process, I broke some things.  
> Now the system is not very usable. I can get another hard drive and  
> install NetBSD on it and then send them that drive, but someone at  
> the data center will need to swap out the drive again. I don't see  
> how I could netboot this system and it is not real easy to tell it to  
> boot from another drive or partition, so I thought that there might  
> be some way to setup a root filesystem much like you do when you  
> netboot. Temporarily mount this partition to run make dev files, then  
> switch over to it, and unmount /home, /var, /usr,  and finely /. Run  
> newfs on the old /, /var, and /usr. Mount / as /mnt, then /var  as / 
> mnt/var and /usr as /mnt/usr. Then cd to /mnt and untar a working  
> install that I did on a test box that has the exact same config as  
> this system, so that everything will be right in /etc. Is there any  
> way to do this?
> Thanks,
> Al

Assuming you still have remote access to the system  it may
not require the above and you can try method below on your
test setup.

I had an unusable system when I had tried update from 5.x 
to 6.0-beta and then tried to backout to 5.y. Possibly I
had a bad 6.0beta cdrom. I then found that backing out is
not supported.
I still had ssh access and eventually I copied a new kernel
and tried to use a script to install sets. This is best done
single user but would require network access to be enabled
and I've not tried that as my pcs are all accessible. 
Stopping as many services as practical may be advisable.

(1) copy sets to some directory

(2) copy new kernel to /

(3) copy script to some directory 

(4) reboot

(5) unpack sets
cd /
for i in base comp games man misc modules tests text ; do
    pax -rvzpoe -f /sets/${i}.tgz

(6) reboot

The etc.tgz set is deliberately missing from above 
If feeling brave you could then use /etcmanage to tidy up
but I prefer to use an occasional sysinstall from a cd.

Without using /etcmanage I've updated from 4.x through to
6.1RC1 but have other systems with more recent cd installs
and along with warnings in /var/log/messages or 
/var/run/dmesg can fix problems in /etc later.

With 4.x and possibly 5.0 I needed to run "fsck_ffs -c 4"
for all the filesystems and change entries in fstab to
enable wapbl. 


Home | Main Index | Thread Index | Old Index