Mounting and editing hard disk from LiveCD

I'm running ZFS on an old machine with 1.5GB RAM, and read that tuning the vm.kmem_size parameter in /boot/loader.conf might help things out. I switched on the machine today and it failed to boot. It gets through the initial boot menu and then shows:

Copyright (c) 1992-2015 The FreeBSD Project
Copyright (c) (dates etc.)
FreeBSD is a registered trademark (etc.)
FreeBSD 11.0-RELEASE-p8 (etc.)
FreeBSD clang version 3.8.0 (etc.)

And that's it.

I've booted into a Live CD with the plan of removing that line, but I can't seem to mount the hard drive. I've found other suggestions that I should be able to cd /tmp then mkdir myDisk and then just use the usual mount -w ada0p3 /tmp/myDisk but I cannot create the directory in /tmp -- I get the result "Read-only file system".

How can I mount the internal drive from the Live CD? Or is there another method I can use to edit /boot/loader.conf?

Thanks!

Edit: to better reflect the nature of the problem
 
How can I mount the internal drive from the Live CD? Or is there another method I can use to edit /boot/loader.conf?

Try this:

Code:
fsck -y
mount -u /
mount -a -t zfs
swapon -a

I don't use ZFS but it's how I enter Single User Mode.
 
Thanks, I tried this but it still won't let me create any directories in /mnt or /tmp
 
Thanks, I tried this but it still won't let me create any directories in /mnt or /tmp

Someone more knowledgeable in that area will have to assist you. I've used that method to enter into Single User More and edit rc.conf from the Live Disk with ee, so I don't know why you get "Read-only file system" and I can write to it.

Once in Single User Mode try:

ee /tmp/somefile[cmd][/cmd]

write to it, save and exit.
 
I'm running ZFS on an old machine with 1.5GB RAM, and read that
How did you install this? Did you simply follow the installer and let it do all the work or did you manually set up all your ZFS mountpoints?

Considering that we're talking about FreeBSD 11 and the nature of your question I'll assume you simply followed the installer, used ZFS on root and have everything set to default.

So, first things first: ZFS isn't a file system like UFS. In fact, as a side note I think that you might have been better off using UFS instead on that machine. But... that's also based on personal opinion. If it works... And ZFS has advantages over UFS.

After you booted your live cd (or rescue, or whatever) use # zpool list. It'll probably tell you that no pools are available, but that's also not what we're after. By issuing this command it will also load the ZFS kernel drivers. If you want to check for yourself use kldstat afterwards. (we could also have used kldload(8) but this is easier, and I'm lazy ;) )

Next stop: ensure that it detects your HD: # gpart show ada0. You could also omit ada0 but..

Make sure that you see a slice type mentioned as freebsd-zfs. You should only have 1 here.

Now to actually access your stuff.. You're right that /mnt is readonly, but a modern FreeBSD boot CD will utilize a ramdisk for both /var and /tmp.

Soooo... # mkdir /tmp/mydata, lets make a mountpoint. Then: # zpool import -fa -R /tmp/mydata.

Now if you'll check zfs list you'll see all your stuff. Except... when looking in /tmp/mydata/zroot nothing will be there. Yah, this is why I think the automated way of installing ZFS is kinda crap. Don't get me wrong; it serves its purpose when you're going to use multiple root file systems and all, but how many people do that? This situation (rescue cd) is far more common.

But... let's keep my bias out of this.

When looking at zfs list you'll notice mention of a filesystem called zroot/ROOT/default. It says it's mounted (/tmp/mystuff) but nothing is there. Yah, that's because this filesystem doesn't get mounted automatically. Once again: to accommodate for that stuff above which I won't speak of anymore :D

So: # zfs mount zroot/ROOT/default. Followed by: cd /tmp/mydata/boot ; vi loader.conf.

I'm sure you'll figure out the rest yourself, good luck!

(edit2): You could also have used zfs mount -a which mounts everything (useful if you ever need to boot singleuser) but I prefer this method myself because it's safer (keeps you in full control).

(edit)

Meant in general: if you don't know the answer to a question, why pretend that you do? Some of the above comments are plain out wrong.
 
Meant in general: if you don't know the answer to a question, why pretend that you do? Some of the above comments are plain out wrong.

I use

Code:
fsck -y
mount -u /
mount -a -t ufs
swapon -a

To enter Single User Mode and can the write to the HDD from the Live Disk using ee. I've never used ZFS and thought that might work for him.

If my comments were just "plain out wrong" then I have no excuse. I plainly state someone with more knowledge in that area will have to assist him. He waited over 24 hours for you to assist him. I'm sure he appreciates it.
 
How did you install this? Did you simply follow the installer and let it do all the work or did you manually set up all your ZFS mountpoints?

Yes, that's precisely what I did! (will explain this in my reply to Wozzeck.Live

Next stop: ensure that it detects your HD: # gpart show ada0. You could also omit ada0 but..

I had done this before and made sure it was there. However, I was doing two things: Escaping to Loader Prompt and Single-user mode.

Soooo... # mkdir /tmp/mydata

This still didn't work, at first... it's because of Single-user mode. I reboot my LiveCD as Multi-User mode and chose Shell, and this finally worked! The rest was all smooth, just as you said.

Thanks a lot for this! I've now booted the system and it all seems to be working fine. For more background on why I have ZFS on this antiquated system, see my reply to Wozzeck.Live below.
 
ZFS consumes a lot of memory.
In my opinion the minimal config for ZFS based system could be 3/4 GO of RAM

ZFS is also known to really sucks with some old controllers.
I don't know how you have set up your system, but with old BIOS you should choose a MBR scheme.
Old BIOS from PC Motherboard doesn't support very well GPT

...

With 1,5 GB of memory there are also some chances you are running FreeBSD i386, anyway, even on AMD64, 1,5 GB is far too low

Since this was mentioned by ShelLuser as well, I should explain why I'm doing something that seems to be ill-advised: I have this old system running so I can learn more about FreeBSD on a live system; play with it, get to know it, break things, fix them -- you know the drill. I figured I'd go for ZFS as so many good things seem to be said about it and thought: "well, I won't be pushing it at all so maybe it'll be OK without the RAM and it'll give me chance to learn about it". I hadn't clocked the thing about i386 being bad though.

So yeah, I'm running i386 with ZFS on root and only 1.5GB RAM. I realise now it's not a great idea and should probably try and get it over to UFS...

So reinstall a system in UFS + Journal, onto a MBR layout
If you want optimal security you can also choose gjournal, significantly more secure that native UFS journal, but a little slower

gjournal can be setup further.

This is something I was thinking about anyway, and the whole process of backing up and restoring to a new filesystem will be a really good exercise for me. I'd like to save one of my user accounts and the main system.

How do I go about it? I've seen that dump and restore only work for UFS, and the guides I've found talk about backing up and then restoring within one filesystem, either UFS or ZFS.

Thanks for taking the time to go over it.
 
This still didn't work, at first... it's because of Single-user mode. I reboot my LiveCD as Multi-User mode and chose Shell, and this finally worked! The rest was all smooth, just as you said.
Happy to hear that you sorted it out!

Ok, a bonus tip... Next time this happens you can still use /mnt. You may not be able to create mount points, but you can still use existing ones. So you could use: # zpool import -fa -R /mnt which will then produce quite a few error messages about not being able to create mount points. Ignore that, and then use the command I mentioned earlier: # zfs mount zroot/ROOT/default (or plain simply: # zfs mount -a).

This would effectively mount your setup on /mnt. Not as elegant as my previous solution, but in times of need...

Maybe something to remember when you don't have a full live cd at hand :)
 
Back
Top