Comments (9)
Hey @jakubpawlowicz, it's great to hear that nixos-in-place has worked for you. What you're looking to do is both certainly possible and not officially supported by this project. With that said, I'll give you some info so on how nixos-in-place works so you can decide whether or not you want to go further.
On your old laptop, with NixOS now, you'll find that there is a file here /etc/nixos/nixos-in-place.nix
that contains the automagically-generated config from your installation. Here's a snippet from mine, where my drive is /dev/vda1
.
{
boot.loader.grub.device = "/dev/vda";
boot.loader.grub.storePath = "/nixos/nix/store";
boot.initrd.supportedFilesystems = [ "ext4" ];
boot.initrd.postDeviceCommands = ''
mkdir -p /mnt-root/old-root ;
mount -t ext4 /dev/vda1 /mnt-root/old-root ;
'';
fileSystems = {
"/" = {
device = "/old-root/nixos";
fsType = "none";
"options" = [ "bind" ];
};
"/old-root" = {
device = "/dev/vda1";
fsType = "ext4";
};
};
}
On some systems like with DigitalOcean, we need old-root
to keep existing. In your case, it seems like you can likely do without. To give it a shot, I'd recommend using a live ISO of some GNU/Linux distro to boot up your machine. From there, mount your drive (on ./mnt
, for example) and delete everything except for ./mnt/nixos
. After that, move everything from within ./mnt/nixos/*
to ./mnt
and delete the empty ./mnt/nixos
directory.
You should then be able to remove nixos-in-place.nix
and make your config look much more like a normal NixOS setup. From there, you'd need to make sure GRUB is updated, so your kernel will be found on your next boot, since it's moved from /nixos/...
to /...
.
This isn't the most thorough outline, since I haven't yet attempted this, but, if you follow through successfully, it'd be great to get your notes. I could then turn it into a wiki page.
Let me know if you have any other questions and best of luck. :) Closing this ticket, but feel free to keep discussing.
from nixos-in-place.
Thanks @jeaye for more details. I've just did it and it seems to work fine, here's a step by step guide:
- Install NixOS via nixos-in-place and reboot into NixOS
- Change
nixos-in-place.nix
to use the following (you can also move what's left to other config files):
{
boot.loader.grub.device = "/dev/vda";
fileSystems = {
"/" = {
device = "/dev/vda";
fsType = "ext4";
};
};
}
- Run
nixos-rebuild boot
so new paths are used - Reboot
- Boot system from a live CD (I used CentOS 7)
- Run following commands via console
mkdir /mnt/root
mount /dev/vda1 /mnt/root
mv /mnt/root/nixos/* /mnt/root
rmdir /mnt/root/nixos
rmdir /mnt/root/old-root
- Reboot
- GRUB will complain that it can't find
/nixos/boot/grub
path, so in GRUB rescue mode type
ls
set prefix=(hd0,1)/boot/grub # use whatever disk you have your /boot/grub folder on
insmod normal
normal
- Select
NixOS default
and boot - Login as root and run
grub-install /dev/vda
At this point I rebooted and everything runs fine.
Some questions:
- How to avoid steps 8-10?
- Can I run grub-install after step 3 to avoid 8-10?
from nixos-in-place.
Awesome work and thanks for the update! I don't think you can run grub-install
after step 3, but I think it should work fine after step 6. I'm thinking the new step 7 can be to chroot into mnt
and run your grub-install
. Then reboot.
Are you able to try that out?
from nixos-in-place.
I tried chrooting with sth like chroot . nix/store/*-nixos-system*/init
but I got the following message "Trying to run as user instance, but the system has not been booted with systemd." and backed out.
from nixos-in-place.
Hm, I wonder if you can chroot in (into /nix/store/*-bash-4.3-*/bin/bash
), skip the init, and run grub-install directly like /nix/store/*-grub-2.x-*/bin/grub-install
.
from nixos-in-place.
Hmmm, that's a good idea. I'll try it tomorrow.
from nixos-in-place.
I've only had a chance to do it again now, but I can confirm that running the following commands after step 6 did the trick:
mount -t proc /proc /mnt/root/proc
mount -o bind /dev /mnt/root/dev
chroot /mnt/root nix/store/*-bash-*/bin/bash
/nix/store/*-grub-*/bin/grub-install /dev/vda
from nixos-in-place.
Nice work! Thanks for the update.
from nixos-in-place.
@jakubpawlowicz Possibly also interesting for you: #41
from nixos-in-place.
Related Issues (20)
- DigitalOcean now uses /dev/vda HOT 2
- ISO download fails HOT 1
- Installation finished but doesn't prompt for a root password HOT 10
- "Failure to set locale" stopping installation HOT 3
- Failed to check file system type of "/boot": No such file or directory HOT 10
- Iso download: unverified, not trustworthy host, not overrideable HOT 12
- Possible race condition in stage1? HOT 3
- Experience report of using nixos-in-place for OVH cloud servers and qemu-guest issue
- init: Permission denied HOT 4
- Failed running on LeaseWeb Ubuntu 16.04 server HOT 1
- error: changing modification time of '...': Read-only file system HOT 4
- Instructions on how to use this to make a Hetzner Cloud snapshot (includes moving /old-root/nixos to /) HOT 8
- Document what this is and what it's not. HOT 1
- login not possible after reboot
- install is not working HOT 1
- Unable to install on VPS HOT 1
- Use drive UUID instead of /dev name
- Instructions for Tiny Core Linux HOT 1
- download link seems offline HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nixos-in-place.